Skip to content

Commit

Permalink
fix(linter): fix flat config migration (#19742)
Browse files Browse the repository at this point in the history
(cherry picked from commit fc468a5)
  • Loading branch information
meeroslav authored and FrozenPandaz committed Nov 1, 2023
1 parent 5ab5362 commit 45c9867
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit 45c9867

Please sign in to comment.