diff --git a/docs/generated/packages/eslint/executors/lint.json b/docs/generated/packages/eslint/executors/lint.json index 4a308613d4..5dcc10ad9b 100644 --- a/docs/generated/packages/eslint/executors/lint.json +++ b/docs/generated/packages/eslint/executors/lint.json @@ -20,7 +20,7 @@ "lintFilePatterns": { "type": "array", "description": "One or more files/dirs/globs to pass directly to ESLint's `lintFiles()` method.", - "default": [], + "default": ["{projectRoot}"], "items": { "type": "string" } }, "format": { @@ -140,7 +140,6 @@ "default": true } }, - "required": ["lintFilePatterns"], "examplesFile": "Linter can be configured in multiple ways. The basic way is to provide only `lintFilePatterns`, which is a mandatory property. This tells us where to look for files to lint.\n\n`project.json`:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"]\n }\n}\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Fixing linter issues\" %}\n\nLinter provides an automated way of fixing known issues. To ensure that those changes are properly cached, we need to add an `outputs` property to the `lint` target. Omitting the `outputs` property would produce an invalid cache record. Both of these properties are set by default when scaffolding a new project.\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"]\n }\n}\n```\n\nWith these settings, we can run the command with a `--fix` flag:\n\n```bash\nnx run frontend:lint --fix\n```\n\nWe can also set this flag via project configuration to always fix files when running lint:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"fix\": true\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Custom output format\" %}\n\nESLint executor uses the `stylish` output format by default. You can change this by specifying the `format` property:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"format\": \"compact\"\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Silence warnings\" %}\n\nMigrated or legacy projects tend to have an overwhelming amount of lint errors. We might want to change those temporarily to be warnings so they don't block the development. But they would still clutter the report. We can run the command with `--quiet` to hide warning (errors would still break the lint):\n\n```bash\nnx run frontend:lint --quiet\n```\n\nWe can also set this via project configuration as a default option.\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"quiet\": true\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Flat Config file\" %}\n\n`ESLint` provides several ways of specifying the configuration. The default one is using `.eslintrc.json` but you can override it by setting the `eslintConfig` flag. The new `Flat Config` is now also supported:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"eslintConfig\": \"eslint.config.js\"\n }\n}\n```\n\n**Note:** In contrast to other configuration formats, the `Flat Config` requires that all configuration files are converted to `eslint.config.js`. Built-in migrations and generators support only `.eslintrc.json` at the moment.\n\n{% /tab %}\n{% /tabs %}\n\n---\n", "presets": [] }, diff --git a/docs/shared/node-server-tutorial/affected-project-graph.json b/docs/shared/node-server-tutorial/affected-project-graph.json index ff386c023f..e419354106 100644 --- a/docs/shared/node-server-tutorial/affected-project-graph.json +++ b/docs/shared/node-server-tutorial/affected-project-graph.json @@ -76,7 +76,6 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["auth/**/*.ts"] }, "configurations": {} }, "test": { @@ -155,7 +154,6 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["e2e/**/*.{js,ts}"] }, "configurations": {} } } @@ -324,7 +322,7 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["./**/*.ts"] }, + "options": { "lintFilePatterns": ["./src"] }, "configurations": {} } } diff --git a/docs/shared/node-server-tutorial/final-project-graph.json b/docs/shared/node-server-tutorial/final-project-graph.json index 2ac5635fe1..97969525b7 100644 --- a/docs/shared/node-server-tutorial/final-project-graph.json +++ b/docs/shared/node-server-tutorial/final-project-graph.json @@ -58,7 +58,6 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["auth/**/*.ts"] }, "configurations": {} }, "test": { @@ -137,7 +136,6 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["e2e/**/*.{js,ts}"] }, "configurations": {} } } diff --git a/docs/shared/node-server-tutorial/initial-project-graph.json b/docs/shared/node-server-tutorial/initial-project-graph.json index b2df6ea1d4..0282c1fd24 100644 --- a/docs/shared/node-server-tutorial/initial-project-graph.json +++ b/docs/shared/node-server-tutorial/initial-project-graph.json @@ -58,7 +58,7 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["auth/**/*.ts"] }, + "configurations": {} }, "test": { @@ -137,7 +137,6 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["e2e/**/*.{js,ts}"] }, "configurations": {} } } @@ -305,7 +304,7 @@ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], - "options": { "lintFilePatterns": ["./**/*.ts"] }, + "options": { "lintFilePatterns": ["./src"] }, "configurations": {} } } diff --git a/e2e/angular-core/src/config.test.ts b/e2e/angular-core/src/config.test.ts index b64a5fa307..3d905253ec 100644 --- a/e2e/angular-core/src/config.test.ts +++ b/e2e/angular-core/src/config.test.ts @@ -120,13 +120,7 @@ const angularV1Json = (appName: string) => `{ } }, "lint": { - "builder": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "${appName}/src/**/*.ts", - "${appName}/src/**/*.html" - ] - } + "builder": "@nx/eslint:lint" }, "test": { "builder": "@nx/jest:jest", @@ -159,10 +153,7 @@ const angularV1Json = (appName: string) => `{ }, "lint": { "builder": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["${appName}-e2e/**/*.{js,ts}"] - } + "outputs": ["{options.outputFile}"] } }, "tags": [], diff --git a/e2e/angular-core/src/ng-add.test.ts b/e2e/angular-core/src/ng-add.test.ts index 5c65714750..30bc5ef938 100644 --- a/e2e/angular-core/src/ng-add.test.ts +++ b/e2e/angular-core/src/ng-add.test.ts @@ -407,12 +407,6 @@ describe('convert Angular CLI workspace to an Nx workspace', () => { const projectConfig = readJson(`apps/${project}/project.json`); expect(projectConfig.targets.lint).toStrictEqual({ executor: '@nx/eslint:lint', - options: { - lintFilePatterns: [ - `apps/${project}/src/**/*.ts`, - `apps/${project}/src/**/*.html`, - ], - }, }); let output = runCLI(`lint ${project}`); diff --git a/e2e/eslint/src/linter.test.ts b/e2e/eslint/src/linter.test.ts index 240a7120ee..6b506f2d32 100644 --- a/e2e/eslint/src/linter.test.ts +++ b/e2e/eslint/src/linter.test.ts @@ -465,14 +465,6 @@ describe('Linter', () => { ]; return json; }); - updateJson(`libs/${mylib}/project.json`, (json) => { - json.targets.lint.options.lintFilePatterns = [ - `libs/${mylib}/**/*.ts`, - `libs/${mylib}/project.json`, - `libs/${mylib}/package.json`, - ]; - return json; - }); }); it('should report dependency check issues', () => { diff --git a/e2e/nx-misc/src/workspace.test.ts b/e2e/nx-misc/src/workspace.test.ts index 28e4c654dd..6dfd14d21e 100644 --- a/e2e/nx-misc/src/workspace.test.ts +++ b/e2e/nx-misc/src/workspace.test.ts @@ -207,10 +207,6 @@ describe('Workspace Tests', () => { const project = readJson(join(newPath, 'project.json')); expect(project).toBeTruthy(); expect(project.sourceRoot).toBe(`${newPath}/src`); - expect(project.targets.lint.options.lintFilePatterns).toEqual([ - `shared/${lib1}/data-access/**/*.ts`, - `shared/${lib1}/data-access/package.json`, - ]); /** * Check that the import in lib2 has been updated @@ -343,11 +339,6 @@ describe('Workspace Tests', () => { const lib3Config = readJson(join(lib3, 'project.json')); expect(lib3Config.implicitDependencies).toEqual([newName]); - expect(project.targets.lint.options.lintFilePatterns).toEqual([ - `shared/${lib1}/data-access/**/*.ts`, - `shared/${lib1}/data-access/package.json`, - ]); - /** * Check that the import in lib2 has been updated */ @@ -479,10 +470,6 @@ describe('Workspace Tests', () => { const project = readJson(join(newPath, 'project.json')); expect(project).toBeTruthy(); expect(project.sourceRoot).toBe(`${newPath}/src`); - expect(project.targets.lint.options.lintFilePatterns).toEqual([ - `packages/shared/${lib1}/data-access/**/*.ts`, - `packages/shared/${lib1}/data-access/package.json`, - ]); expect(project.tags).toEqual([]); /** @@ -615,10 +602,6 @@ describe('Workspace Tests', () => { const project = readJson(join(newPath, 'project.json')); expect(project).toBeTruthy(); expect(project.sourceRoot).toBe(`${newPath}/src`); - expect(project.targets.lint.options.lintFilePatterns).toEqual([ - `${lib1}/data-access/**/*.ts`, - `${lib1}/data-access/package.json`, - ]); /** * Check that the import in lib2 has been updated @@ -736,10 +719,6 @@ describe('Workspace Tests', () => { const project = readJson(join(newPath, 'project.json')); expect(project).toBeTruthy(); expect(project.sourceRoot).toBe(`${newPath}/src`); - expect(project.targets.lint.options.lintFilePatterns).toEqual([ - `shared/${lib1}/data-access/**/*.ts`, - `shared/${lib1}/data-access/package.json`, - ]); /** * Check that the import in lib2 has been updated diff --git a/packages/angular/src/generators/add-linting/add-linting.spec.ts b/packages/angular/src/generators/add-linting/add-linting.spec.ts index 459e64c600..c1de78bdec 100644 --- a/packages/angular/src/generators/add-linting/add-linting.spec.ts +++ b/packages/angular/src/generators/add-linting/add-linting.spec.ts @@ -72,12 +72,6 @@ describe('addLinting generator', () => { const project = readProjectConfiguration(tree, appProjectName); expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', - options: { - lintFilePatterns: [ - `${appProjectRoot}/**/*.ts`, - `${appProjectRoot}/**/*.html`, - ], - }, outputs: ['{options.outputFile}'], }); }); diff --git a/packages/angular/src/generators/add-linting/add-linting.ts b/packages/angular/src/generators/add-linting/add-linting.ts index fc531abe75..c25cbad282 100755 --- a/packages/angular/src/generators/add-linting/add-linting.ts +++ b/packages/angular/src/generators/add-linting/add-linting.ts @@ -7,7 +7,6 @@ import { Tree, } from '@nx/devkit'; import { Linter, lintProjectGenerator } from '@nx/eslint'; -import { mapLintPattern } from '@nx/eslint/src/generators/lint-project/lint-project'; import { addAngularEsLintDependencies } from './lib/add-angular-eslint-dependencies'; import type { AddLintingGeneratorSchema } from './schema'; import { @@ -30,10 +29,6 @@ export async function addLintingGenerator( joinPathFragments(options.projectRoot, 'tsconfig.app.json'), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [ - mapLintPattern(options.projectRoot, 'ts', rootProject), - mapLintPattern(options.projectRoot, 'html', rootProject), - ], setParserOptionsProject: options.setParserOptionsProject, skipFormat: true, rootProject: rootProject, diff --git a/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap index f082cff7ab..36bd14637f 100644 --- a/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap @@ -267,12 +267,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "apps/my-dir/my-app/**/*.ts", - "apps/my-dir/my-app/**/*.html", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -339,11 +333,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "apps/my-dir/my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -503,12 +492,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "apps/my-app/**/*.ts", - "apps/my-app/**/*.html", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -575,11 +558,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "apps/my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -963,12 +941,6 @@ exports[`app nested should create project configs 1`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-dir/my-app/**/*.ts", - "my-dir/my-app/**/*.html", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -1035,11 +1007,6 @@ exports[`app nested should create project configs 2`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-dir/my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -1112,12 +1079,6 @@ exports[`app not nested should create project configs 1`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app/**/*.ts", - "my-app/**/*.html", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -1184,11 +1145,6 @@ exports[`app not nested should create project configs 2`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/angular/src/generators/application/application.spec.ts b/packages/angular/src/generators/application/application.spec.ts index 6093701302..f7f973d1a5 100644 --- a/packages/angular/src/generators/application/application.spec.ts +++ b/packages/angular/src/generators/application/application.spec.ts @@ -506,12 +506,6 @@ describe('app', () => { .toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app/**/*.ts", - "my-app/**/*.html", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -521,11 +515,6 @@ describe('app', () => { .toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/angular/src/generators/library-secondary-entry-point/lib/index.ts b/packages/angular/src/generators/library-secondary-entry-point/lib/index.ts index de417b325a..2bebc9ddaf 100644 --- a/packages/angular/src/generators/library-secondary-entry-point/lib/index.ts +++ b/packages/angular/src/generators/library-secondary-entry-point/lib/index.ts @@ -1,5 +1,4 @@ export * from './add-files'; export * from './add-path-mapping'; export * from './normalize-options'; -export * from './update-linting-file-patterns'; export * from './update-tsconfig-included-files'; diff --git a/packages/angular/src/generators/library-secondary-entry-point/lib/update-linting-file-patterns.ts b/packages/angular/src/generators/library-secondary-entry-point/lib/update-linting-file-patterns.ts deleted file mode 100644 index ca3cee759a..0000000000 --- a/packages/angular/src/generators/library-secondary-entry-point/lib/update-linting-file-patterns.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Tree, updateProjectConfiguration } from '@nx/devkit'; -import { NormalizedGeneratorOptions } from '../schema'; - -export function updateLintingFilePatterns( - tree: Tree, - options: NormalizedGeneratorOptions -): void { - const { libraryProject } = options; - - if (libraryProject.targets?.lint?.options?.lintFilePatterns) { - libraryProject.targets.lint.options.lintFilePatterns.push( - ...[ - `${libraryProject.root}/${options.name}/**/*.ts`, - `${libraryProject.root}/${options.name}/**/*.html`, - ] - ); - - updateProjectConfiguration(tree, options.library, libraryProject); - } -} diff --git a/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.spec.ts b/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.spec.ts index 9c26db5d84..b2c3aa5669 100644 --- a/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.spec.ts +++ b/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.spec.ts @@ -146,41 +146,6 @@ describe('librarySecondaryEntryPoint generator', () => { ).toStrictEqual(['libs/lib1/testing/src/index.ts']); }); - it('should add the entry point file patterns to the lint target', async () => { - addProjectConfiguration(tree, 'lib1', { - root: 'libs/lib1', - projectType: 'library', - targets: { - lint: { - executor: '', - options: { - lintFilePatterns: [ - 'libs/lib1/src/**/*.ts', - 'libs/lib1/src/**/*.html', - ], - }, - }, - }, - }); - tree.write( - 'libs/lib1/package.json', - JSON.stringify({ name: '@my-org/lib1' }) - ); - - await librarySecondaryEntryPointGenerator(tree, { - name: 'testing', - library: 'lib1', - }); - - const project = readProjectConfiguration(tree, 'lib1'); - expect(project.targets!.lint.options.lintFilePatterns).toEqual( - expect.arrayContaining([ - 'libs/lib1/testing/**/*.ts', - 'libs/lib1/testing/**/*.html', - ]) - ); - }); - it('should update the tsconfig "include" and "exclude" options', async () => { await generateTestLibrary(tree, { name: 'lib1', diff --git a/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.ts b/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.ts index 2efe883c47..79cfe79539 100644 --- a/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.ts +++ b/packages/angular/src/generators/library-secondary-entry-point/library-secondary-entry-point.ts @@ -3,7 +3,6 @@ import { addFiles, addPathMapping, normalizeOptions, - updateLintingFilePatterns, updateTsConfigIncludedFiles, } from './lib'; import { GeneratorOptions } from './schema'; @@ -17,7 +16,6 @@ export async function librarySecondaryEntryPointGenerator( addFiles(tree, options); addPathMapping(tree, options); updateTsConfigIncludedFiles(tree, options); - updateLintingFilePatterns(tree, options); await formatFiles(tree); } diff --git a/packages/angular/src/generators/library/library.spec.ts b/packages/angular/src/generators/library/library.spec.ts index 0f0c4bd90f..13552281f0 100644 --- a/packages/angular/src/generators/library/library.spec.ts +++ b/packages/angular/src/generators/library/library.spec.ts @@ -1129,12 +1129,6 @@ describe('lib', () => { .toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-lib/**/*.ts", - "my-lib/**/*.html", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/angular/src/generators/ng-add/migrators/projects/e2e.migrator.ts b/packages/angular/src/generators/ng-add/migrators/projects/e2e.migrator.ts index 3a170f9335..91d17b466f 100644 --- a/packages/angular/src/generators/ng-add/migrators/projects/e2e.migrator.ts +++ b/packages/angular/src/generators/ng-add/migrators/projects/e2e.migrator.ts @@ -322,7 +322,6 @@ export class E2eMigrator extends ProjectMigrator { await lintProjectGenerator(this.tree, { project: this.project.name, linter: Linter.EsLint, - eslintFilePatterns: [`${this.project.newRoot}/**/*.{js,ts}`], unitTestRunner: this.options.unitTestRunner, tsConfigPaths: [ joinPathFragments(this.project.newRoot, 'tsconfig.json'), diff --git a/packages/cypress/src/generators/cypress-project/__snapshots__/cypress-project.spec.ts.snap b/packages/cypress/src/generators/cypress-project/__snapshots__/cypress-project.spec.ts.snap index 1a049b8af0..2fa158d61e 100644 --- a/packages/cypress/src/generators/cypress-project/__snapshots__/cypress-project.spec.ts.snap +++ b/packages/cypress/src/generators/cypress-project/__snapshots__/cypress-project.spec.ts.snap @@ -50,11 +50,6 @@ exports[`Cypress Project < v7 nested should update configuration 1`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-dir/my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -96,11 +91,6 @@ exports[`Cypress Project < v7 project with directory in its name should update c }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-dir/my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -121,11 +111,6 @@ exports[`Cypress Project < v7 should update project configuration (baseUrl) 1`] }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -151,11 +136,6 @@ exports[`Cypress Project < v7 should update project configuration 1`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -181,11 +161,6 @@ exports[`Cypress Project < v7 should update target configurations 1`] = ` }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -268,11 +243,6 @@ exports[`Cypress Project > v10 should set right path names in \`tsconfig.e2e.jso exports[`Cypress Project > v10 should update configuration when eslint is passed 1`] = ` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/cypress/src/generators/migrate-to-cypress-11/__snapshots__/migrate-to-cypress-11.spec.ts.snap b/packages/cypress/src/generators/migrate-to-cypress-11/__snapshots__/migrate-to-cypress-11.spec.ts.snap index b8843b9698..af35b36235 100644 --- a/packages/cypress/src/generators/migrate-to-cypress-11/__snapshots__/migrate-to-cypress-11.spec.ts.snap +++ b/packages/cypress/src/generators/migrate-to-cypress-11/__snapshots__/migrate-to-cypress-11.spec.ts.snap @@ -182,11 +182,6 @@ exports[`convertToCypressTen convertCypressProject should infer targets with --a }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], @@ -247,11 +242,6 @@ exports[`convertToCypressTen convertCypressProject should not break when an inva }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "app-e2e/**/*.{js,ts}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/cypress/src/utils/add-linter.ts b/packages/cypress/src/utils/add-linter.ts index add4b4d513..dba3edc5e4 100644 --- a/packages/cypress/src/utils/add-linter.ts +++ b/packages/cypress/src/utils/add-linter.ts @@ -57,9 +57,6 @@ export async function addLinterToCyProject( linter: options.linter, skipFormat: true, tsConfigPaths: [joinPathFragments(projectConfig.root, 'tsconfig.json')], - eslintFilePatterns: [ - `${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`, - ], setParserOptionsProject: options.setParserOptionsProject, skipPackageJson: options.skipPackageJson, rootProject: options.rootProject, diff --git a/packages/detox/src/generators/application/lib/add-linting.ts b/packages/detox/src/generators/application/lib/add-linting.ts index 2f42357414..f02e171c78 100644 --- a/packages/detox/src/generators/application/lib/add-linting.ts +++ b/packages/detox/src/generators/application/lib/add-linting.ts @@ -23,7 +23,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { tsConfigPaths: [ joinPathFragments(options.e2eProjectRoot, 'tsconfig.app.json'), ], - eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{ts,tsx,js,jsx}`], skipFormat: true, }); diff --git a/packages/eslint/migrations.json b/packages/eslint/migrations.json index 891d477f1e..3b48926a31 100644 --- a/packages/eslint/migrations.json +++ b/packages/eslint/migrations.json @@ -32,6 +32,11 @@ "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" + }, + "simplify-eslint-patterns": { + "version": "17.2.0-beta.0", + "description": "Simplify eslintFilePatterns", + "implementation": "./src/migrations/update-17-2-0/simplify-eslint-patterns" } }, "packageJsonUpdates": { diff --git a/packages/eslint/src/executors/lint/lint.impl.ts b/packages/eslint/src/executors/lint/lint.impl.ts index abac84c3af..0f3304a902 100644 --- a/packages/eslint/src/executors/lint/lint.impl.ts +++ b/packages/eslint/src/executors/lint/lint.impl.ts @@ -5,6 +5,7 @@ import { dirname, resolve } from 'path'; import type { Schema } from './schema'; import { resolveAndInstantiateESLint } from './utility/eslint-utils'; +import { interpolate } from 'nx/src/tasks-runner/utils'; export default async function run( options: Schema, @@ -84,8 +85,18 @@ export default async function run( let lintResults: ESLint.LintResult[] = []; + const normalizedLintFilePatterns = normalizedOptions.lintFilePatterns.map( + (pattern) => { + return interpolate(pattern, { + workspaceRoot: '', + projectRoot: + context.projectsConfigurations.projects[context.projectName].root, + projectName: context.projectName, + }); + } + ); try { - lintResults = await eslint.lintFiles(normalizedOptions.lintFilePatterns); + lintResults = await eslint.lintFiles(normalizedLintFilePatterns); } catch (err) { if ( err.message.includes( @@ -117,7 +128,7 @@ Please see https://nx.dev/guides/eslint for full guidance on how to resolve this if (lintResults.length === 0 && errorOnUnmatchedPattern) { const ignoredPatterns = ( await Promise.all( - normalizedOptions.lintFilePatterns.map(async (pattern) => + normalizedLintFilePatterns.map(async (pattern) => (await eslint.isPathIgnored(pattern)) ? pattern : null ) ) diff --git a/packages/eslint/src/executors/lint/schema.json b/packages/eslint/src/executors/lint/schema.json index 13925b8339..9ded29d171 100644 --- a/packages/eslint/src/executors/lint/schema.json +++ b/packages/eslint/src/executors/lint/schema.json @@ -17,7 +17,7 @@ "lintFilePatterns": { "type": "array", "description": "One or more files/dirs/globs to pass directly to ESLint's `lintFiles()` method.", - "default": [], + "default": ["{projectRoot}"], "items": { "type": "string" } @@ -144,6 +144,5 @@ "default": true } }, - "required": ["lintFilePatterns"], "examplesFile": "../../../docs/eslint-examples.md" } 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 936f5a0bef..90c2b0e1ba 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 @@ -46,7 +46,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -132,7 +131,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -216,7 +214,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -233,12 +230,12 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); tree.write('another-folder/.myeslintignore', 'ignore/me'); updateJson(tree, 'libs/test-lib/project.json', (json) => { + json.targets.lint.options = json.targets.lint.options || {}; json.targets.lint.options.ignorePath = 'another-folder/.myeslintignore'; return json; }); @@ -262,7 +259,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -281,7 +277,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -301,7 +296,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -320,7 +314,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -342,7 +335,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -364,7 +356,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -381,7 +372,6 @@ describe('convert-to-flat-config generator', () => { await lintProjectGenerator(tree, { skipFormat: false, linter: Linter.EsLint, - eslintFilePatterns: ['**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); diff --git a/packages/eslint/src/generators/init/init-migration.ts b/packages/eslint/src/generators/init/init-migration.ts index a4da8e7804..0a78ae6804 100644 --- a/packages/eslint/src/generators/init/init-migration.ts +++ b/packages/eslint/src/generators/init/init-migration.ts @@ -55,7 +55,7 @@ export function migrateConfigToMonorepoStyle( const lintTarget = findLintTarget(project); if (lintTarget) { const eslintFile = - lintTarget.options.eslintConfig || findEslintFile(tree, project.root); + lintTarget.options?.eslintConfig || findEslintFile(tree, project.root); if (eslintFile) { const projectEslintPath = joinPathFragments(project.root, eslintFile); migrateEslintFile(projectEslintPath, tree); diff --git a/packages/eslint/src/generators/lint-project/lint-project.spec.ts b/packages/eslint/src/generators/lint-project/lint-project.spec.ts index fb431b0483..17201adc0b 100644 --- a/packages/eslint/src/generators/lint-project/lint-project.spec.ts +++ b/packages/eslint/src/generators/lint-project/lint-project.spec.ts @@ -44,7 +44,6 @@ describe('@nx/eslint:lint-project', () => { await lintProjectGenerator(tree, { ...defaultOptions, linter: Linter.EsLint, - eslintFilePatterns: ['libs/test-lib/**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -72,13 +71,33 @@ describe('@nx/eslint:lint-project', () => { " `); + const projectConfig = readProjectConfiguration(tree, 'test-lib'); + expect(projectConfig.targets.lint).toMatchInlineSnapshot(` + { + "executor": "@nx/eslint:lint", + "outputs": [ + "{options.outputFile}", + ], + } + `); + }); + + it('should generate a project config with lintFilePatterns if provided', async () => { + await lintProjectGenerator(tree, { + ...defaultOptions, + linter: Linter.EsLint, + project: 'test-lib', + eslintFilePatterns: ['libs/test-lib/src/**/*.ts'], + setParserOptionsProject: false, + }); + const projectConfig = readProjectConfiguration(tree, 'test-lib'); expect(projectConfig.targets.lint).toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", "options": { "lintFilePatterns": [ - "libs/test-lib/**/*.ts", + "libs/test-lib/src/**/*.ts", ], }, "outputs": [ @@ -92,7 +111,6 @@ describe('@nx/eslint:lint-project', () => { await lintProjectGenerator(tree, { ...defaultOptions, linter: Linter.EsLint, - eslintFilePatterns: ['libs/buildable-lib/**/*.ts'], project: 'buildable-lib', setParserOptionsProject: false, }); @@ -127,14 +145,34 @@ describe('@nx/eslint:lint-project', () => { " `); + const projectConfig = readProjectConfiguration(tree, 'buildable-lib'); + expect(projectConfig.targets.lint).toMatchInlineSnapshot(` + { + "executor": "@nx/eslint:lint", + "outputs": [ + "{options.outputFile}", + ], + } + `); + }); + + it('should generate a project config for buildable lib with lintFilePatterns if provided', async () => { + await lintProjectGenerator(tree, { + ...defaultOptions, + linter: Linter.EsLint, + project: 'buildable-lib', + setParserOptionsProject: false, + eslintFilePatterns: ['libs/test-lib/src/**/*.ts'], + }); + const projectConfig = readProjectConfiguration(tree, 'buildable-lib'); expect(projectConfig.targets.lint).toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", "options": { "lintFilePatterns": [ - "libs/buildable-lib/**/*.ts", - "libs/buildable-lib/package.json", + "libs/test-lib/src/**/*.ts", + "{projectRoot}/package.json", ], }, "outputs": [ @@ -150,7 +188,6 @@ describe('@nx/eslint:lint-project', () => { await lintProjectGenerator(tree, { ...defaultOptions, linter: Linter.EsLint, - eslintFilePatterns: ['libs/test-lib/**/*.ts'], project: 'test-lib', setParserOptionsProject: false, }); @@ -189,7 +226,6 @@ describe('@nx/eslint:lint-project', () => { await lintProjectGenerator(tree, { ...defaultOptions, linter: Linter.EsLint, - eslintFilePatterns: ['libs/buildable-lib/**/*.ts'], project: 'buildable-lib', setParserOptionsProject: false, }); @@ -213,7 +249,6 @@ describe('@nx/eslint:lint-project', () => { await lintProjectGenerator(tree, { ...defaultOptions, linter: Linter.EsLint, - eslintFilePatterns: ['libs/buildable-lib/**/*.ts'], project: 'buildable-lib', setParserOptionsProject: false, }); diff --git a/packages/eslint/src/generators/lint-project/lint-project.ts b/packages/eslint/src/generators/lint-project/lint-project.ts index e9c1b32ea4..6981ca57dd 100644 --- a/packages/eslint/src/generators/lint-project/lint-project.ts +++ b/packages/eslint/src/generators/lint-project/lint-project.ts @@ -47,18 +47,6 @@ interface LintProjectOptions { rootProject?: boolean; } -export function mapLintPattern( - projectRoot: string, - extension: string, - rootProject?: boolean -) { - if (rootProject && (projectRoot === '.' || projectRoot === '')) { - return `${projectRoot}/src/**/*.${extension}`; - } else { - return `${projectRoot}/**/*.${extension}`; - } -} - export async function lintProjectGenerator( tree: Tree, options: LintProjectOptions @@ -71,19 +59,29 @@ export async function lintProjectGenerator( }); const projectConfig = readProjectConfiguration(tree, options.project); - const lintFilePatterns = options.eslintFilePatterns ?? []; - if (isBuildableLibraryProject(projectConfig)) { - lintFilePatterns.push(`${projectConfig.root}/package.json`); - } - projectConfig.targets['lint'] = { executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: lintFilePatterns, - }, }; + let lintFilePatterns = options.eslintFilePatterns; + if (!lintFilePatterns && options.rootProject && projectConfig.root === '.') { + lintFilePatterns = ['./src']; + } + if (lintFilePatterns && lintFilePatterns.length) { + if ( + isBuildableLibraryProject(projectConfig) && + !lintFilePatterns.includes('{projectRoot}') + ) { + lintFilePatterns.push(`{projectRoot}/package.json`); + } + + // only add lintFilePatterns if they are explicitly defined + projectConfig.targets['lint'].options = { + lintFilePatterns, + }; + } + // we are adding new project which is not the root project or // companion e2e app so we should check if migration to // monorepo style is needed diff --git a/packages/eslint/src/migrations/update-17-2-0/simplify-eslint-patterns.spec.ts b/packages/eslint/src/migrations/update-17-2-0/simplify-eslint-patterns.spec.ts new file mode 100644 index 0000000000..09e3a07e90 --- /dev/null +++ b/packages/eslint/src/migrations/update-17-2-0/simplify-eslint-patterns.spec.ts @@ -0,0 +1,145 @@ +import { Tree, addProjectConfiguration, readJson } from '@nx/devkit'; + +import update from './simplify-eslint-patterns'; +import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports'; + +describe('simplify-eslint-patterns migration', () => { + let tree: Tree; + + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + tree.write('.eslintrc.json', '{}'); + }); + + it('should remove pattern if matches default', async () => { + addProjectConfiguration(tree, 'test-lib', { + root: 'libs/test-lib', + projectType: 'library', + targets: { + lint: { + executor: '@nx/eslint:lint', + options: { + lintFilePatterns: ['libs/test-lib/**/*.{ts,html}'], + }, + }, + }, + }); + + await update(tree); + + const projJson = readJson(tree, 'libs/test-lib/project.json'); + expect(projJson.targets.lint).toMatchInlineSnapshot(` + { + "executor": "@nx/eslint:lint", + } + `); + }); + + it('should not remove options if other fields are set', async () => { + addProjectConfiguration(tree, 'test-lib', { + root: 'libs/test-lib', + projectType: 'library', + targets: { + lint: { + executor: '@nx/eslint:lint', + options: { + lintFilePatterns: ['libs/test-lib/**/*.{ts,html}'], + ignorePatterns: ['**/node_modules/**'], + }, + }, + }, + }); + + await update(tree); + + const projJson = readJson(tree, 'libs/test-lib/project.json'); + expect(projJson.targets.lint).toMatchInlineSnapshot(` + { + "executor": "@nx/eslint:lint", + "options": { + "ignorePatterns": [ + "**/node_modules/**", + ], + }, + } + `); + }); + + it('should remove multiple lint patterns if matches default', async () => { + addProjectConfiguration(tree, 'test-lib', { + root: 'libs/test-lib', + projectType: 'library', + targets: { + lint: { + executor: '@nx/eslint:lint', + options: { + lintFilePatterns: [ + 'libs/test-lib/**/*.ts', + 'libs/test-lib/**/*.html', + 'libs/test-lib/**/*.tsx', + ], + }, + }, + }, + }); + + await update(tree); + + const projJson = readJson(tree, 'libs/test-lib/project.json'); + expect(projJson.targets.lint).toMatchInlineSnapshot(` + { + "executor": "@nx/eslint:lint", + } + `); + }); + + it('should persist external patterns', async () => { + addProjectConfiguration(tree, 'test-lib', { + root: 'libs/test-lib', + projectType: 'library', + targets: { + lint: { + executor: '@nx/eslint:lint', + options: { + lintFilePatterns: [ + 'libs/test-lib/**/*.ts', + 'libs/some-external/**/*.html', + 'libs/test-lib/**/*.tsx', + '**/*.js', + ], + }, + }, + }, + }); + + await update(tree); + + const projJson = readJson(tree, 'libs/test-lib/project.json'); + expect(projJson.targets.lint.options.lintFilePatterns).toEqual([ + 'libs/test-lib', + 'libs/some-external/**/*.html', + '**/*.js', + ]); + }); + + it('should update standalone projects lint patterns', async () => { + addProjectConfiguration(tree, 'test-lib', { + root: '', + sourceRoot: './src', + projectType: 'library', + targets: { + lint: { + executor: '@nx/eslint:lint', + options: { + lintFilePatterns: ['./src/**/*.{ts,html}'], + }, + }, + }, + }); + + await update(tree); + + const projJson = readJson(tree, 'project.json'); + expect(projJson.targets.lint.options.lintFilePatterns).toEqual(['./src']); + }); +}); diff --git a/packages/eslint/src/migrations/update-17-2-0/simplify-eslint-patterns.ts b/packages/eslint/src/migrations/update-17-2-0/simplify-eslint-patterns.ts new file mode 100644 index 0000000000..e572880ce7 --- /dev/null +++ b/packages/eslint/src/migrations/update-17-2-0/simplify-eslint-patterns.ts @@ -0,0 +1,66 @@ +import { + ProjectConfiguration, + Tree, + formatFiles, + getProjects, + updateProjectConfiguration, +} from '@nx/devkit'; + +export default async function update(tree: Tree) { + const projects = getProjects(tree); + + for (const [projectName, projectConfiguration] of projects) { + let needsUpdate = false; + + for (const [targetName, targetConfig] of Object.entries( + projectConfiguration.targets ?? {} + )) { + if (targetConfig.executor !== '@nx/eslint:lint') { + continue; + } + + needsUpdate = true; + if (projectConfiguration.targets[targetName].options?.lintFilePatterns) { + const rootPattern = getLintRoot(projectConfiguration); + const nonRootPatterns = projectConfiguration.targets[ + targetName + ].options.lintFilePatterns.filter( + (p) => !p.startsWith(rootPattern) && !p.startsWith('{projectRoot}') + ); + + if ( + nonRootPatterns.length === 0 && + rootPattern === projectConfiguration.root + ) { + // delete the lintFilePatterns option if it's the only option and matches the root of the project + delete projectConfiguration.targets[targetName].options + .lintFilePatterns; + if ( + Object.keys(projectConfiguration.targets[targetName].options) + .length === 0 + ) { + delete projectConfiguration.targets[targetName].options; + } + } else { + projectConfiguration.targets[targetName].options.lintFilePatterns = [ + rootPattern, + ...nonRootPatterns, + ]; + } + } + } + + if (needsUpdate) { + updateProjectConfiguration(tree, projectName, projectConfiguration); + } + } + + await formatFiles(tree); +} + +function getLintRoot({ root, sourceRoot }: ProjectConfiguration): string { + if (root === '' || root === '.') { + return sourceRoot || './src'; + } + return root; +} diff --git a/packages/expo/src/generators/library/library.spec.ts b/packages/expo/src/generators/library/library.spec.ts index 9ae5797763..78cae69e55 100644 --- a/packages/expo/src/generators/library/library.spec.ts +++ b/packages/expo/src/generators/library/library.spec.ts @@ -42,9 +42,6 @@ describe('lib', () => { expect(projectConfiguration.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'], - }, }); expect(projectConfiguration.tags).toEqual(['one', 'two']); }); @@ -151,9 +148,6 @@ describe('lib', () => { expect(projectConfiguration.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-dir/my-lib/**/*.{ts,tsx,js,jsx}'], - }, }); }); @@ -200,9 +194,6 @@ describe('lib', () => { expect(projectConfiguration.targets.test).toBeUndefined(); expect(projectConfiguration.targets.lint).toMatchObject({ executor: '@nx/eslint:lint', - options: { - lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'], - }, outputs: ['{options.outputFile}'], }); }); diff --git a/packages/expo/src/utils/add-linting.ts b/packages/expo/src/utils/add-linting.ts index 70ee6f3e2e..2b0ae44509 100644 --- a/packages/expo/src/utils/add-linting.ts +++ b/packages/expo/src/utils/add-linting.ts @@ -31,7 +31,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { linter: options.linter, project: options.projectName, tsConfigPaths: options.tsConfigPaths, - eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`], skipFormat: true, skipPackageJson: options.skipPackageJson, }); diff --git a/packages/js/src/generators/library/library.spec.ts b/packages/js/src/generators/library/library.spec.ts index 27ec711efd..067e6a9401 100644 --- a/packages/js/src/generators/library/library.spec.ts +++ b/packages/js/src/generators/library/library.spec.ts @@ -496,9 +496,6 @@ describe('lib', () => { expect(readProjectConfiguration(tree, 'my-lib').targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/**/*.ts', 'my-lib/package.json'], - }, }); }); @@ -569,12 +566,6 @@ describe('lib', () => { expect(readProjectConfiguration(tree, 'my-lib').targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: [ - 'my-dir/my-lib/**/*.ts', - 'my-dir/my-lib/package.json', - ], - }, }); }); @@ -711,10 +702,6 @@ describe('lib', () => { js: true, projectNameAndRootFormat: 'as-provided', }); - expect( - readProjectConfiguration(tree, 'my-lib').targets.lint.options - .lintFilePatterns - ).toEqual(['my-dir/my-lib/**/*.js', 'my-dir/my-lib/package.json']); expect(readJson(tree, 'my-dir/my-lib/.eslintrc.json')) .toMatchInlineSnapshot(` { diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index 9b8bc833f4..618a895497 100644 --- a/packages/js/src/generators/library/library.ts +++ b/packages/js/src/generators/library/library.ts @@ -270,9 +270,6 @@ export async function addLint( options: AddLintOptions ): Promise { const { lintProjectGenerator } = ensurePackage('@nx/eslint', nxVersion); - const { mapLintPattern } = - // nx-ignore-next-line - require('@nx/eslint/src/generators/lint-project/lint-project'); const projectConfiguration = readProjectConfiguration(tree, options.name); const task = lintProjectGenerator(tree, { project: options.name, @@ -282,13 +279,6 @@ export async function addLint( joinPathFragments(options.projectRoot, 'tsconfig.lib.json'), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [ - mapLintPattern( - options.projectRoot, - options.js ? 'js' : 'ts', - options.rootProject - ), - ], setParserOptionsProject: options.setParserOptionsProject, rootProject: options.rootProject, }); diff --git a/packages/nest/src/generators/library/__snapshots__/library.spec.ts.snap b/packages/nest/src/generators/library/__snapshots__/library.spec.ts.snap index 0027a19b08..5824869dc9 100644 --- a/packages/nest/src/generators/library/__snapshots__/library.spec.ts.snap +++ b/packages/nest/src/generators/library/__snapshots__/library.spec.ts.snap @@ -54,11 +54,6 @@ exports[`lib --unit-test-runner none should not generate test configuration 1`] exports[`lib --unit-test-runner none should not generate test configuration 2`] = ` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-lib/**/*.ts", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/nest/src/generators/library/library.spec.ts b/packages/nest/src/generators/library/library.spec.ts index a0e043056f..0b8262226f 100644 --- a/packages/nest/src/generators/library/library.spec.ts +++ b/packages/nest/src/generators/library/library.spec.ts @@ -25,9 +25,6 @@ describe('lib', () => { expect(config.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: [`my-lib/**/*.ts`], - }, }); expect(config.targets.test).toEqual({ executor: '@nx/jest:jest', @@ -214,9 +211,6 @@ describe('lib', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: [`my-dir/my-lib/**/*.ts`], - }, }); }); diff --git a/packages/next/src/generators/application/lib/add-linting.ts b/packages/next/src/generators/application/lib/add-linting.ts index 71ab2fa282..73eec8abf4 100644 --- a/packages/next/src/generators/application/lib/add-linting.ts +++ b/packages/next/src/generators/application/lib/add-linting.ts @@ -15,7 +15,6 @@ import { isEslintConfigSupported, updateOverrideInLintConfig, } from '@nx/eslint/src/generators/utils/eslint-file'; -import { mapLintPattern } from '@nx/eslint/src/generators/lint-project/lint-project'; export async function addLinting( host: Tree, @@ -28,13 +27,6 @@ export async function addLinting( joinPathFragments(options.appProjectRoot, 'tsconfig.app.json'), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [ - mapLintPattern( - options.appProjectRoot, - '{ts,tsx,js,jsx}', - options.rootProject - ), - ], skipFormat: true, rootProject: options.rootProject, }); diff --git a/packages/node/src/generators/application/application.spec.ts b/packages/node/src/generators/application/application.spec.ts index f688abcc66..8e8e779c05 100644 --- a/packages/node/src/generators/application/application.spec.ts +++ b/packages/node/src/generators/application/application.spec.ts @@ -71,9 +71,6 @@ describe('app', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-node-app/**/*.ts'], - }, }); expect(() => readProjectConfiguration(tree, 'my-node-app-e2e') @@ -195,9 +192,6 @@ describe('app', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-dir/my-node-app/**/*.ts'], - }, }); expect(() => @@ -284,11 +278,6 @@ describe('app', () => { expect(project.targets.lint).toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-node-app/**/*.ts", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/node/src/generators/application/application.ts b/packages/node/src/generators/application/application.ts index 939ce5b144..1abbdeb308 100644 --- a/packages/node/src/generators/application/application.ts +++ b/packages/node/src/generators/application/application.ts @@ -24,7 +24,6 @@ import { configurationGenerator } from '@nx/jest'; import { getRelativePathToRootTsConfig, tsConfigBaseOptions } from '@nx/js'; import { esbuildVersion } from '@nx/js/src/utils/versions'; import { Linter, lintProjectGenerator } from '@nx/eslint'; -import { mapLintPattern } from '@nx/eslint/src/generators/lint-project/lint-project'; import { join } from 'path'; import { expressTypingsVersion, @@ -268,13 +267,6 @@ export async function addLintingToApplication( tsConfigPaths: [ joinPathFragments(options.appProjectRoot, 'tsconfig.app.json'), ], - eslintFilePatterns: [ - mapLintPattern( - options.appProjectRoot, - options.js ? 'js' : 'ts', - options.rootProject - ), - ], unitTestRunner: options.unitTestRunner, skipFormat: true, setParserOptionsProject: options.setParserOptionsProject, diff --git a/packages/node/src/generators/e2e-project/e2e-project.ts b/packages/node/src/generators/e2e-project/e2e-project.ts index aa84f6ac95..cac4c97e5e 100644 --- a/packages/node/src/generators/e2e-project/e2e-project.ts +++ b/packages/node/src/generators/e2e-project/e2e-project.ts @@ -115,7 +115,6 @@ export async function e2eProjectGeneratorInternal( tsConfigPaths: [ joinPathFragments(options.e2eProjectRoot, 'tsconfig.json'), ], - eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`], setParserOptionsProject: false, skipPackageJson: false, rootProject: options.rootProject, diff --git a/packages/node/src/generators/library/library.spec.ts b/packages/node/src/generators/library/library.spec.ts index 632676c868..82da3029f2 100644 --- a/packages/node/src/generators/library/library.spec.ts +++ b/packages/node/src/generators/library/library.spec.ts @@ -31,9 +31,6 @@ describe('lib', () => { expect(configuration.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/**/*.ts'], - }, }); expect(configuration.targets.test).toEqual({ executor: '@nx/jest:jest', @@ -224,9 +221,6 @@ describe('lib', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-dir/my-lib/**/*.ts'], - }, }); }); diff --git a/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap index dbad06c799..20dcf5bca6 100644 --- a/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap @@ -84,10 +84,7 @@ exports[`app generated files content - as-provided general application should co }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["my-app/**/*.{ts,tsx,js,jsx,vue}"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/vite:test", diff --git a/packages/nuxt/src/utils/add-linting.ts b/packages/nuxt/src/utils/add-linting.ts index 20950c3ef4..1d6b5cceca 100644 --- a/packages/nuxt/src/utils/add-linting.ts +++ b/packages/nuxt/src/utils/add-linting.ts @@ -27,7 +27,6 @@ export async function addLinting( project: options.projectName, tsConfigPaths: [joinPathFragments(options.projectRoot, 'tsconfig.json')], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx,vue}`], skipFormat: true, rootProject: options.rootProject, }); diff --git a/packages/nx/src/command-line/init/implementation/add-nx-to-nest.ts b/packages/nx/src/command-line/init/implementation/add-nx-to-nest.ts index e618c47965..ea943ee28a 100644 --- a/packages/nx/src/command-line/init/implementation/add-nx-to-nest.ts +++ b/packages/nx/src/command-line/init/implementation/add-nx-to-nest.ts @@ -240,7 +240,7 @@ function createProjectJson( executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], options: { - lintFilePatterns: ['src/**/*.ts', 'test/**/*.ts'], + lintFilePatterns: ['./src', './test'], }, }; diff --git a/packages/playwright/src/utils/add-linter.ts b/packages/playwright/src/utils/add-linter.ts index dc1354f891..8f71ee1d18 100644 --- a/packages/playwright/src/utils/add-linter.ts +++ b/packages/playwright/src/utils/add-linter.ts @@ -49,9 +49,6 @@ export async function addLinterToPlaywrightProject( linter: options.linter, skipFormat: true, tsConfigPaths: [joinPathFragments(projectConfig.root, 'tsconfig.json')], - eslintFilePatterns: [ - `${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`, - ], setParserOptionsProject: options.setParserOptionsProject, skipPackageJson: options.skipPackageJson, rootProject: options.rootProject, diff --git a/packages/plugin/src/generators/e2e-project/e2e.spec.ts b/packages/plugin/src/generators/e2e-project/e2e.spec.ts index 5b042d22f7..2507002a05 100644 --- a/packages/plugin/src/generators/e2e-project/e2e.spec.ts +++ b/packages/plugin/src/generators/e2e-project/e2e.spec.ts @@ -164,9 +164,6 @@ describe('NxPlugin e2e-project Generator', () => { expect(projectsConfigurations.get('my-plugin-e2e').targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['apps/my-plugin-e2e/**/*.ts'], - }, }); }); }); diff --git a/packages/plugin/src/generators/e2e-project/e2e.ts b/packages/plugin/src/generators/e2e-project/e2e.ts index f413b79b21..c1bbb9f234 100644 --- a/packages/plugin/src/generators/e2e-project/e2e.ts +++ b/packages/plugin/src/generators/e2e-project/e2e.ts @@ -168,7 +168,6 @@ async function addLintingToApplication( tsConfigPaths: [ joinPathFragments(options.projectRoot, 'tsconfig.app.json'), ], - eslintFilePatterns: [`${options.projectRoot}/**/*.ts`], unitTestRunner: 'jest', skipFormat: true, setParserOptionsProject: false, diff --git a/packages/plugin/src/generators/lint-checks/generator.spec.ts b/packages/plugin/src/generators/lint-checks/generator.spec.ts index 685c3db078..21398c95a0 100644 --- a/packages/plugin/src/generators/lint-checks/generator.spec.ts +++ b/packages/plugin/src/generators/lint-checks/generator.spec.ts @@ -10,7 +10,6 @@ import { import type { Linter as ESLint } from 'eslint'; import { Linter } from '@nx/eslint'; -import { Schema as EsLintExecutorOptions } from '@nx/eslint/src/executors/lint/schema'; import generator from './generator'; import pluginGenerator from '../plugin/plugin'; @@ -53,21 +52,11 @@ describe('lint-checks generator', () => { await generator(tree, { projectName: 'plugin' }); const projectConfig = readProjectConfiguration(tree, 'plugin'); - const targetConfig = projectConfig.targets?.['lint']; const eslintConfig: ESLint.Config = readJson( tree, `${projectConfig.root}/.eslintrc.json` ); - expect(targetConfig.options.lintFilePatterns).toContain( - `${projectConfig.root}/generators.json` - ); - expect(targetConfig.options.lintFilePatterns).toContain( - `${projectConfig.root}/executors.json` - ); - expect(targetConfig.options.lintFilePatterns).toContain( - `${projectConfig.root}/package.json` - ); expect(eslintConfig.overrides).toContainEqual( expect.objectContaining({ files: expect.arrayContaining([ @@ -86,19 +75,11 @@ describe('lint-checks generator', () => { await generator(tree, { projectName: 'plugin' }); await generator(tree, { projectName: 'plugin' }); const projectConfig = readProjectConfiguration(tree, 'plugin'); - const targetConfig = projectConfig.targets?.['lint'] - .options as EsLintExecutorOptions; const eslintConfig: ESLint.Config = readJson( tree, `${projectConfig.root}/.eslintrc.json` ); - const uniqueLintFilePatterns = new Set(targetConfig.lintFilePatterns); - - expect(targetConfig.lintFilePatterns).toHaveLength( - uniqueLintFilePatterns.size - ); - expect( eslintConfig.overrides.filter((x) => '@nx/nx-plugin-checks' in x.rules) ).toHaveLength(1); @@ -125,27 +106,11 @@ describe('lint-checks generator', () => { ); await generator(tree, { projectName: 'plugin' }); const projectConfig = readProjectConfiguration(tree, 'plugin'); - const targetConfig = projectConfig.targets?.['lint']; const eslintConfig: ESLint.Config = readJson( tree, `${projectConfig.root}/.eslintrc.json` ); - expect(targetConfig.options.lintFilePatterns).not.toContain( - `${projectConfig.root}/generators.json` - ); - expect(targetConfig.options.lintFilePatterns).toContain( - `${projectConfig.root}/collection.json` - ); - expect(targetConfig.options.lintFilePatterns).not.toContain( - `${projectConfig.root}/executors.json` - ); - expect(targetConfig.options.lintFilePatterns).toContain( - `${projectConfig.root}/builders.json` - ); - expect(targetConfig.options.lintFilePatterns).toContain( - `${projectConfig.root}/migrations.json` - ); expect(eslintConfig.overrides).toContainEqual( expect.objectContaining({ files: expect.arrayContaining([ diff --git a/packages/plugin/src/generators/lint-checks/generator.ts b/packages/plugin/src/generators/lint-checks/generator.ts index 87a224b08c..949ccaa40e 100644 --- a/packages/plugin/src/generators/lint-checks/generator.ts +++ b/packages/plugin/src/generators/lint-checks/generator.ts @@ -94,33 +94,37 @@ export function addMigrationJsonChecks( relativeMigrationsJsonPath ); + if (!eslintTarget) { + return; + } + + // Add path to lintFilePatterns if different than default "{projectRoot}" if ( - eslintTarget && - !eslintTargetConfiguration.options?.lintFilePatterns?.includes( + eslintTargetConfiguration.options?.lintFilePatterns && + !eslintTargetConfiguration.options.lintFilePatterns.includes( migrationsJsonPath ) ) { - // Add to lintFilePatterns eslintTargetConfiguration.options.lintFilePatterns.push(migrationsJsonPath); updateProjectConfiguration(host, options.projectName, projectConfiguration); - - // Update project level eslintrc - updateOverrideInLintConfig( - host, - projectConfiguration.root, - (o) => - Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') || - Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), - (o) => { - const fileSet = new Set(Array.isArray(o.files) ? o.files : [o.files]); - fileSet.add(relativeMigrationsJsonPath); - return { - ...o, - files: Array.from(fileSet), - }; - } - ); } + + // Update project level eslintrc + updateOverrideInLintConfig( + host, + projectConfiguration.root, + (o) => + Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') || + Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), + (o) => { + const fileSet = new Set(Array.isArray(o.files) ? o.files : [o.files]); + fileSet.add(relativeMigrationsJsonPath); + return { + ...o, + files: Array.from(fileSet), + }; + } + ); } function updateProjectTarget( @@ -135,9 +139,9 @@ function updateProjectTarget( for (const [target, configuration] of Object.entries(project.targets)) { if ( - configuration.executor === '@nx/eslint:lint' || - configuration.executor === '@nx/linter:eslint' || - configuration.executor === '@nrwl/linter:eslint' + configuration.executor === '@nx/eslint:lint' && + // only add patterns if there are already hardcoded ones + configuration.options?.lintFilePatterns ) { const opts: EsLintExecutorOptions = configuration.options ?? {}; opts.lintFilePatterns ??= []; diff --git a/packages/plugin/src/generators/plugin/plugin.spec.ts b/packages/plugin/src/generators/plugin/plugin.spec.ts index a6d6c00fe3..44a6930de0 100644 --- a/packages/plugin/src/generators/plugin/plugin.spec.ts +++ b/packages/plugin/src/generators/plugin/plugin.spec.ts @@ -71,12 +71,6 @@ describe('NxPlugin Plugin Generator', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: expect.arrayContaining([ - 'libs/my-plugin/**/*.ts', - 'libs/my-plugin/package.json', - ]), - }, }); expect(project.targets.test).toEqual({ executor: '@nx/jest:jest', diff --git a/packages/react-native/src/generators/component-story/component-story.spec.ts b/packages/react-native/src/generators/component-story/component-story.spec.ts index dfb22bd2f8..937e30acd9 100644 --- a/packages/react-native/src/generators/component-story/component-story.spec.ts +++ b/packages/react-native/src/generators/component-story/component-story.spec.ts @@ -420,7 +420,6 @@ export async function createTestUILib(libName: string): Promise { const currentWorkspaceJson = getProjects(appTree); const projectConfig = currentWorkspaceJson.get(libName); - projectConfig.targets.lint.options.linter = 'eslint'; updateProjectConfiguration(appTree, libName, projectConfig); diff --git a/packages/react-native/src/generators/library/library.spec.ts b/packages/react-native/src/generators/library/library.spec.ts index 8387f60011..3921096e86 100644 --- a/packages/react-native/src/generators/library/library.spec.ts +++ b/packages/react-native/src/generators/library/library.spec.ts @@ -36,9 +36,6 @@ describe('lib', () => { expect(projectConfiguration.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'], - }, }); expect(projectConfiguration.tags).toEqual(['one', 'two']); }); @@ -160,9 +157,6 @@ describe('lib', () => { expect(projectConfiguration.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-dir/**/*.{ts,tsx,js,jsx}'], - }, }); }); @@ -241,9 +235,6 @@ describe('lib', () => { expect(projectConfiguration.targets.test).toBeUndefined(); expect(projectConfiguration.targets.lint).toMatchObject({ executor: '@nx/eslint:lint', - options: { - lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'], - }, outputs: ['{options.outputFile}'], }); }); diff --git a/packages/react-native/src/utils/add-linting.ts b/packages/react-native/src/utils/add-linting.ts index 332a7293be..fba1629a83 100644 --- a/packages/react-native/src/utils/add-linting.ts +++ b/packages/react-native/src/utils/add-linting.ts @@ -31,7 +31,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { linter: options.linter, project: options.projectName, tsConfigPaths: options.tsConfigPaths, - eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`], skipFormat: true, skipPackageJson: options.skipPackageJson, }); diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index f9e20ce450..62f2519c16 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -472,9 +472,6 @@ describe('app', () => { expect(projectsConfigurations.get('my-app').targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-app/**/*.{ts,tsx,js,jsx}'], - }, }); }); @@ -495,11 +492,6 @@ describe('app', () => { .toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app/**/*.{ts,tsx,js,jsx}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/react/src/generators/application/application.ts b/packages/react/src/generators/application/application.ts index f637761975..d8a3809ce8 100644 --- a/packages/react/src/generators/application/application.ts +++ b/packages/react/src/generators/application/application.ts @@ -22,7 +22,6 @@ import { import reactInitGenerator from '../init/init'; import { Linter, lintProjectGenerator } from '@nx/eslint'; -import { mapLintPattern } from '@nx/eslint/src/generators/lint-project/lint-project'; import { babelLoaderVersion, nxRspackVersion, @@ -49,13 +48,6 @@ async function addLinting(host: Tree, options: NormalizedSchema) { joinPathFragments(options.appProjectRoot, 'tsconfig.app.json'), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [ - mapLintPattern( - options.appProjectRoot, - '{ts,tsx,js,jsx}', - options.rootProject - ), - ], skipFormat: true, rootProject: options.rootProject, skipPackageJson: options.skipPackageJson, diff --git a/packages/react/src/generators/component-story/component-story.spec.ts b/packages/react/src/generators/component-story/component-story.spec.ts index e3e8a83e66..4102c79ba6 100644 --- a/packages/react/src/generators/component-story/component-story.spec.ts +++ b/packages/react/src/generators/component-story/component-story.spec.ts @@ -539,7 +539,6 @@ export async function createTestUILib(libName: string): Promise { const currentWorkspaceJson = getProjects(appTree); const projectConfig = currentWorkspaceJson.get(libName); - projectConfig.targets.lint.options.linter = 'eslint'; updateProjectConfiguration(appTree, libName, projectConfig); diff --git a/packages/react/src/generators/library/lib/add-linting.ts b/packages/react/src/generators/library/lib/add-linting.ts index 610f83660a..c76352cf8f 100644 --- a/packages/react/src/generators/library/lib/add-linting.ts +++ b/packages/react/src/generators/library/lib/add-linting.ts @@ -19,7 +19,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { joinPathFragments(options.projectRoot, 'tsconfig.lib.json'), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`], skipFormat: true, skipPackageJson: options.skipPackageJson, setParserOptionsProject: options.setParserOptionsProject, diff --git a/packages/react/src/generators/library/library.spec.ts b/packages/react/src/generators/library/library.spec.ts index 3cf6bfe614..5ccdd0c5f1 100644 --- a/packages/react/src/generators/library/library.spec.ts +++ b/packages/react/src/generators/library/library.spec.ts @@ -55,9 +55,6 @@ describe('lib', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'], - }, }); }); @@ -319,9 +316,6 @@ describe('lib', () => { expect(config.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-dir/my-lib/**/*.{ts,tsx,js,jsx}'], - }, }); }); @@ -416,11 +410,6 @@ describe('lib', () => { expect(config.targets.lint).toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-lib/**/*.{ts,tsx,js,jsx}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap b/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap index 8174227b5c..78b81220c4 100644 --- a/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap +++ b/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap @@ -48,11 +48,6 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou }, "lint": { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "test-ui-lib/**/*.ts", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/storybook/src/utils/test-configs/different-target-variations.json b/packages/storybook/src/utils/test-configs/different-target-variations.json index 7b9cc716c3..76efa1b5b3 100644 --- a/packages/storybook/src/utils/test-configs/different-target-variations.json +++ b/packages/storybook/src/utils/test-configs/different-target-variations.json @@ -160,13 +160,7 @@ "defaultConfiguration": "production" }, "lint": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "libs/nglibuild/**/*.ts", - "libs/nglibuild/**/*.html" - ] - } + "executor": "@nx/eslint:lint" } }, "react-swc": { diff --git a/packages/storybook/src/utils/test-configs/executor-context.json b/packages/storybook/src/utils/test-configs/executor-context.json index 5514236236..de5002a971 100644 --- a/packages/storybook/src/utils/test-configs/executor-context.json +++ b/packages/storybook/src/utils/test-configs/executor-context.json @@ -85,11 +85,7 @@ "lint": { "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/main-webpack/**/*.{ts,tsx,js,jsx}"] - }, - "configurations": {} + "outputs": ["{options.outputFile}"] }, "test": { "inputs": [ diff --git a/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap b/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap index bfa3ba169f..c9c9c0fbc1 100644 --- a/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap +++ b/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap @@ -115,12 +115,7 @@ exports[`@nx/vite:configuration library mode should set up non buildable library "targets": { "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": [ - "libs/react-lib-nonb-jest/**/*.{ts,tsx,js,jsx}" - ] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", @@ -196,12 +191,7 @@ exports[`@nx/vite:configuration library mode should set up non buildable library "targets": { "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": [ - "libs/react-lib-nonb-vitest/**/*.{ts,tsx,js,jsx}" - ] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/vite:test", @@ -256,12 +246,7 @@ exports[`@nx/vite:configuration transform React app to use Vite by providing cus }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": [ - "apps/my-test-mixed-react-app/**/*.{ts,tsx,js,jsx}" - ] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", @@ -399,10 +384,7 @@ exports[`@nx/vite:configuration transform React app to use Vite should transform }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/my-test-react-app/**/*.{ts,tsx,js,jsx}"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", @@ -528,10 +510,7 @@ exports[`@nx/vite:configuration transform Web app to use Vite should transform w }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/my-test-web-app/**/*.ts"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", diff --git a/packages/vite/src/utils/test-files/react-lib-non-buildable-jest.json b/packages/vite/src/utils/test-files/react-lib-non-buildable-jest.json index bc0942d026..69bbdd0de5 100644 --- a/packages/vite/src/utils/test-files/react-lib-non-buildable-jest.json +++ b/packages/vite/src/utils/test-files/react-lib-non-buildable-jest.json @@ -7,10 +7,7 @@ "targets": { "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/react-lib-nonb-jest/**/*.{ts,tsx,js,jsx}"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", diff --git a/packages/vite/src/utils/test-files/react-lib-non-buildable-vitest.json b/packages/vite/src/utils/test-files/react-lib-non-buildable-vitest.json index a1c97c5174..bc610a9561 100644 --- a/packages/vite/src/utils/test-files/react-lib-non-buildable-vitest.json +++ b/packages/vite/src/utils/test-files/react-lib-non-buildable-vitest.json @@ -7,10 +7,7 @@ "targets": { "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/react-lib-nonb-vitest/**/*.{ts,tsx,js,jsx}"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/vite:test", diff --git a/packages/vite/src/utils/test-files/react-mixed-project.config.json b/packages/vite/src/utils/test-files/react-mixed-project.config.json index a5d4e375da..54d8a5b163 100644 --- a/packages/vite/src/utils/test-files/react-mixed-project.config.json +++ b/packages/vite/src/utils/test-files/react-mixed-project.config.json @@ -32,12 +32,7 @@ }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": [ - "apps/my-test-mixed-react-app/**/*.{ts,tsx,js,jsx}" - ] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", diff --git a/packages/vite/src/utils/test-files/react-project.config.json b/packages/vite/src/utils/test-files/react-project.config.json index bc64bab865..58a5a7aa0c 100644 --- a/packages/vite/src/utils/test-files/react-project.config.json +++ b/packages/vite/src/utils/test-files/react-project.config.json @@ -67,10 +67,7 @@ }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/my-test-react-app/**/*.{ts,tsx,js,jsx}"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", diff --git a/packages/vite/src/utils/test-files/react-vite-project.config.json b/packages/vite/src/utils/test-files/react-vite-project.config.json index 8bf59239cb..e3e7f1b093 100644 --- a/packages/vite/src/utils/test-files/react-vite-project.config.json +++ b/packages/vite/src/utils/test-files/react-vite-project.config.json @@ -47,10 +47,7 @@ }, "lint": { "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/my-test-react-vite-app/**/*.{ts,tsx,js,jsx}"] - } + "outputs": ["{options.outputFile}"] } }, "tags": [] diff --git a/packages/vite/src/utils/test-files/unknown-project.config.json b/packages/vite/src/utils/test-files/unknown-project.config.json index f87f53c378..84c3645470 100644 --- a/packages/vite/src/utils/test-files/unknown-project.config.json +++ b/packages/vite/src/utils/test-files/unknown-project.config.json @@ -55,10 +55,7 @@ }, "lint": { "executor": "@random/something:test", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/my-test-random-app/**/*.ts"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@random/something:test", diff --git a/packages/vite/src/utils/test-files/web-project.config.json b/packages/vite/src/utils/test-files/web-project.config.json index 0356aed565..88c114689c 100644 --- a/packages/vite/src/utils/test-files/web-project.config.json +++ b/packages/vite/src/utils/test-files/web-project.config.json @@ -55,10 +55,7 @@ }, "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/my-test-web-app/**/*.ts"] - } + "outputs": ["{options.outputFile}"] }, "test": { "executor": "@nx/jest:jest", diff --git a/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap index 2e704767b7..cdda91ef52 100644 --- a/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap @@ -86,10 +86,7 @@ exports[`application generator should set up project correctly with given option "targets": { "lint": { "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["test/**/*.{ts,tsx,js,jsx,vue}"] - } + "outputs": ["{options.outputFile}"] }, "build": { "executor": "@nx/vite:build", diff --git a/packages/vue/src/generators/library/library.spec.ts b/packages/vue/src/generators/library/library.spec.ts index 31285f9adc..f84d05ff30 100644 --- a/packages/vue/src/generators/library/library.spec.ts +++ b/packages/vue/src/generators/library/library.spec.ts @@ -44,9 +44,6 @@ describe('lib', () => { expect(project.targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx,vue}'], - }, }); }); @@ -205,13 +202,6 @@ describe('lib', () => { const config = readProjectConfiguration(tree, 'my-dir-my-lib'); expect(config.root).toEqual('my-dir/my-lib'); - expect(config.targets.lint).toEqual({ - executor: '@nx/eslint:lint', - outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-dir/my-lib/**/*.{ts,tsx,js,jsx,vue}'], - }, - }); }); it('should update root tsconfig.base.json', async () => { @@ -254,11 +244,6 @@ describe('lib', () => { expect(config.targets.lint).toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-lib/**/*.{ts,tsx,js,jsx,vue}", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/vue/src/generators/stories/lib/component-story.spec.ts b/packages/vue/src/generators/stories/lib/component-story.spec.ts index 69aab18659..e0a47ec445 100644 --- a/packages/vue/src/generators/stories/lib/component-story.spec.ts +++ b/packages/vue/src/generators/stories/lib/component-story.spec.ts @@ -123,7 +123,6 @@ export async function createTestUILib(libName: string): Promise { const currentWorkspaceJson = getProjects(appTree); const projectConfig = currentWorkspaceJson.get(libName); - projectConfig.targets.lint.options.linter = 'eslint'; updateProjectConfiguration(appTree, libName, projectConfig); diff --git a/packages/vue/src/utils/add-linting.ts b/packages/vue/src/utils/add-linting.ts index 48468ef087..5a0d675ab1 100644 --- a/packages/vue/src/utils/add-linting.ts +++ b/packages/vue/src/utils/add-linting.ts @@ -11,7 +11,6 @@ import { addExtendsToLintConfig, isEslintConfigSupported, } from '@nx/eslint/src/generators/utils/eslint-file'; -import { mapLintPattern } from '@nx/eslint/src/generators/lint-project/lint-project'; export async function addLinting( host: Tree, @@ -34,13 +33,6 @@ export async function addLinting( joinPathFragments(options.projectRoot, `tsconfig.${projectType}.json`), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [ - mapLintPattern( - options.projectRoot, - '{ts,tsx,js,jsx,vue}', - options.rootProject - ), - ], skipFormat: true, setParserOptionsProject: options.setParserOptionsProject, rootProject: options.rootProject, diff --git a/packages/web/src/generators/application/application.spec.ts b/packages/web/src/generators/application/application.spec.ts index 0eee66efae..6e8a854190 100644 --- a/packages/web/src/generators/application/application.spec.ts +++ b/packages/web/src/generators/application/application.spec.ts @@ -442,9 +442,6 @@ describe('app', () => { expect(readProjectConfiguration(tree, 'my-app').targets.lint).toEqual({ executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-app/**/*.ts'], - }, }); }); @@ -479,11 +476,6 @@ describe('app', () => { expect(projectConfiguration.targets.lint).toMatchInlineSnapshot(` { "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "my-app/**/*.ts", - ], - }, "outputs": [ "{options.outputFile}", ], diff --git a/packages/web/src/generators/application/application.ts b/packages/web/src/generators/application/application.ts index 0e51e2a8f9..df9b1e99b7 100644 --- a/packages/web/src/generators/application/application.ts +++ b/packages/web/src/generators/application/application.ts @@ -274,7 +274,6 @@ export async function applicationGeneratorInternal(host: Tree, schema: Schema) { joinPathFragments(options.appProjectRoot, 'tsconfig.app.json'), ], unitTestRunner: options.unitTestRunner, - eslintFilePatterns: [`${options.appProjectRoot}/**/*.ts`], skipFormat: true, setParserOptionsProject: options.setParserOptionsProject, }); diff --git a/packages/workspace/src/generators/move/lib/create-project-configuration-in-new-destination.spec.ts b/packages/workspace/src/generators/move/lib/create-project-configuration-in-new-destination.spec.ts index 87a560f9bc..5ab2e7ebd9 100644 --- a/packages/workspace/src/generators/move/lib/create-project-configuration-in-new-destination.spec.ts +++ b/packages/workspace/src/generators/move/lib/create-project-configuration-in-new-destination.spec.ts @@ -100,13 +100,6 @@ describe('moveProjectConfiguration', () => { }, lint: { executor: '@nx/eslint:lint', - options: { - lintFilePatterns: [ - '{projectRoot}/**/*.{ts,tsx,js,jsx}', - '{projectRoot}/**/*.{html,htm}', - '{projectRoot}/project.json', - ], - }, }, test: { executor: '@nx/jest:jest', @@ -141,13 +134,6 @@ describe('moveProjectConfiguration', () => { }, lint: { executor: '@nx/eslint:lint', - options: { - lintFilePatterns: [ - '{projectRoot}/**/*.{ts,tsx,js,jsx}', - '{projectRoot}/**/*.{html,htm}', - '{projectRoot}/project.json', - ], - }, }, }, }); diff --git a/packages/workspace/src/generators/move/move.spec.ts b/packages/workspace/src/generators/move/move.spec.ts index 668359e91a..b4ac408760 100644 --- a/packages/workspace/src/generators/move/move.spec.ts +++ b/packages/workspace/src/generators/move/move.spec.ts @@ -139,9 +139,6 @@ describe('move', () => { lint: { executor: '@nx/eslint:lint', outputs: ['{options.outputFile}'], - options: { - lintFilePatterns: ['my-lib/src/**/*.ts', 'my-lib/package.json'], - }, }, test: { executor: '@nx/jest:jest',