diff --git a/.gitignore b/.gitignore index 4284058f4..74249bfff 100644 --- a/.gitignore +++ b/.gitignore @@ -43,8 +43,11 @@ testem.log .DS_Store Thumbs.db +# generated eslint reports +.eslint + # generated Code PushUp reports -/.code-pushup +.code-pushup # Nx workspace cache .nx diff --git a/code-pushup.preset.ts b/code-pushup.preset.ts index af7633ea9..0b033bcd8 100644 --- a/code-pushup.preset.ts +++ b/code-pushup.preset.ts @@ -7,9 +7,10 @@ import coveragePlugin, { getNxCoveragePaths, } from './packages/plugin-coverage/src/index.js'; import eslintPlugin, { - eslintConfigFromAllNxProjects, eslintConfigFromNxProject, } from './packages/plugin-eslint/src/index.js'; +import type { ESLintTarget } from './packages/plugin-eslint/src/lib/config.js'; +import { nxProjectsToConfig } from './packages/plugin-eslint/src/lib/nx/projects-to-config.js'; import jsPackagesPlugin from './packages/plugin-js-packages/src/index.js'; import jsDocsPlugin from './packages/plugin-jsdocs/src/index.js'; import type { JsDocsPluginTransformedConfig } from './packages/plugin-jsdocs/src/lib/config.js'; @@ -156,6 +157,17 @@ export const jsDocsCoreConfig = ( ), }); +export async function eslintConfigFromPublishableNxProjects(): Promise< + ESLintTarget[] +> { + const { createProjectGraphAsync } = await import('@nx/devkit'); + const projectGraph = await createProjectGraphAsync({ exitOnError: false }); + return nxProjectsToConfig( + projectGraph, + project => project.tags?.includes('publishable') ?? false, + ); +} + export const eslintCoreConfigNx = async ( projectName?: string, ): Promise => ({ @@ -163,7 +175,7 @@ export const eslintCoreConfigNx = async ( await eslintPlugin( await (projectName ? eslintConfigFromNxProject(projectName) - : eslintConfigFromAllNxProjects()), + : eslintConfigFromPublishableNxProjects()), ), ], categories: eslintCategories, diff --git a/nx.json b/nx.json index 99e48af53..54340c1d9 100644 --- a/nx.json +++ b/nx.json @@ -46,9 +46,9 @@ "lint": { "inputs": ["default", "{workspaceRoot}/eslint.config.?(c)js"], "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], "cache": true, "options": { + "errorOnUnmatchedPattern": false, "maxWarnings": 0, "lintFilePatterns": [ "{projectRoot}/**/*.ts", @@ -56,6 +56,22 @@ ] } }, + "lint-report": { + "inputs": ["default", "{workspaceRoot}/eslint.config.?(c)js"], + "outputs": ["{projectRoot}/.eslint/eslint-report*.json"], + "cache": true, + "executor": "@nx/linter:eslint", + "options": { + "errorOnUnmatchedPattern": false, + "maxWarnings": 0, + "format": "json", + "outputFile": "{projectRoot}/.eslint/eslint-report.json", + "lintFilePatterns": [ + "{projectRoot}/**/*.ts", + "{projectRoot}/package.json" + ] + } + }, "nxv-pkg-install": { "parallelism": false }, diff --git a/packages/ci/project.json b/packages/ci/project.json index 9215f87b3..b6bdeab2c 100644 --- a/packages/ci/project.json +++ b/packages/ci/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} }, diff --git a/packages/cli/project.json b/packages/cli/project.json index bc3b384a7..733186813 100644 --- a/packages/cli/project.json +++ b/packages/cli/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {}, "run-help": { diff --git a/packages/core/project.json b/packages/core/project.json index 4924717c5..75fc9f380 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} }, diff --git a/packages/create-cli/project.json b/packages/create-cli/project.json index c2bc6ef60..813f42b91 100644 --- a/packages/create-cli/project.json +++ b/packages/create-cli/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "exec-node": { "dependsOn": ["build"], diff --git a/packages/models/project.json b/packages/models/project.json index 15981781f..58a71cd27 100644 --- a/packages/models/project.json +++ b/packages/models/project.json @@ -18,6 +18,7 @@ ] }, "lint": {}, + "lint-report": {}, "unit-test": {} }, "tags": ["scope:shared", "type:util", "publishable"] diff --git a/packages/nx-plugin/project.json b/packages/nx-plugin/project.json index 52c8f2290..63e15c1d4 100644 --- a/packages/nx-plugin/project.json +++ b/packages/nx-plugin/project.json @@ -41,6 +41,15 @@ ] } }, + "lint-report": { + "options": { + "lintFilePatterns": [ + "packages/nx-plugin/**/*.ts", + "packages/nx-plugin/package.json", + "packages/nx-plugin/generators.json" + ] + } + }, "unit-test": {}, "int-test": {} }, diff --git a/packages/plugin-coverage/project.json b/packages/plugin-coverage/project.json index edb62346f..031d65697 100644 --- a/packages/plugin-coverage/project.json +++ b/packages/plugin-coverage/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} }, diff --git a/packages/plugin-eslint/project.json b/packages/plugin-eslint/project.json index 241101850..eeae19055 100644 --- a/packages/plugin-eslint/project.json +++ b/packages/plugin-eslint/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} }, diff --git a/packages/plugin-js-packages/project.json b/packages/plugin-js-packages/project.json index 9f0dc7789..63782308a 100644 --- a/packages/plugin-js-packages/project.json +++ b/packages/plugin-js-packages/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} }, diff --git a/packages/plugin-jsdocs/project.json b/packages/plugin-jsdocs/project.json index 745540438..9f07a4761 100644 --- a/packages/plugin-jsdocs/project.json +++ b/packages/plugin-jsdocs/project.json @@ -7,6 +7,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} } diff --git a/packages/plugin-lighthouse/project.json b/packages/plugin-lighthouse/project.json index b93152ffb..468165a9c 100644 --- a/packages/plugin-lighthouse/project.json +++ b/packages/plugin-lighthouse/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {} }, "tags": ["scope:plugin", "type:feature", "publishable"] diff --git a/packages/plugin-typescript/project.json b/packages/plugin-typescript/project.json index 645259554..de10ea00e 100644 --- a/packages/plugin-typescript/project.json +++ b/packages/plugin-typescript/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "unit-test": {}, "int-test": {} }, diff --git a/packages/utils/project.json b/packages/utils/project.json index 021205deb..2953464ca 100644 --- a/packages/utils/project.json +++ b/packages/utils/project.json @@ -6,6 +6,7 @@ "targets": { "build": {}, "lint": {}, + "lint-report": {}, "perf": { "command": "npx tsx --tsconfig=../tsconfig.perf.json", "options": {