@code-pushup/eslint-plugin 0.53.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/bin.js +3 -5
- package/index.js +27 -5
- package/package.json +4 -4
- package/src/lib/nx/filter-project-graph.d.ts +2 -0
- package/src/lib/nx/find-all-projects.d.ts +10 -3
package/README.md
CHANGED
|
@@ -72,6 +72,12 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
|
|
|
72
72
|
};
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
You can also exclude specific projects if needed by passing their names in the `exclude` option:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
await eslintConfigFromAllNxProjects({ exclude: ['server'] });
|
|
79
|
+
```
|
|
80
|
+
|
|
75
81
|
- If you wish to target a specific project along with other projects it depends on, use the `eslintConfigFromNxProjectAndDeps` helper and pass in in your project name:
|
|
76
82
|
|
|
77
83
|
```js
|
package/bin.js
CHANGED
|
@@ -110,7 +110,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
110
110
|
message: `The filename has to be valid`
|
|
111
111
|
}).min(1, { message: "file name is invalid" });
|
|
112
112
|
var positiveIntSchema = z.number().int().positive();
|
|
113
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
114
113
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
115
114
|
function packageVersionSchema(options) {
|
|
116
115
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -654,7 +653,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
654
653
|
z16.object({
|
|
655
654
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
656
655
|
z16.object({
|
|
657
|
-
diff: z16.number().
|
|
656
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
658
657
|
})
|
|
659
658
|
).describe("Audit `value` comparison"),
|
|
660
659
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -747,6 +746,7 @@ function executeProcess(cfg) {
|
|
|
747
746
|
return new Promise((resolve, reject) => {
|
|
748
747
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
749
748
|
shell: true,
|
|
749
|
+
windowsHide: true,
|
|
750
750
|
...options
|
|
751
751
|
});
|
|
752
752
|
let stdout = "";
|
|
@@ -1129,9 +1129,7 @@ var PLUGIN_CONFIG_PATH = join3(
|
|
|
1129
1129
|
"plugin-config.json"
|
|
1130
1130
|
);
|
|
1131
1131
|
async function executeRunner() {
|
|
1132
|
-
const { slugs, targets } = await readJsonFile(
|
|
1133
|
-
PLUGIN_CONFIG_PATH
|
|
1134
|
-
);
|
|
1132
|
+
const { slugs, targets } = await readJsonFile(PLUGIN_CONFIG_PATH);
|
|
1135
1133
|
const linterOutputs = await targets.reduce(
|
|
1136
1134
|
async (acc, target) => [...await acc, await lint(target)],
|
|
1137
1135
|
Promise.resolve([])
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
|
|
5
5
|
// packages/plugin-eslint/package.json
|
|
6
6
|
var name = "@code-pushup/eslint-plugin";
|
|
7
|
-
var version = "0.
|
|
7
|
+
var version = "0.54.0";
|
|
8
8
|
|
|
9
9
|
// packages/plugin-eslint/src/lib/config.ts
|
|
10
10
|
import { z as z17 } from "zod";
|
|
@@ -117,7 +117,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
|
|
|
117
117
|
message: `The filename has to be valid`
|
|
118
118
|
}).min(1, { message: "file name is invalid" });
|
|
119
119
|
var positiveIntSchema = z.number().int().positive();
|
|
120
|
-
var nonnegativeIntSchema = z.number().int().nonnegative();
|
|
121
120
|
var nonnegativeNumberSchema = z.number().nonnegative();
|
|
122
121
|
function packageVersionSchema(options) {
|
|
123
122
|
const { versionDescription = "NPM version of the package", required } = options ?? {};
|
|
@@ -661,7 +660,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
661
660
|
z16.object({
|
|
662
661
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
663
662
|
z16.object({
|
|
664
|
-
diff: z16.number().
|
|
663
|
+
diff: z16.number().describe("Value change (`values.after - values.before`)")
|
|
665
664
|
})
|
|
666
665
|
).describe("Audit `value` comparison"),
|
|
667
666
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -1133,6 +1132,25 @@ async function eslintPlugin(config) {
|
|
|
1133
1132
|
};
|
|
1134
1133
|
}
|
|
1135
1134
|
|
|
1135
|
+
// packages/plugin-eslint/src/lib/nx/filter-project-graph.ts
|
|
1136
|
+
function filterProjectGraph(projectGraph, exclude = []) {
|
|
1137
|
+
const filteredNodes = Object.entries(
|
|
1138
|
+
projectGraph.nodes
|
|
1139
|
+
).reduce(
|
|
1140
|
+
(acc, [projectName, projectNode]) => exclude.includes(projectName) ? acc : { ...acc, [projectName]: projectNode },
|
|
1141
|
+
{}
|
|
1142
|
+
);
|
|
1143
|
+
const filteredDependencies = Object.entries(projectGraph.dependencies).reduce(
|
|
1144
|
+
(acc, [key, deps]) => exclude.includes(key) ? acc : { ...acc, [key]: deps },
|
|
1145
|
+
{}
|
|
1146
|
+
);
|
|
1147
|
+
return {
|
|
1148
|
+
nodes: filteredNodes,
|
|
1149
|
+
dependencies: filteredDependencies,
|
|
1150
|
+
version: projectGraph.version
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1136
1154
|
// packages/plugin-eslint/src/lib/nx/utils.ts
|
|
1137
1155
|
import { join as join4 } from "node:path";
|
|
1138
1156
|
async function findCodePushupEslintrc(project) {
|
|
@@ -1184,10 +1202,14 @@ async function nxProjectsToConfig(projectGraph, predicate = () => true) {
|
|
|
1184
1202
|
}
|
|
1185
1203
|
|
|
1186
1204
|
// packages/plugin-eslint/src/lib/nx/find-all-projects.ts
|
|
1187
|
-
async function eslintConfigFromAllNxProjects() {
|
|
1205
|
+
async function eslintConfigFromAllNxProjects(options = {}) {
|
|
1188
1206
|
const { createProjectGraphAsync } = await import("@nx/devkit");
|
|
1189
1207
|
const projectGraph = await createProjectGraphAsync({ exitOnError: false });
|
|
1190
|
-
|
|
1208
|
+
const filteredProjectGraph = filterProjectGraph(
|
|
1209
|
+
projectGraph,
|
|
1210
|
+
options.exclude
|
|
1211
|
+
);
|
|
1212
|
+
return nxProjectsToConfig(filteredProjectGraph);
|
|
1191
1213
|
}
|
|
1192
1214
|
var eslintConfigFromNxProjects = eslintConfigFromAllNxProjects;
|
|
1193
1215
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Code PushUp plugin for detecting problems in source code using ESLint.📋",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-eslint#readme",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"main": "./index.js",
|
|
41
41
|
"types": "./src/index.d.ts",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@code-pushup/utils": "0.
|
|
44
|
-
"@code-pushup/models": "0.
|
|
43
|
+
"@code-pushup/utils": "0.54.0",
|
|
44
|
+
"@code-pushup/models": "0.54.0",
|
|
45
45
|
"eslint": "^8.46.0",
|
|
46
46
|
"zod": "^3.22.4"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@nx/devkit": "
|
|
49
|
+
"@nx/devkit": ">=17.0.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@nx/devkit": {
|
|
@@ -2,8 +2,11 @@ import type { ESLintTarget } from '../config';
|
|
|
2
2
|
/**
|
|
3
3
|
* Finds all Nx projects in workspace and converts their lint configurations to Code PushUp ESLint plugin parameters.
|
|
4
4
|
*
|
|
5
|
+
* Allows excluding certain projects from the configuration using the `options.exclude` parameter.
|
|
6
|
+
*
|
|
5
7
|
* Use when you wish to automatically include every Nx project in a single Code PushUp project.
|
|
6
|
-
* If you prefer to only
|
|
8
|
+
* If you prefer to include only a subset of your Nx monorepo, specify projects to exclude using the `exclude` option
|
|
9
|
+
* or consider using {@link eslintConfigFromNxProjectAndDeps} for finer control.
|
|
7
10
|
*
|
|
8
11
|
* @example
|
|
9
12
|
* import eslintPlugin, {
|
|
@@ -13,14 +16,18 @@ import type { ESLintTarget } from '../config';
|
|
|
13
16
|
* export default {
|
|
14
17
|
* plugins: [
|
|
15
18
|
* await eslintPlugin(
|
|
16
|
-
* await eslintConfigFromAllNxProjects()
|
|
19
|
+
* await eslintConfigFromAllNxProjects({ exclude: ['server'] })
|
|
17
20
|
* )
|
|
18
21
|
* ]
|
|
19
22
|
* }
|
|
20
23
|
*
|
|
24
|
+
* @param options - Configuration options to filter projects
|
|
25
|
+
* @param options.exclude - Array of project names to exclude from the ESLint configuration
|
|
21
26
|
* @returns ESLint config and patterns, intended to be passed to {@link eslintPlugin}
|
|
22
27
|
*/
|
|
23
|
-
export declare function eslintConfigFromAllNxProjects(
|
|
28
|
+
export declare function eslintConfigFromAllNxProjects(options?: {
|
|
29
|
+
exclude?: string[];
|
|
30
|
+
}): Promise<ESLintTarget[]>;
|
|
24
31
|
/**
|
|
25
32
|
* @deprecated
|
|
26
33
|
* Helper is renamed, please use `eslintConfigFromAllNxProjects` function instead.
|