Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linter): fix flat config migration #19742

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/eslint/src/generators/init/init-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ function migrateEslintFile(projectEslintPath: string, tree: Tree) {
'plugin:@nrwl/typescript',
'plugin:@nrwl/javascript',
]);
console.warn('Flat eslint config is not supported yet for migration');
tree.write(projectEslintPath, config);
} else {
updateJson(tree, projectEslintPath, (json) => {
Expand Down
10 changes: 8 additions & 2 deletions packages/eslint/src/generators/utils/flat-config/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,24 @@ export function addBlockToFlatConfigExport(
});
const insert = printer.printNode(ts.EmitHint.Expression, config, source);
if (options.insertAtTheEnd) {
const index =
exportsArray.length > 0
? exportsArray.at(exportsArray.length - 1).end
: exportsArray.pos;
return applyChangesToString(content, [
{
type: ChangeType.Insert,
index: exportsArray[exportsArray.length - 1].end,
index,
text: `,\n${insert}`,
},
]);
} else {
const index =
exportsArray.length > 0 ? exportsArray.at(0).pos : exportsArray.pos;
return applyChangesToString(content, [
{
type: ChangeType.Insert,
index: exportsArray[0].pos,
index,
text: `\n${insert},`,
},
]);
Expand Down