From 79c9233553d57363b6b1c33ae0790a9ae572c9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Jona=C5=A1?= Date: Thu, 2 Nov 2023 10:09:40 +0100 Subject: [PATCH] feat(linter): update typescript-eslint to v6 (#19548) Co-authored-by: FrozenPandaz Co-authored-by: Jack Hsu --- e2e/eslint/src/linter.test.ts | 11 +- package.json | 8 +- packages/angular/package.json | 2 +- .../utils/insert-ngmodule-import.ts | 4 +- packages/eslint-plugin/package.json | 6 +- .../update-16-0-0-add-nx-packages.spec.ts | 16 +- .../src/rules/dependency-checks.ts | 8 +- .../src/rules/enforce-module-boundaries.ts | 15 +- .../src/rules/nx-plugin-checks.ts | 9 +- .../src/utils/create-eslint-rule.ts | 3 - packages/eslint-plugin/tsconfig.json | 1 + packages/eslint/migrations.json | 19 + .../__snapshots__/workspace-rule.spec.ts.snap | 6 +- .../workspace-rule/files/__name__.ts__tmpl__ | 2 +- .../workspace-rule/workspace-rule.spec.ts | 2 +- .../workspace-rules-project.spec.ts.snap | 4 +- .../files/tsconfig.json__tmpl__ | 1 + .../workspace-rules-project.ts | 52 +-- .../update-typescript-eslint.spec.ts.snap | 67 ++++ .../update-typescript-eslint.spec.ts | 102 ++++++ .../update-17-1-0/update-typescript-eslint.ts | 98 +++++ packages/eslint/src/utils/versions.ts | 2 +- .../files/fastify/src/app/app.ts__tmpl__ | 2 +- .../src/app/plugins/sensible.ts__tmpl__ | 2 +- .../fastify/src/app/routes/root.ts__tmpl__ | 4 +- .../__snapshots__/application.spec.ts.snap | 2 +- .../get-in-source-vitest-tests-template.ts | 2 +- .../__snapshots__/library.spec.ts.snap | 8 +- pnpm-lock.yaml | 343 +++++++++++------- tools/eslint-rules/jest.config.ts | 5 +- .../rules/valid-schema-description.ts | 2 +- tools/eslint-rules/tsconfig.json | 1 + 32 files changed, 584 insertions(+), 225 deletions(-) delete mode 100644 packages/eslint-plugin/src/utils/create-eslint-rule.ts create mode 100644 packages/eslint/src/migrations/update-17-1-0/__snapshots__/update-typescript-eslint.spec.ts.snap create mode 100644 packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.spec.ts create mode 100644 packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.ts diff --git a/e2e/eslint/src/linter.test.ts b/e2e/eslint/src/linter.test.ts index 5eb0bd798d..4dd88cf44f 100644 --- a/e2e/eslint/src/linter.test.ts +++ b/e2e/eslint/src/linter.test.ts @@ -17,13 +17,6 @@ import { } from '@nx/e2e/utils'; import * as ts from 'typescript'; -/** - * Importing this helper from @typescript-eslint/type-utils to ensure - * compatibility with TS < 4.8 due to the API change in TS4.8. - * This helper allows for support of TS <= 4.8. - */ -import { getModifiers } from '@typescript-eslint/type-utils'; - describe('Linter', () => { describe('Integrated', () => { const myapp = uniq('myapp'); @@ -494,7 +487,7 @@ describe('Linter', () => { `libs/${mylib}/src/lib/${mylib}.ts`, (content) => `import { names } from '@nx/devkit';\n\n` + - content.replace(/return .*;/, `return names(${mylib}).className;`) + content.replace(/=> .*;/, `=> names(${mylib}).className;`) ); // output should now report missing dependency @@ -847,7 +840,7 @@ function updateGeneratedRuleImplementation( ) { return ts.factory.updateMethodDeclaration( node, - getModifiers(node), + node.modifiers, node.asteriskToken, node.name, node.questionToken, diff --git a/package.json b/package.json index a031c4b157..00e52eec79 100644 --- a/package.json +++ b/package.json @@ -129,10 +129,10 @@ "@types/tmp": "^0.2.0", "@types/yargs": "^17.0.10", "@types/yarnpkg__lockfile": "^1.1.5", - "@typescript-eslint/eslint-plugin": "5.62.0", - "@typescript-eslint/parser": "5.62.0", - "@typescript-eslint/type-utils": "5.60.1", - "@typescript-eslint/utils": "5.62.0", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", + "@typescript-eslint/type-utils": "^6.9.1", + "@typescript-eslint/utils": "^6.9.1", "@xstate/immer": "0.3.1", "@xstate/inspect": "0.7.0", "@xstate/react": "3.0.1", diff --git a/packages/angular/package.json b/packages/angular/package.json index 0d5cff872a..6539314749 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -47,7 +47,7 @@ }, "dependencies": { "@phenomnomnominal/tsquery": "~5.0.1", - "@typescript-eslint/type-utils": "^5.36.1", + "@typescript-eslint/type-utils": "^6.9.1", "chalk": "^4.1.0", "find-cache-dir": "^3.3.2", "ignore": "^5.0.4", diff --git a/packages/angular/src/generators/utils/insert-ngmodule-import.ts b/packages/angular/src/generators/utils/insert-ngmodule-import.ts index 64f51c7047..f7debaf22d 100644 --- a/packages/angular/src/generators/utils/insert-ngmodule-import.ts +++ b/packages/angular/src/generators/utils/insert-ngmodule-import.ts @@ -211,7 +211,7 @@ function findPropertyAssignment( ) as PropertyAssignment; } -let tsUtils: typeof import('@typescript-eslint/type-utils'); -function getTsEsLintTypeUtils(): typeof import('@typescript-eslint/type-utils') { +let tsUtils; +function getTsEsLintTypeUtils() { return tsUtils ?? require('@typescript-eslint/type-utils'); } diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 4099dce24a..a50fee04c6 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -24,7 +24,7 @@ }, "homepage": "https://nx.dev", "peerDependencies": { - "@typescript-eslint/parser": "^5.60.1", + "@typescript-eslint/parser": "^6.9.1", "eslint-config-prettier": "^9.0.0" }, "peerDependenciesMeta": { @@ -35,8 +35,8 @@ "dependencies": { "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", - "@typescript-eslint/type-utils": "^5.60.1", - "@typescript-eslint/utils": "^5.60.1", + "@typescript-eslint/type-utils": "^6.9.1", + "@typescript-eslint/utils": "^6.9.1", "chalk": "^4.1.0", "confusing-browser-globals": "^1.0.9", "jsonc-eslint-parser": "^2.1.0", diff --git a/packages/eslint-plugin/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts b/packages/eslint-plugin/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts index d39970c561..f75974eea6 100644 --- a/packages/eslint-plugin/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +++ b/packages/eslint-plugin/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts @@ -71,15 +71,13 @@ describe('update-16-0-0-add-nx-packages', () => { expect(tree.read('ignored-file.ts').toString()).toMatchInlineSnapshot(` "// eslint-disable-next-line @nx/enforce-module-boundaries - /* - * eslint-disable @nx/enforce-module-boundaries - */ - // eslint-disable-line @nx/enforce-module-boundaries - " - `); - expect(tree.read('plugin.ts').toString()).toMatchInlineSnapshot(` - "import * as p from '@nrwl/nx-plugin'; - " + /* + * eslint-disable @nx/enforce-module-boundaries + */ + // eslint-disable-line @nx/enforce-module-boundaries" `); + expect(tree.read('plugin.ts').toString()).toMatchInlineSnapshot( + `"import * as p from '@nrwl/nx-plugin'"` + ); }); }); diff --git a/packages/eslint-plugin/src/rules/dependency-checks.ts b/packages/eslint-plugin/src/rules/dependency-checks.ts index 190ef955d4..5bbca10f71 100644 --- a/packages/eslint-plugin/src/rules/dependency-checks.ts +++ b/packages/eslint-plugin/src/rules/dependency-checks.ts @@ -4,8 +4,6 @@ import { AST } from 'jsonc-eslint-parser'; import { type JSONLiteral } from 'jsonc-eslint-parser/lib/parser/ast'; import { normalizePath, workspaceRoot } from '@nx/devkit'; import { findNpmDependencies } from '@nx/js/src/utils/find-npm-dependencies'; - -import { createESLintRule } from '../utils/create-eslint-rule'; import { readProjectGraph } from '../utils/project-graph-utils'; import { findProject, getSourceFilePath } from '../utils/runtime-lint-utils'; import { @@ -13,6 +11,8 @@ import { getPackageJson, getProductionDependencies, } from '../utils/package-json-utils'; +import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'; +import { ESLintUtils } from '@typescript-eslint/utils'; export type Options = [ { @@ -34,13 +34,13 @@ export type MessageIds = export const RULE_NAME = 'dependency-checks'; -export default createESLintRule({ +export default ESLintUtils.RuleCreator(() => ``)({ name: RULE_NAME, meta: { type: 'suggestion', docs: { description: `Checks dependencies in project's package.json for version mismatches`, - recommended: 'error', + recommended: 'recommended', }, fixable: 'code', schema: [ diff --git a/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts b/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts index b69fefad88..93e49a4066 100644 --- a/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts +++ b/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts @@ -8,15 +8,16 @@ import { import { isRelativePath } from 'nx/src/utils/fileutils'; import { checkCircularPath, - findFilesWithDynamicImports, findFilesInCircularPath, + findFilesWithDynamicImports, } from '../utils/graph-utils'; import { + appIsMFERemote, DepConstraint, findConstraintsFor, findDependenciesWithTags, - findProjectUsingImport, findProject, + findProjectUsingImport, findTransitiveExternalDependencies, getSourceFilePath, getTargetProjectBasedOnRelativeImport, @@ -27,12 +28,11 @@ import { hasNoneOfTheseTags, isAbsoluteImportIntoAnotherProject, isAngularSecondaryEntrypoint, + isComboDepConstraint, isDirectDependency, matchImportWithWildcard, onlyLoadChildren, stringifyTags, - isComboDepConstraint, - appIsMFERemote, } from '../utils/runtime-lint-utils'; import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils'; import { basename, dirname, relative } from 'path'; @@ -41,8 +41,9 @@ import { getBarrelEntryPointProjectNode, getRelativeImportPath, } from '../utils/ast-utils'; -import { createESLintRule } from '../utils/create-eslint-rule'; import { readProjectGraph } from '../utils/project-graph-utils'; +import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'; +import { ESLintUtils } from '@typescript-eslint/utils'; type Options = [ { @@ -73,13 +74,13 @@ export type MessageIds = | 'notTagsConstraintViolation'; export const RULE_NAME = 'enforce-module-boundaries'; -export default createESLintRule({ +export default ESLintUtils.RuleCreator(() => ``)({ name: RULE_NAME, meta: { type: 'suggestion', docs: { description: `Ensure that module boundaries are respected within the monorepo`, - recommended: 'error', + recommended: 'recommended', }, fixable: 'code', schema: [ diff --git a/packages/eslint-plugin/src/rules/nx-plugin-checks.ts b/packages/eslint-plugin/src/rules/nx-plugin-checks.ts index 8d56062ad2..ea0b5eb966 100644 --- a/packages/eslint-plugin/src/rules/nx-plugin-checks.ts +++ b/packages/eslint-plugin/src/rules/nx-plugin-checks.ts @@ -1,5 +1,6 @@ import type { AST } from 'jsonc-eslint-parser'; import type { TSESLint } from '@typescript-eslint/utils'; +import { ESLintUtils } from '@typescript-eslint/utils'; import { ProjectGraphProjectNode, @@ -10,11 +11,9 @@ import { findProject, getSourceFilePath } from '../utils/runtime-lint-utils'; import { existsSync } from 'fs'; import { registerTsProject } from '@nx/js/src/internal'; import * as path from 'path'; - -import { createESLintRule } from '../utils/create-eslint-rule'; +import { join } from 'path'; import { readProjectGraph } from '../utils/project-graph-utils'; import { valid } from 'semver'; -import { join } from 'path'; type Options = [ { @@ -49,12 +48,12 @@ export type MessageIds = export const RULE_NAME = 'nx-plugin-checks'; -export default createESLintRule({ +export default ESLintUtils.RuleCreator(() => ``)({ name: RULE_NAME, meta: { docs: { description: 'Checks common nx-plugin configuration files for validity', - recommended: 'error', + recommended: 'recommended', }, schema: [ { diff --git a/packages/eslint-plugin/src/utils/create-eslint-rule.ts b/packages/eslint-plugin/src/utils/create-eslint-rule.ts deleted file mode 100644 index 68b7c15a66..0000000000 --- a/packages/eslint-plugin/src/utils/create-eslint-rule.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { ESLintUtils } from '@typescript-eslint/utils'; - -export const createESLintRule = ESLintUtils.RuleCreator(() => ``); diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json index 58bd2c97a6..070f94efdc 100644 --- a/packages/eslint-plugin/tsconfig.json +++ b/packages/eslint-plugin/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "moduleResolution": "node16", "types": ["node", "jest"] }, "include": [], diff --git a/packages/eslint/migrations.json b/packages/eslint/migrations.json index 011866d8c0..c2bc56b4a0 100644 --- a/packages/eslint/migrations.json +++ b/packages/eslint/migrations.json @@ -27,6 +27,11 @@ "version": "17.0.0-beta.7", "description": "update-17-0-0-rename-to-eslint", "implementation": "./src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint" + }, + "update-typescript-eslint": { + "version": "17.1.0-beta.1", + "description": "Updates for @typescript-utils/utils v6.9.1+", + "implementation": "./src/migrations/update-17-1-0/update-typescript-eslint" } }, "packageJsonUpdates": { @@ -82,6 +87,20 @@ "version": "^9.0.0" } } + }, + "17.1.0": { + "version": "17.1.0-beta.1", + "packages": { + "@typescript-eslint/parser": { + "version": "^6.9.1" + }, + "@typescript-eslint/eslint-plugin": { + "version": "^6.9.1" + }, + "@typescript-eslint/utils": { + "version": "^6.9.1" + } + } } } } diff --git a/packages/eslint/src/generators/workspace-rule/__snapshots__/workspace-rule.spec.ts.snap b/packages/eslint/src/generators/workspace-rule/__snapshots__/workspace-rule.spec.ts.snap index da178f1e17..0b542e8437 100644 --- a/packages/eslint/src/generators/workspace-rule/__snapshots__/workspace-rule.spec.ts.snap +++ b/packages/eslint/src/generators/workspace-rule/__snapshots__/workspace-rule.spec.ts.snap @@ -28,7 +28,7 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ type: 'problem', docs: { description: \`\`, - recommended: 'error', + recommended: 'recommended', }, schema: [], messages: {}, @@ -84,7 +84,7 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ type: 'problem', docs: { description: \`\`, - recommended: 'error', + recommended: 'recommended', }, schema: [], messages: {}, @@ -140,7 +140,7 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ type: 'problem', docs: { description: \`\`, - recommended: 'error', + recommended: 'recommended', }, schema: [], messages: {}, diff --git a/packages/eslint/src/generators/workspace-rule/files/__name__.ts__tmpl__ b/packages/eslint/src/generators/workspace-rule/files/__name__.ts__tmpl__ index b20a24f002..5cd2ecf7c6 100644 --- a/packages/eslint/src/generators/workspace-rule/files/__name__.ts__tmpl__ +++ b/packages/eslint/src/generators/workspace-rule/files/__name__.ts__tmpl__ @@ -25,7 +25,7 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ type: 'problem', docs: { description: ``, - recommended: 'error', + recommended: 'recommended', }, schema: [], messages: {}, diff --git a/packages/eslint/src/generators/workspace-rule/workspace-rule.spec.ts b/packages/eslint/src/generators/workspace-rule/workspace-rule.spec.ts index 110ba3783c..1c9468d7ee 100644 --- a/packages/eslint/src/generators/workspace-rule/workspace-rule.spec.ts +++ b/packages/eslint/src/generators/workspace-rule/workspace-rule.spec.ts @@ -1,4 +1,4 @@ -import { NxJsonConfiguration, readJson, Tree } from '@nx/devkit'; +import { Tree } from '@nx/devkit'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { lintWorkspaceRuleGenerator } from './workspace-rule'; 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 d391e2f6ee..d59b9e9875 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 @@ -35,6 +35,7 @@ exports[`@nx/eslint:workspace-rules-project should generate the required files 2 "{ "extends": "../../tsconfig.base.json", "compilerOptions": { + "moduleResolution": "node16", "module": "commonjs" }, "files": [], @@ -87,9 +88,6 @@ export default { }, moduleFileExtensions: ['ts', 'js', 'html'], coverageDirectory: '../../coverage/tools/eslint-rules', - moduleNameMapper: { - '@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs', - }, }; " `; 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 709828769d..b316654a5a 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__ @@ -1,6 +1,7 @@ { "extends": "<%= rootTsConfigPath %>", "compilerOptions": { + "moduleResolution": "node16", "module": "commonjs" }, "files": [], 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 bcb39dbaea..ba2df7530e 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 @@ -1,12 +1,14 @@ import { + addDependenciesToPackageJson, addProjectConfiguration, ensurePackage, formatFiles, generateFiles, - joinPathFragments, + GeneratorCallback, offsetFromRoot, readNxJson, readProjectConfiguration, + runTasksInSerial, Tree, updateJson, updateNxJson, @@ -14,7 +16,7 @@ import { import { getRelativePathToRootTsConfig } from '@nx/js'; import { addSwcRegisterDependencies } from '@nx/js/src/utils/swc/add-swc-dependencies'; import { join } from 'path'; -import { nxVersion } from '../../utils/versions'; +import { nxVersion, typescriptESLintVersion } from '../../utils/versions'; import { workspaceLintPluginDir } from '../../utils/workspace-lint-rules'; export const WORKSPACE_RULES_PROJECT_NAME = 'eslint-rules'; @@ -29,9 +31,11 @@ export async function lintWorkspaceRulesProjectGenerator( tree: Tree, options: LintWorkspaceRulesProjectGeneratorOptions = {} ) { - const { addPropertyToJestConfig, configurationGenerator } = ensurePackage< - typeof import('@nx/jest') - >('@nx/jest', nxVersion); + const { configurationGenerator } = ensurePackage( + '@nx/jest', + nxVersion + ); + const tasks: GeneratorCallback[] = []; // Noop if the workspace rules project already exists try { @@ -68,14 +72,16 @@ export async function lintWorkspaceRulesProjectGenerator( } // Add jest to the project and return installation task - const installTask = await configurationGenerator(tree, { - project: WORKSPACE_RULES_PROJECT_NAME, - supportTsx: false, - skipSerializers: true, - setupFile: 'none', - compiler: 'tsc', - skipFormat: true, - }); + tasks.push( + await configurationGenerator(tree, { + project: WORKSPACE_RULES_PROJECT_NAME, + supportTsx: false, + skipSerializers: true, + setupFile: 'none', + compiler: 'tsc', + skipFormat: true, + }) + ); updateJson( tree, @@ -102,21 +108,21 @@ export async function lintWorkspaceRulesProjectGenerator( ); // Add swc dependencies - addSwcRegisterDependencies(tree); + tasks.push(addSwcRegisterDependencies(tree)); - // Add extra config to the jest.config.ts file to allow ESLint 8 exports mapping to work with jest - addPropertyToJestConfig( - tree, - joinPathFragments(WORKSPACE_PLUGIN_DIR, 'jest.config.ts'), - 'moduleNameMapper', - { - '@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs', - } + tasks.push( + addDependenciesToPackageJson( + tree, + {}, + { + '@typescript-eslint/utils': typescriptESLintVersion, + } + ) ); if (!options.skipFormat) { await formatFiles(tree); } - return installTask; + return runTasksInSerial(...tasks); } 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 new file mode 100644 index 0000000000..88550a1027 --- /dev/null +++ b/packages/eslint/src/migrations/update-17-1-0/__snapshots__/update-typescript-eslint.spec.ts.snap @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`update-typescript-eslint migration should update the jest.config.ts 1`] = ` +"/* eslint-disable */ +export default { + displayName: 'eslint-rules', + preset: '../../jest.preset.js', + transform: { + '^.+\\\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/tools/eslint-rules', + moduleNameMapper: {}, +}; +" +`; + +exports[`update-typescript-eslint migration should update the rules 1`] = ` +"/** + * This file sets you up with structure needed for an ESLint rule. + * + * It leverages utilities from @typescript-eslint to allow TypeScript to + * provide autocompletions etc for the configuration. + * + * Your rule's custom logic will live within the create() method below + * and you can learn more about writing ESLint rules on the official guide: + * + * https://eslint.org/docs/developer-guide/working-with-rules + * + * You can also view many examples of existing rules here: + * + * https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/rules + */ + +import { ESLintUtils } from '@typescript-eslint/utils'; + +// NOTE: The rule will be available in ESLint configs as "@nx/workspace/lint-rule" +export const RULE_NAME = 'lint-rule'; + +export const rule = ESLintUtils.RuleCreator(() => __filename)({ + name: RULE_NAME, + meta: { + type: 'problem', + docs: { + description: \`\`, + recommended: 'recommended', + }, + schema: [], + messages: {}, + }, + defaultOptions: [], + create(context) { + return {}; + }, +}); +" +`; + +exports[`update-typescript-eslint migration should update the tsconfig.json 1`] = ` +"{ + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node16" + } +} +" +`; 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 new file mode 100644 index 0000000000..03e084110e --- /dev/null +++ b/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.spec.ts @@ -0,0 +1,102 @@ +import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; +import { Tree, writeJson } from '@nx/devkit'; + +import update from './update-typescript-eslint'; + +describe('update-typescript-eslint migration', () => { + let tree: Tree; + + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + + writeJson(tree, 'tools/eslint-rules/tsconfig.json', { + compilerOptions: { + module: 'commonjs', + }, + }); + + tree.write( + 'tools/eslint-rules/jest.config.ts', + `/* eslint-disable */ +export default { + displayName: 'eslint-rules', + preset: '../../jest.preset.js', + transform: { + '^.+\\\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/tools/eslint-rules', + moduleNameMapper: { + '@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs', + }, +}; +` + ); + + tree.write( + 'tools/eslint-rules/rules/rule.ts', + `/** + * This file sets you up with structure needed for an ESLint rule. + * + * It leverages utilities from @typescript-eslint to allow TypeScript to + * provide autocompletions etc for the configuration. + * + * Your rule's custom logic will live within the create() method below + * and you can learn more about writing ESLint rules on the official guide: + * + * https://eslint.org/docs/developer-guide/working-with-rules + * + * You can also view many examples of existing rules here: + * + * https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/rules + */ + +import { ESLintUtils } from '@typescript-eslint/utils'; + +// NOTE: The rule will be available in ESLint configs as "@nx/workspace/lint-rule" +export const RULE_NAME = 'lint-rule'; + +export const rule = ESLintUtils.RuleCreator(() => __filename)({ + name: RULE_NAME, + meta: { + type: 'problem', + docs: { + description: \`\`, + recommended: 'error', + }, + schema: [], + messages: {}, + }, + defaultOptions: [], + create(context) { + return {}; + }, +}); +` + ); + }); + + it('should update the tsconfig.json', async () => { + await update(tree); + + expect( + tree.read('tools/eslint-rules/tsconfig.json', 'utf-8') + ).toMatchSnapshot(); + }); + + it('should update the jest.config.ts', async () => { + await update(tree); + + expect( + tree.read('tools/eslint-rules/jest.config.ts', 'utf-8') + ).toMatchSnapshot(); + }); + + it('should update the rules', async () => { + await update(tree); + + expect( + tree.read('tools/eslint-rules/rules/rule.ts', 'utf-8') + ).toMatchSnapshot(); + }); +}); 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 new file mode 100644 index 0000000000..4a90cb4db9 --- /dev/null +++ b/packages/eslint/src/migrations/update-17-1-0/update-typescript-eslint.ts @@ -0,0 +1,98 @@ +import { + applyChangesToString, + ChangeType, + ensurePackage, + formatFiles, + StringChange, + Tree, + updateJson, + visitNotIgnoredFiles, +} from '@nx/devkit'; +import { nxVersion } from '../../utils/versions'; +import { extname } from 'path'; +import { + createSourceFile, + forEachChild, + isIdentifier, + isPropertyAssignment, + isStringLiteral, + type Node, + ScriptTarget, +} from 'typescript'; + +function updateJestConfig(tree: Tree) { + const jestConfigPath = 'tools/eslint-rules/jest.config.ts'; + if (tree.exists(jestConfigPath)) { + const { removePropertyFromJestConfig } = ensurePackage< + typeof import('@nx/jest') + >('@nx/jest', nxVersion); + + removePropertyFromJestConfig(tree, jestConfigPath, [ + 'moduleNameMapper', + '@eslint/eslintrc', + ]); + } +} + +function updateTsConfig(tree: Tree) { + const tsConfigPath = 'tools/eslint-rules/tsconfig.json'; + if (tree.exists(tsConfigPath)) { + updateJson(tree, tsConfigPath, (tsConfig) => { + tsConfig.compilerOptions ??= {}; + tsConfig.compilerOptions.moduleResolution = 'node16'; + return tsConfig; + }); + } +} + +function updateRecommended(tree: Tree) { + visitNotIgnoredFiles(tree, 'tools/eslint-rules', (path) => { + if (extname(path) !== '.ts') { + return; + } + + const contents = tree.read(path, 'utf-8'); + const sourceFile = createSourceFile( + path, + contents, + ScriptTarget.ESNext, + true + ); + + const changes: StringChange[] = []; + + const visit = (node: Node) => { + if ( + isPropertyAssignment(node) && + isIdentifier(node.name) && + node.name.text === 'recommended' && + isStringLiteral(node.initializer) + ) { + changes.push({ + type: ChangeType.Delete, + start: node.initializer.getStart(sourceFile), + length: node.initializer.getWidth(sourceFile), + }); + changes.push({ + type: ChangeType.Insert, + index: node.initializer.getStart(sourceFile), + text: "'recommended'", + }); + } else { + forEachChild(node, visit); + } + }; + + forEachChild(sourceFile, visit); + + tree.write(path, applyChangesToString(contents, changes)); + }); +} + +export default async function update(tree: Tree) { + updateJestConfig(tree); + updateTsConfig(tree); + updateRecommended(tree); + + await formatFiles(tree); +} diff --git a/packages/eslint/src/utils/versions.ts b/packages/eslint/src/utils/versions.ts index f7248ec13c..e646a4ade1 100644 --- a/packages/eslint/src/utils/versions.ts +++ b/packages/eslint/src/utils/versions.ts @@ -3,4 +3,4 @@ export const nxVersion = require('../../package.json').version; export const eslintVersion = '~8.46.0'; export const eslintrcVersion = '^2.1.1'; export const eslintConfigPrettierVersion = '^9.0.0'; -export const typescriptESLintVersion = '^5.60.1'; +export const typescriptESLintVersion = '^6.9.1'; diff --git a/packages/node/src/generators/application/files/fastify/src/app/app.ts__tmpl__ b/packages/node/src/generators/application/files/fastify/src/app/app.ts__tmpl__ index 6c7d1a8640..1645bc1d93 100644 --- a/packages/node/src/generators/application/files/fastify/src/app/app.ts__tmpl__ +++ b/packages/node/src/generators/application/files/fastify/src/app/app.ts__tmpl__ @@ -1,5 +1,5 @@ import * as path from 'path'; -import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; +import { FastifyInstance } from 'fastify'; import AutoLoad from '@fastify/autoload'; /* eslint-disable-next-line */ diff --git a/packages/node/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ b/packages/node/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ index ef7dfe0391..54badc2826 100644 --- a/packages/node/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ +++ b/packages/node/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ @@ -1,4 +1,4 @@ -import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; +import { FastifyInstance } from 'fastify'; import fp from 'fastify-plugin'; import sensible from '@fastify/sensible'; diff --git a/packages/node/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ b/packages/node/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ index 3b765e0794..e9edd35ce4 100644 --- a/packages/node/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ +++ b/packages/node/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ @@ -1,7 +1,7 @@ -import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; +import { FastifyInstance } from 'fastify'; export default async function(fastify: FastifyInstance) { - fastify.get('/', async function(request: FastifyRequest, reply: FastifyReply) { + fastify.get('/', async function() { return { message: 'Hello API' }; }); } diff --git a/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap index c2e7dd1482..9a922ce58e 100644 --- a/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap @@ -22,7 +22,7 @@ if (import.meta.vitest) { // For more information please visit the Vitest docs site here: https://vitest.dev/guide/in-source.html const { it, expect, beforeEach } = import.meta.vitest; - let render: any; + let render: typeof import('@testing-library/react').render; beforeEach(async () => { render = (await import('@testing-library/react')).render; diff --git a/packages/react/src/utils/get-in-source-vitest-tests-template.ts b/packages/react/src/utils/get-in-source-vitest-tests-template.ts index 4160c0a063..7ddba1bc1f 100644 --- a/packages/react/src/utils/get-in-source-vitest-tests-template.ts +++ b/packages/react/src/utils/get-in-source-vitest-tests-template.ts @@ -5,7 +5,7 @@ if (import.meta.vitest) { // For more information please visit the Vitest docs site here: https://vitest.dev/guide/in-source.html const { it, expect, beforeEach } = import.meta.vitest; - let render: any; + let render: typeof import('@testing-library/react').render; beforeEach(async () => { render = (await import('@testing-library/react')).render; diff --git a/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap b/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap index 10935e3927..49f6416716 100644 --- a/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap +++ b/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap @@ -46,8 +46,8 @@ exports[`lib should add correct jest.config.ts and dependencies to package.json "@swc/core": "~1.3.85", "@types/jest": "^29.4.0", "@types/node": "16.11.7", - "@typescript-eslint/eslint-plugin": "^5.60.1", - "@typescript-eslint/parser": "^5.60.1", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", "@vitejs/plugin-vue": "^4.3.1", "@vue/eslint-config-prettier": "7.1.0", "@vue/eslint-config-typescript": "^11.0.3", @@ -243,8 +243,8 @@ exports[`lib should add vue, vite and vitest to package.json 1`] = ` "@nx/vue": "0.0.1", "@swc-node/register": "~1.6.7", "@swc/core": "~1.3.85", - "@typescript-eslint/eslint-plugin": "^5.60.1", - "@typescript-eslint/parser": "^5.60.1", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", "@vitejs/plugin-vue": "^4.3.1", "@vitest/coverage-c8": "~0.32.0", "@vitest/ui": "~0.32.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd1f05ace0..2fd2f24e59 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -292,7 +292,7 @@ devDependencies: version: 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(eslint@8.46.0)(nx@17.0.0-rc.2)(verdaccio@5.15.4) '@nx/eslint-plugin': specifier: 17.0.0-rc.2 - version: 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@5.62.0)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) + version: 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@6.9.1)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) '@nx/jest': specifier: 17.0.0-rc.2 version: 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(nx@17.0.0-rc.2)(ts-node@10.9.1)(typescript@5.1.3)(verdaccio@5.15.4) @@ -468,17 +468,17 @@ devDependencies: specifier: ^1.1.5 version: 1.1.5 '@typescript-eslint/eslint-plugin': - specifier: 5.62.0 - version: 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.3) + specifier: ^6.9.1 + version: 6.9.1(@typescript-eslint/parser@6.9.1)(eslint@8.46.0)(typescript@5.1.3) '@typescript-eslint/parser': - specifier: 5.62.0 - version: 5.62.0(eslint@8.46.0)(typescript@5.1.3) + specifier: ^6.9.1 + version: 6.9.1(eslint@8.46.0)(typescript@5.1.3) '@typescript-eslint/type-utils': - specifier: 5.60.1 - version: 5.60.1(eslint@8.46.0)(typescript@5.1.3) + specifier: ^6.9.1 + version: 6.9.1(eslint@8.46.0)(typescript@5.1.3) '@typescript-eslint/utils': - specifier: 5.62.0 - version: 5.62.0(eslint@8.46.0)(typescript@5.1.3) + specifier: ^6.9.1 + version: 6.9.1(eslint@8.46.0)(typescript@5.1.3) '@xstate/immer': specifier: 0.3.1 version: 0.3.1(immer@9.0.16)(xstate@4.34.0) @@ -589,7 +589,7 @@ devDependencies: version: 2.14.0(eslint@8.46.0) eslint-plugin-import: specifier: 2.26.0 - version: 2.26.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.2)(eslint@8.46.0) + version: 2.26.0(@typescript-eslint/parser@6.9.1)(eslint@8.46.0) eslint-plugin-jsx-a11y: specifier: 6.6.1 version: 6.6.1(eslint@8.46.0) @@ -4447,12 +4447,7 @@ packages: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: eslint: 8.46.0 - eslint-visitor-keys: 3.3.0 - dev: true - - /@eslint-community/regexpp@4.5.0: - resolution: {integrity: sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==} - engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + eslint-visitor-keys: 3.4.3 dev: true /@eslint-community/regexpp@4.6.2: @@ -5662,7 +5657,7 @@ packages: dependencies: '@phenomnomnominal/tsquery': 4.1.1(typescript@5.1.3) ejs: 3.1.8 - ignore: 5.2.0 + ignore: 5.2.4 nx: 15.8.0(@swc-node/register@1.6.8)(@swc/core@1.3.86) semver: 7.3.4 tmp: 0.2.1 @@ -5678,7 +5673,7 @@ packages: dependencies: '@phenomnomnominal/tsquery': 4.1.1(typescript@5.1.3) ejs: 3.1.8 - ignore: 5.2.0 + ignore: 5.2.4 nx: 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86) semver: 7.3.4 tmp: 0.2.1 @@ -5713,10 +5708,10 @@ packages: - verdaccio dev: true - /@nrwl/eslint-plugin-nx@17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@5.62.0)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4): + /@nrwl/eslint-plugin-nx@17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@6.9.1)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4): resolution: {integrity: sha512-qASP7I8CEuJWe0vJP7xde6uI/1kKIWOSsSnFcjlPSbwI+LxXBSSDRoGMm2MU/f2mt0qkxZX8WSNRBpxsbNbG+A==} dependencies: - '@nx/eslint-plugin': 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@5.62.0)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) + '@nx/eslint-plugin': 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@6.9.1)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) transitivePeerDependencies: - '@babel/traverse' - '@swc-node/register' @@ -5771,7 +5766,7 @@ packages: chalk: 4.1.2 fast-glob: 3.2.7 fs-extra: 11.1.1 - ignore: 5.2.0 + ignore: 5.2.4 js-tokens: 4.0.0 minimatch: 3.0.5 source-map-support: 0.5.19 @@ -5808,7 +5803,7 @@ packages: chalk: 4.1.2 fast-glob: 3.2.7 fs-extra: 11.1.1 - ignore: 5.2.0 + ignore: 5.2.4 js-tokens: 4.0.0 minimatch: 3.0.5 source-map-support: 0.5.19 @@ -6225,7 +6220,7 @@ packages: '@nx/workspace': 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86) '@phenomnomnominal/tsquery': 5.0.1(typescript@5.1.3) '@schematics/angular': 16.2.0 - '@typescript-eslint/type-utils': 5.60.1(eslint@8.46.0)(typescript@5.1.3) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.3) chalk: 4.1.2 enquirer: 2.3.6 esbuild: 0.19.5 @@ -6345,7 +6340,7 @@ packages: - verdaccio dev: true - /@nx/eslint-plugin@17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@5.62.0)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4): + /@nx/eslint-plugin@17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@6.9.1)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4): resolution: {integrity: sha512-FJvgyzbZguURGQREGPG+3nWhZTjCKKxCPw6uVONSusWsZ3JypQ9QsY0u8I8p4eybIWNkl2/zQbMfh30mv+JZWQ==} peerDependencies: '@typescript-eslint/parser': ^5.60.1 @@ -6354,11 +6349,11 @@ packages: eslint-config-prettier: optional: true dependencies: - '@nrwl/eslint-plugin-nx': 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@5.62.0)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) + '@nrwl/eslint-plugin-nx': 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(@typescript-eslint/parser@6.9.1)(eslint-config-prettier@9.0.0)(eslint@8.46.0)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) '@nx/devkit': 17.0.0-rc.2(nx@17.0.0-rc.2) '@nx/js': 17.0.0-rc.2(@swc-node/register@1.6.8)(@swc/core@1.3.86)(@types/node@18.16.9)(nx@17.0.0-rc.2)(typescript@5.1.3)(verdaccio@5.15.4) - '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.3) - '@typescript-eslint/type-utils': 5.60.1(eslint@8.46.0)(typescript@5.1.3) + '@typescript-eslint/parser': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.3) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.3) chalk: 4.1.2 confusing-browser-globals: 1.0.11 @@ -10159,29 +10154,30 @@ packages: dev: true optional: true - /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.3): - resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/eslint-plugin@6.9.1(@typescript-eslint/parser@6.9.1)(eslint@8.46.0)(typescript@5.1.3): + resolution: {integrity: sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==} + engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: - '@typescript-eslint/parser': ^5.0.0 - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.5.0 - '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.3) - '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.3) - '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.3) + '@eslint-community/regexpp': 4.6.2 + '@typescript-eslint/parser': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + '@typescript-eslint/scope-manager': 6.9.1 + '@typescript-eslint/type-utils': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + '@typescript-eslint/utils': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + '@typescript-eslint/visitor-keys': 6.9.1 debug: 4.3.4(supports-color@5.5.0) eslint: 8.46.0 graphemer: 1.4.0 - ignore: 5.2.0 - natural-compare-lite: 1.4.0 - semver: 7.5.3 - tsutils: 3.21.0(typescript@5.1.3) + ignore: 5.2.4 + natural-compare: 1.4.0 + semver: 7.5.4 + ts-api-utils: 1.0.3(typescript@5.1.3) typescript: 5.1.3 transitivePeerDependencies: - supports-color @@ -10207,6 +10203,27 @@ packages: - supports-color dev: true + /@typescript-eslint/parser@6.9.1(eslint@8.46.0)(typescript@5.1.3): + resolution: {integrity: sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/scope-manager': 6.9.1 + '@typescript-eslint/types': 6.9.1 + '@typescript-eslint/typescript-estree': 6.9.1(typescript@5.1.3) + '@typescript-eslint/visitor-keys': 6.9.1 + debug: 4.3.4(supports-color@5.5.0) + eslint: 8.46.0 + typescript: 5.1.3 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/scope-manager@5.59.2: resolution: {integrity: sha512-dB1v7ROySwQWKqQ8rEWcdbTsFjh2G0vn8KUyvTXdPoyzSL6lLGkiXEV5CvpJsEe9xIdKV+8Zqb7wif2issoOFA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10215,14 +10232,6 @@ packages: '@typescript-eslint/visitor-keys': 5.59.2 dev: true - /@typescript-eslint/scope-manager@5.60.1: - resolution: {integrity: sha512-Dn/LnN7fEoRD+KspEOV0xDMynEmR3iSHdgNsarlXNLGGtcUok8L4N71dxUgt3YvlO8si7E+BJ5Fe3wb5yUw7DQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - '@typescript-eslint/types': 5.60.1 - '@typescript-eslint/visitor-keys': 5.60.1 - dev: true - /@typescript-eslint/scope-manager@5.62.0: resolution: {integrity: sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10231,6 +10240,14 @@ packages: '@typescript-eslint/visitor-keys': 5.62.0 dev: true + /@typescript-eslint/scope-manager@6.9.1: + resolution: {integrity: sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==} + engines: {node: ^16.0.0 || >=18.0.0} + dependencies: + '@typescript-eslint/types': 6.9.1 + '@typescript-eslint/visitor-keys': 6.9.1 + dev: true + /@typescript-eslint/type-utils@5.59.2(eslint@8.46.0)(typescript@5.1.3): resolution: {integrity: sha512-b1LS2phBOsEy/T381bxkkywfQXkV1dWda/z0PhnIy3bC5+rQWQDS7fk9CSpcXBccPY27Z6vBEuaPBCKCgYezyQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10251,26 +10268,6 @@ packages: - supports-color dev: true - /@typescript-eslint/type-utils@5.60.1(eslint@8.46.0)(typescript@5.1.3): - resolution: {integrity: sha512-vN6UztYqIu05nu7JqwQGzQKUJctzs3/Hg7E2Yx8rz9J+4LgtIDFWjjl1gm3pycH0P3mHAcEUBd23LVgfrsTR8A==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: '*' - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/typescript-estree': 5.60.1(typescript@5.1.3) - '@typescript-eslint/utils': 5.60.1(eslint@8.46.0)(typescript@5.1.3) - debug: 4.3.4(supports-color@5.5.0) - eslint: 8.46.0 - tsutils: 3.21.0(typescript@5.1.3) - typescript: 5.1.3 - transitivePeerDependencies: - - supports-color - dev: true - /@typescript-eslint/type-utils@5.62.0(eslint@8.46.0)(typescript@5.1.3): resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10291,13 +10288,28 @@ packages: - supports-color dev: true - /@typescript-eslint/types@5.59.2: - resolution: {integrity: sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /@typescript-eslint/type-utils@6.9.1(eslint@8.46.0)(typescript@5.1.3): + resolution: {integrity: sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/typescript-estree': 6.9.1(typescript@5.1.3) + '@typescript-eslint/utils': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + debug: 4.3.4(supports-color@5.5.0) + eslint: 8.46.0 + ts-api-utils: 1.0.3(typescript@5.1.3) + typescript: 5.1.3 + transitivePeerDependencies: + - supports-color dev: true - /@typescript-eslint/types@5.60.1: - resolution: {integrity: sha512-zDcDx5fccU8BA0IDZc71bAtYIcG9PowaOwaD8rjYbqwK7dpe/UMQl3inJ4UtUK42nOCT41jTSCwg76E62JpMcg==} + /@typescript-eslint/types@5.59.2: + resolution: {integrity: sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -10306,6 +10318,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@typescript-eslint/types@6.9.1: + resolution: {integrity: sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==} + engines: {node: ^16.0.0 || >=18.0.0} + dev: true + /@typescript-eslint/typescript-estree@5.59.2(typescript@5.1.3): resolution: {integrity: sha512-+j4SmbwVmZsQ9jEyBMgpuBD0rKwi9RxRpjX71Brr73RsYnEr3Lt5QZ624Bxphp8HUkSKfqGnPJp1kA5nl0Sh7Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10327,27 +10344,6 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree@5.60.1(typescript@5.1.3): - resolution: {integrity: sha512-hkX70J9+2M2ZT6fhti5Q2FoU9zb+GeZK2SLP1WZlvUDqdMbEKhexZODD1WodNRyO8eS+4nScvT0dts8IdaBzfw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/types': 5.60.1 - '@typescript-eslint/visitor-keys': 5.60.1 - debug: 4.3.4(supports-color@5.5.0) - globby: 11.1.0 - is-glob: 4.0.3 - semver: 7.5.3 - tsutils: 3.21.0(typescript@5.1.3) - typescript: 5.1.3 - transitivePeerDependencies: - - supports-color - dev: true - /@typescript-eslint/typescript-estree@5.62.0(typescript@5.1.3): resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10369,6 +10365,27 @@ packages: - supports-color dev: true + /@typescript-eslint/typescript-estree@6.9.1(typescript@5.1.3): + resolution: {integrity: sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 6.9.1 + '@typescript-eslint/visitor-keys': 6.9.1 + debug: 4.3.4(supports-color@5.5.0) + globby: 11.1.0 + is-glob: 4.0.3 + semver: 7.5.4 + ts-api-utils: 1.0.3(typescript@5.1.3) + typescript: 5.1.3 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/utils@5.59.2(eslint@8.46.0)(typescript@5.1.3): resolution: {integrity: sha512-kSuF6/77TZzyGPhGO4uVp+f0SBoYxCDf+lW3GKhtKru/L8k/Hd7NFQxyWUeY7Z/KGB2C6Fe3yf2vVi4V9TsCSQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10389,26 +10406,6 @@ packages: - typescript dev: true - /@typescript-eslint/utils@5.60.1(eslint@8.46.0)(typescript@5.1.3): - resolution: {integrity: sha512-tiJ7FFdFQOWssFa3gqb94Ilexyw0JVxj6vBzaSpfN/8IhoKkDuSAenUKvsSHw2A/TMpJb26izIszTXaqygkvpQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) - '@types/json-schema': 7.0.12 - '@types/semver': 7.5.2 - '@typescript-eslint/scope-manager': 5.60.1 - '@typescript-eslint/types': 5.60.1 - '@typescript-eslint/typescript-estree': 5.60.1(typescript@5.1.3) - eslint: 8.46.0 - eslint-scope: 5.1.1 - semver: 7.5.3 - transitivePeerDependencies: - - supports-color - - typescript - dev: true - /@typescript-eslint/utils@5.62.0(eslint@8.46.0)(typescript@5.1.3): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -10429,20 +10426,31 @@ packages: - typescript dev: true + /@typescript-eslint/utils@6.9.1(eslint@8.46.0)(typescript@5.1.3): + resolution: {integrity: sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) + '@types/json-schema': 7.0.12 + '@types/semver': 7.5.2 + '@typescript-eslint/scope-manager': 6.9.1 + '@typescript-eslint/types': 6.9.1 + '@typescript-eslint/typescript-estree': 6.9.1(typescript@5.1.3) + eslint: 8.46.0 + semver: 7.5.4 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/visitor-keys@5.59.2: resolution: {integrity: sha512-EEpsO8m3RASrKAHI9jpavNv9NlEUebV4qmF1OWxSTtKSFBpC1NCmWazDQHFivRf0O1DV11BA645yrLEVQ0/Lig==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: '@typescript-eslint/types': 5.59.2 - eslint-visitor-keys: 3.3.0 - dev: true - - /@typescript-eslint/visitor-keys@5.60.1: - resolution: {integrity: sha512-xEYIxKcultP6E/RMKqube11pGjXH1DCo60mQoWhVYyKfLkwbIVVjYxmOenNMxILx0TjCujPTjjnTIVzm09TXIw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - '@typescript-eslint/types': 5.60.1 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /@typescript-eslint/visitor-keys@5.62.0: @@ -10450,7 +10458,15 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: '@typescript-eslint/types': 5.62.0 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 + dev: true + + /@typescript-eslint/visitor-keys@6.9.1: + resolution: {integrity: sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==} + engines: {node: ^16.0.0 || >=18.0.0} + dependencies: + '@typescript-eslint/types': 6.9.1 + eslint-visitor-keys: 3.4.3 dev: true /@verdaccio/commons-api@10.2.0: @@ -15039,6 +15055,35 @@ packages: - supports-color dev: true + /eslint-module-utils@2.7.4(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.6)(eslint@8.46.0): + resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + eslint: + optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true + dependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + debug: 3.2.7(supports-color@8.1.1) + eslint: 8.46.0 + eslint-import-resolver-node: 0.3.6 + transitivePeerDependencies: + - supports-color + dev: true + /eslint-plugin-cypress@2.14.0(eslint@8.46.0): resolution: {integrity: sha512-eW6tv7iIg7xujleAJX4Ujm649Bf5jweqa4ObPEIuueYRyLZt7qXGWhCY/n4bfeFW/j6nQZwbIBHKZt6EKcL/cg==} peerDependencies: @@ -15079,6 +15124,37 @@ packages: - supports-color dev: true + /eslint-plugin-import@2.26.0(@typescript-eslint/parser@6.9.1)(eslint@8.46.0): + resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + dependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.46.0)(typescript@5.1.3) + array-includes: 3.1.6 + array.prototype.flat: 1.3.1 + debug: 2.6.9 + doctrine: 2.1.0 + eslint: 8.46.0 + eslint-import-resolver-node: 0.3.6 + eslint-module-utils: 2.7.4(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.6)(eslint@8.46.0) + has: 1.0.3 + is-core-module: 2.11.0 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.values: 1.1.6 + resolve: 1.22.1 + tsconfig-paths: 3.14.1 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + dev: true + /eslint-plugin-jsx-a11y@6.6.1(eslint@8.46.0): resolution: {integrity: sha512-sXgFVNHiWffBq23uiS/JaP6eVR622DqwB4yTzKvGZGcPq6/yZ3WmOZfuBks/vHWo9GaFOqC2ZK4i6+C35knx7Q==} engines: {node: '>=4.0'} @@ -15248,7 +15324,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /espree@9.6.1: @@ -16477,7 +16553,7 @@ packages: array-union: 2.1.0 dir-glob: 3.0.1 fast-glob: 3.3.1 - ignore: 5.2.0 + ignore: 5.2.4 merge2: 1.4.1 slash: 3.0.0 dev: true @@ -20262,10 +20338,6 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - /natural-compare-lite@1.4.0: - resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} - dev: true - /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true @@ -25836,6 +25908,15 @@ packages: resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==} dev: true + /ts-api-utils@1.0.3(typescript@5.1.3): + resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} + engines: {node: '>=16.13.0'} + peerDependencies: + typescript: '>=4.2.0' + dependencies: + typescript: 5.1.3 + dev: true + /ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} engines: {node: '>=6.10'} diff --git a/tools/eslint-rules/jest.config.ts b/tools/eslint-rules/jest.config.ts index d98d764a4b..a99e5a1c6e 100644 --- a/tools/eslint-rules/jest.config.ts +++ b/tools/eslint-rules/jest.config.ts @@ -12,9 +12,6 @@ export default { ], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/tools/eslint-rules', - moduleNameMapper: { - '@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs', - }, + testEnvironment: 'node', preset: '../../jest.preset.js', }; diff --git a/tools/eslint-rules/rules/valid-schema-description.ts b/tools/eslint-rules/rules/valid-schema-description.ts index ea02827577..74de032e78 100644 --- a/tools/eslint-rules/rules/valid-schema-description.ts +++ b/tools/eslint-rules/rules/valid-schema-description.ts @@ -10,7 +10,7 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ type: 'problem', docs: { description: `Ensures that nx schemas contain valid descriptions in order to provide consistent --help output for commands`, - recommended: 'error', + recommended: 'recommended', }, fixable: 'code', schema: [], diff --git a/tools/eslint-rules/tsconfig.json b/tools/eslint-rules/tsconfig.json index 51165861a7..6db9d51433 100644 --- a/tools/eslint-rules/tsconfig.json +++ b/tools/eslint-rules/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "moduleResolution": "node16", "module": "commonjs" }, "files": [],