diff --git a/packages/eslint/src/generators/convert-to-flat-config/generator.spec.ts b/packages/eslint/src/generators/convert-to-flat-config/generator.spec.ts index 988dfd588b04d..aeb150d9d134a 100644 --- a/packages/eslint/src/generators/convert-to-flat-config/generator.spec.ts +++ b/packages/eslint/src/generators/convert-to-flat-config/generator.spec.ts @@ -47,6 +47,32 @@ describe('convert-to-flat-config generator', () => { }); }); + it('should update dependencies', async () => { + await lintProjectGenerator(tree, { + skipFormat: false, + linter: Linter.EsLint, + project: 'test-lib', + setParserOptionsProject: false, + }); + await convertToFlatConfigGenerator(tree, options); + + expect(tree.read('package.json', 'utf-8')).toMatchInlineSnapshot(` + "{ + "name": "@proj/source", + "dependencies": {}, + "devDependencies": { + "@eslint/eslintrc": "^2.1.1", + "@nx/eslint": "0.0.1", + "@nx/eslint-plugin": "0.0.1", + "eslint": "^9.8.0", + "eslint-config-prettier": "^9.0.0", + "typescript-eslint": "^8.0.0" + } + } + " + `); + }); + it('should convert json successfully', async () => { await lintProjectGenerator(tree, { skipFormat: false, diff --git a/packages/eslint/src/generators/convert-to-flat-config/generator.ts b/packages/eslint/src/generators/convert-to-flat-config/generator.ts index 795b97b6c91fa..5e68663fda610 100644 --- a/packages/eslint/src/generators/convert-to-flat-config/generator.ts +++ b/packages/eslint/src/generators/convert-to-flat-config/generator.ts @@ -8,6 +8,7 @@ import { ProjectConfiguration, readJson, readNxJson, + removeDependenciesFromPackageJson, Tree, updateJson, updateProjectConfiguration, @@ -240,4 +241,10 @@ function processConvertedConfig( } addDependenciesToPackageJson(tree, {}, devDependencies); + + removeDependenciesFromPackageJson( + tree, + ['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'], + ['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'] + ); }