Skip to content

Commit 636cd77

Browse files
authored
fix(linter): remove legacy dependencies during convert to flat config (#28981)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` are left at old versions after converting to flat config. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` are removed when converting to flat config. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent 76d61ea commit 636cd77

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

packages/eslint/src/generators/convert-to-flat-config/generator.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ describe('convert-to-flat-config generator', () => {
4747
});
4848
});
4949

50+
it('should update dependencies', async () => {
51+
await lintProjectGenerator(tree, {
52+
skipFormat: false,
53+
linter: Linter.EsLint,
54+
project: 'test-lib',
55+
setParserOptionsProject: false,
56+
});
57+
await convertToFlatConfigGenerator(tree, options);
58+
59+
expect(tree.read('package.json', 'utf-8')).toMatchInlineSnapshot(`
60+
"{
61+
"name": "@proj/source",
62+
"dependencies": {},
63+
"devDependencies": {
64+
"@eslint/eslintrc": "^2.1.1",
65+
"@nx/eslint": "0.0.1",
66+
"@nx/eslint-plugin": "0.0.1",
67+
"eslint": "^9.8.0",
68+
"eslint-config-prettier": "^9.0.0",
69+
"typescript-eslint": "^8.0.0"
70+
}
71+
}
72+
"
73+
`);
74+
});
75+
5076
it('should convert json successfully', async () => {
5177
await lintProjectGenerator(tree, {
5278
skipFormat: false,

packages/eslint/src/generators/convert-to-flat-config/generator.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ProjectConfiguration,
99
readJson,
1010
readNxJson,
11+
removeDependenciesFromPackageJson,
1112
Tree,
1213
updateJson,
1314
updateProjectConfiguration,
@@ -240,4 +241,10 @@ function processConvertedConfig(
240241
}
241242

242243
addDependenciesToPackageJson(tree, {}, devDependencies);
244+
245+
removeDependenciesFromPackageJson(
246+
tree,
247+
['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'],
248+
['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser']
249+
);
243250
}

0 commit comments

Comments
 (0)