@code-pushup/eslint-plugin 0.53.0 → 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 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
@@ -16,7 +16,7 @@ var MAX_ISSUE_MESSAGE_LENGTH = 1024;
16
16
  var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
17
17
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
18
18
  function hasDuplicateStrings(strings) {
19
- const sortedStrings = [...strings].sort();
19
+ const sortedStrings = strings.toSorted();
20
20
  const duplStrings = sortedStrings.filter(
21
21
  (item, index) => index !== 0 && item === sortedStrings[index - 1]
22
22
  );
@@ -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().int().describe("Value change (`values.after - values.before`)")
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 = "";
@@ -1079,7 +1079,7 @@ function toAudit(slug, issues) {
1079
1079
  auditIssues.map(({ severity }) => severity)
1080
1080
  );
1081
1081
  const severities = objectToEntries(severityCounts);
1082
- const summaryText = [...severities].sort((a, b) => -compareIssueSeverity(a[0], b[0])).map(([severity, count = 0]) => pluralizeToken(severity, count)).join(", ");
1082
+ const summaryText = severities.toSorted((a, b) => -compareIssueSeverity(a[0], b[0])).map(([severity, count = 0]) => pluralizeToken(severity, count)).join(", ");
1083
1083
  return {
1084
1084
  slug,
1085
1085
  score: Number(auditIssues.length === 0),
@@ -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.53.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";
@@ -23,7 +23,7 @@ var MAX_ISSUE_MESSAGE_LENGTH = 1024;
23
23
  var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
24
24
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
25
25
  function hasDuplicateStrings(strings) {
26
- const sortedStrings = [...strings].sort();
26
+ const sortedStrings = strings.toSorted();
27
27
  const duplStrings = sortedStrings.filter(
28
28
  (item, index) => index !== 0 && item === sortedStrings[index - 1]
29
29
  );
@@ -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().int().describe("Value change (`values.after - values.before`)")
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(
@@ -1051,7 +1050,7 @@ function groupsFromRuleCategories(rules) {
1051
1050
  })
1052
1051
  )
1053
1052
  );
1054
- return [...groups].sort((a, b) => a.slug.localeCompare(b.slug));
1053
+ return groups.toSorted((a, b) => a.slug.localeCompare(b.slug));
1055
1054
  }
1056
1055
 
1057
1056
  // packages/plugin-eslint/src/lib/meta/transform.ts
@@ -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
- return nxProjectsToConfig(projectGraph);
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,35 +1,56 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.53.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
- "dependencies": {
7
- "@code-pushup/utils": "0.53.0",
8
- "@code-pushup/models": "0.53.0",
9
- "eslint": "^8.46.0",
10
- "zod": "^3.22.4"
11
- },
12
- "peerDependencies": {
13
- "@nx/devkit": "^17.0.0 || ^18.0.0 || ^19.0.0"
14
- },
15
- "peerDependenciesMeta": {
16
- "@nx/devkit": {
17
- "optional": true
18
- }
19
- },
20
6
  "homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-eslint#readme",
21
7
  "bugs": {
22
- "url": "https://github.com/code-pushup/cli/issues"
8
+ "url": "https://github.com/code-pushup/cli/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3A\"🧩%20eslint-plugin\""
23
9
  },
24
10
  "repository": {
25
11
  "type": "git",
26
12
  "url": "git+https://github.com/code-pushup/cli.git",
27
13
  "directory": "packages/plugin-eslint"
28
14
  },
15
+ "keywords": [
16
+ "CLI",
17
+ "Code PushUp",
18
+ "ESLint",
19
+ "JavaScript",
20
+ "TypeScript",
21
+ "plugin",
22
+ "static analysis",
23
+ "linting",
24
+ "audit",
25
+ "performance",
26
+ "score monitoring",
27
+ "code quality",
28
+ "conformance",
29
+ "KPI tracking",
30
+ "tech debt",
31
+ "automated feedback",
32
+ "regression guard",
33
+ "actionable feedback",
34
+ "trend analysis"
35
+ ],
29
36
  "publishConfig": {
30
37
  "access": "public"
31
38
  },
32
39
  "type": "module",
33
40
  "main": "./index.js",
34
- "types": "./src/index.d.ts"
35
- }
41
+ "types": "./src/index.d.ts",
42
+ "dependencies": {
43
+ "@code-pushup/utils": "0.54.0",
44
+ "@code-pushup/models": "0.54.0",
45
+ "eslint": "^8.46.0",
46
+ "zod": "^3.22.4"
47
+ },
48
+ "peerDependencies": {
49
+ "@nx/devkit": ">=17.0.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "@nx/devkit": {
53
+ "optional": true
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,2 @@
1
+ import type { ProjectGraph } from '@nx/devkit';
2
+ export declare function filterProjectGraph(projectGraph: ProjectGraph, exclude?: string[]): ProjectGraph;
@@ -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 include a subset of your Nx monorepo, refer to {@link eslintConfigFromNxProjectAndDeps} instead.
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(): Promise<ESLintTarget[]>;
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.