diff --git a/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.spec.ts b/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.spec.ts index 888ef94716..df0f326233 100644 --- a/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.spec.ts +++ b/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.spec.ts @@ -121,12 +121,12 @@ describe('Update eslint builder and config for 10.3.0', () => { "builder": "@nrwl/linter:eslint", "options": Object { "lintFilePatterns": Array [ - "apps/testProject/something-ad-hoc/**/*.ts", "apps/testProject/**/*.js", "apps/testProject/**/*.jsx", "apps/testProject/**/*.ts", "apps/testProject/**/*.tsx", "apps/testProject/some-random-relative-file.ts", + "apps/testProject/something-ad-hoc/**/*.ts", "apps/testProject/**/*.spec.ts", "apps/testProject/**/*.spec.tsx", "apps/testProject/**/*.spec.js", diff --git a/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.ts b/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.ts index 7b0642c4d4..77317ba21a 100644 --- a/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.ts +++ b/packages/linter/src/migrations/update-10-3-0/update-eslint-builder-and-config.ts @@ -21,25 +21,48 @@ function updateESLintBuilder(host: Tree) { const tsconfigs = []; - try { - tsconfigs.push(readJsonInTree(host, `${project.root}/tsconfig.json`)); - } catch {} - try { - tsconfigs.push(readJsonInTree(host, `${project.root}/tsconfig.app.json`)); - } catch {} - try { - tsconfigs.push(readJsonInTree(host, `${project.root}/tsconfig.lib.json`)); - } catch {} - try { - tsconfigs.push( - readJsonInTree(host, `${project.root}/tsconfig.spec.json`) - ); - } catch {} + if (options.tsConfig) { + const normalizedTsConfigOption = Array.isArray(options.tsConfig) + ? options.tsConfig + : [options.tsConfig]; + normalizedTsConfigOption.forEach((tsConfigPath) => { + try { + tsconfigs.push(readJsonInTree(host, tsConfigPath as string)); + } catch {} + try { + tsconfigs.push(readJsonInTree(host, `${project.root}/tsconfig.json`)); + } catch {} + }); + } else { + try { + tsconfigs.push(readJsonInTree(host, `${project.root}/tsconfig.json`)); + } catch {} + try { + tsconfigs.push( + readJsonInTree(host, `${project.root}/tsconfig.app.json`) + ); + } catch {} + try { + tsconfigs.push( + readJsonInTree(host, `${project.root}/tsconfig.lib.json`) + ); + } catch {} + try { + tsconfigs.push( + readJsonInTree(host, `${project.root}/tsconfig.spec.json`) + ); + } catch {} + try { + tsconfigs.push( + readJsonInTree(host, `${project.root}/tsconfig.e2e.json`) + ); + } catch {} + } const defaultLintFilePatterns = [`${project.root}/**/*.ts`]; // Merge any available `includes` and `files` from the tsconfig files - const lintFilePatterns = !tsconfigs.length + let lintFilePatterns = !tsconfigs.length ? defaultLintFilePatterns : tsconfigs .map((tsconfig) => { @@ -48,6 +71,8 @@ function updateESLintBuilder(host: Tree) { .reduce((flat, val) => flat.concat(val), []) .map((pattern) => join(normalize(project.root), pattern)); + lintFilePatterns = [...new Set(lintFilePatterns)]; + return { lintFilePatterns }; }, '@nrwl/linter:lint'); }