diff --git a/packages/eslint-plugin/src/configs/react-base.ts b/packages/eslint-plugin/src/configs/react-base.ts index 892760cd1f..791a4377b5 100644 --- a/packages/eslint-plugin/src/configs/react-base.ts +++ b/packages/eslint-plugin/src/configs/react-base.ts @@ -8,7 +8,7 @@ * This configuration is intended to be combined with other configs from this * package. */ -import * as restrictedGlobals from 'confusing-browser-globals'; +import restrictedGlobals from 'confusing-browser-globals'; /** * Rule set originally adapted from: diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json index 070f94efdc..214f415f98 100644 --- a/packages/eslint-plugin/tsconfig.json +++ b/packages/eslint-plugin/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "moduleResolution": "node16", + "module": "node16", "types": ["node", "jest"] }, "include": [], diff --git a/packages/eslint-plugin/tsconfig.lib.json b/packages/eslint-plugin/tsconfig.lib.json index 1d2ddef3c1..fbc2a0755e 100644 --- a/packages/eslint-plugin/tsconfig.lib.json +++ b/packages/eslint-plugin/tsconfig.lib.json @@ -1,7 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "commonjs", "outDir": "../../dist/out-tsc", "declaration": true, "types": ["node"] diff --git a/packages/eslint-plugin/tsconfig.spec.json b/packages/eslint-plugin/tsconfig.spec.json index 869c90c526..a358285f72 100644 --- a/packages/eslint-plugin/tsconfig.spec.json +++ b/packages/eslint-plugin/tsconfig.spec.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "commonjs", "types": ["jest", "node"] }, "include": [ diff --git a/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap b/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap index d59b9e9875..dbc51f509d 100644 --- a/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap +++ b/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap @@ -36,7 +36,7 @@ exports[`@nx/eslint:workspace-rules-project should generate the required files 2 "extends": "../../tsconfig.base.json", "compilerOptions": { "moduleResolution": "node16", - "module": "commonjs" + "module": "node16" }, "files": [], "include": [], @@ -70,7 +70,6 @@ exports[`@nx/eslint:workspace-rules-project should generate the required files 4 "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "commonjs", "types": ["jest", "node"] }, "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] diff --git a/packages/eslint/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ b/packages/eslint/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ index b316654a5a..23c840040a 100644 --- a/packages/eslint/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +++ b/packages/eslint/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ @@ -2,7 +2,7 @@ "extends": "<%= rootTsConfigPath %>", "compilerOptions": { "moduleResolution": "node16", - "module": "commonjs" + "module": "node16" }, "files": [], "include": [], diff --git a/packages/eslint/src/generators/workspace-rules-project/workspace-rules-project.ts b/packages/eslint/src/generators/workspace-rules-project/workspace-rules-project.ts index ba2df7530e..0b9bbaa217 100644 --- a/packages/eslint/src/generators/workspace-rules-project/workspace-rules-project.ts +++ b/packages/eslint/src/generators/workspace-rules-project/workspace-rules-project.ts @@ -87,6 +87,8 @@ export async function lintWorkspaceRulesProjectGenerator( tree, join(workspaceLintPluginDir, 'tsconfig.spec.json'), (json) => { + delete json.compilerOptions?.module; + if (json.include) { json.include = json.include.map((v) => { if (v.startsWith('src/**')) { diff --git a/packages/eslint/src/migrations/update-17-1-0/__snapshots__/update-typescript-eslint.spec.ts.snap b/packages/eslint/src/migrations/update-17-1-0/__snapshots__/update-typescript-eslint.spec.ts.snap index 88550a1027..63db3f321f 100644 --- a/packages/eslint/src/migrations/update-17-1-0/__snapshots__/update-typescript-eslint.spec.ts.snap +++ b/packages/eslint/src/migrations/update-17-1-0/__snapshots__/update-typescript-eslint.spec.ts.snap @@ -59,9 +59,34 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ exports[`update-typescript-eslint migration should update the tsconfig.json 1`] = ` "{ "compilerOptions": { - "module": "commonjs", + "module": "node16", "moduleResolution": "node16" } } " `; + +exports[`update-typescript-eslint migration should update the tsconfig.json 2`] = ` +"{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["jest", "node"] + }, + "include": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*_spec.ts", + "**/*_test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx", + "**/*.d.ts", + "jest.config.ts" + ] +} +" +`; diff --git a/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.spec.ts b/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.spec.ts index 03e084110e..34bfd3f372 100644 --- a/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.spec.ts +++ b/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.spec.ts @@ -14,6 +14,28 @@ describe('update-typescript-eslint migration', () => { module: 'commonjs', }, }); + writeJson(tree, 'tools/eslint-rules/tsconfig.spec.json', { + extends: './tsconfig.json', + compilerOptions: { + outDir: '../../dist/out-tsc', + module: 'commonjs', + types: ['jest', 'node'], + }, + include: [ + '**/*.spec.ts', + '**/*.test.ts', + '**/*_spec.ts', + '**/*_test.ts', + '**/*.spec.tsx', + '**/*.test.tsx', + '**/*.spec.js', + '**/*.test.js', + '**/*.spec.jsx', + '**/*.test.jsx', + '**/*.d.ts', + 'jest.config.ts', + ], + }); tree.write( 'tools/eslint-rules/jest.config.ts', @@ -82,6 +104,9 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ expect( tree.read('tools/eslint-rules/tsconfig.json', 'utf-8') ).toMatchSnapshot(); + expect( + tree.read('tools/eslint-rules/tsconfig.spec.json', 'utf-8') + ).toMatchSnapshot(); }); it('should update the jest.config.ts', async () => { diff --git a/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.ts b/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.ts index 4a90cb4db9..cc2844b62c 100644 --- a/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.ts +++ b/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.ts @@ -34,15 +34,24 @@ function updateJestConfig(tree: Tree) { } } -function updateTsConfig(tree: Tree) { +function updateTsConfigs(tree: Tree) { const tsConfigPath = 'tools/eslint-rules/tsconfig.json'; if (tree.exists(tsConfigPath)) { updateJson(tree, tsConfigPath, (tsConfig) => { tsConfig.compilerOptions ??= {}; tsConfig.compilerOptions.moduleResolution = 'node16'; + tsConfig.compilerOptions.module = 'node16'; return tsConfig; }); } + const tsConfigSpec = 'tools/eslint-rules/tsconfig.spec.json'; + if (tree.exists(tsConfigSpec)) { + updateJson(tree, tsConfigSpec, (tsConfigSpec) => { + delete tsConfigSpec.compilerOptions?.module; + delete tsConfigSpec.compilerOptions?.moduleResolution; + return tsConfigSpec; + }); + } } function updateRecommended(tree: Tree) { @@ -91,7 +100,7 @@ function updateRecommended(tree: Tree) { export default async function update(tree: Tree) { updateJestConfig(tree); - updateTsConfig(tree); + updateTsConfigs(tree); updateRecommended(tree); await formatFiles(tree); diff --git a/tools/eslint-rules/tsconfig.json b/tools/eslint-rules/tsconfig.json index 6db9d51433..ca63ae2215 100644 --- a/tools/eslint-rules/tsconfig.json +++ b/tools/eslint-rules/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "moduleResolution": "node16", - "module": "commonjs" + "module": "node16" }, "files": [], "include": [], diff --git a/tools/eslint-rules/tsconfig.spec.json b/tools/eslint-rules/tsconfig.spec.json index f95b08f8f7..960d8000ce 100644 --- a/tools/eslint-rules/tsconfig.spec.json +++ b/tools/eslint-rules/tsconfig.spec.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "commonjs", "types": ["jest", "node"] }, "include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts", "jest.config.ts"]