@code-pushup/eslint-plugin 0.42.1 → 0.44.1

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
@@ -59,28 +59,28 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
59
59
 
60
60
  If you're using an Nx monorepo, additional helper functions are provided to simplify your configuration:
61
61
 
62
- - If you wish to combine all projects in your workspace into one report, use the `eslintConfigFromNxProjects` helper:
62
+ - If you wish to combine all projects in your workspace into one report, use the `eslintConfigFromAllNxProjects` helper:
63
63
 
64
64
  ```js
65
- import eslintPlugin, { eslintConfigFromNxProjects } from '@code-pushup/eslint-plugin';
65
+ import eslintPlugin, { eslintConfigFromAllNxProjects } from '@code-pushup/eslint-plugin';
66
66
 
67
67
  export default {
68
68
  plugins: [
69
69
  // ...
70
- await eslintPlugin(await eslintConfigFromNxProjects()),
70
+ await eslintPlugin(await eslintConfigFromAllNxProjects()),
71
71
  ],
72
72
  };
73
73
  ```
74
74
 
75
- - If you wish to target a specific project along with other projects it depends on, use the `eslintConfigFromNxProject` helper and pass in in your project name:
75
+ - 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
76
 
77
77
  ```js
78
- import eslintPlugin, { eslintConfigFromNxProject } from '@code-pushup/eslint-plugin';
78
+ import eslintPlugin, { eslintConfigFromNxProjectAndDeps } from '@code-pushup/eslint-plugin';
79
79
 
80
80
  export default {
81
81
  plugins: [
82
82
  // ...
83
- await eslintPlugin(await eslintConfigFromNxProject('<PROJECT-NAME>')),
83
+ await eslintPlugin(await eslintConfigFromNxProjectAndDeps('<PROJECT-NAME>')),
84
84
  ],
85
85
  };
86
86
  ```
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.42.1";
7
+ var version = "0.44.1";
8
8
 
9
9
  // packages/plugin-eslint/src/lib/config.ts
10
10
  import { z as z16 } from "zod";
@@ -1427,11 +1427,26 @@ async function nxProjectsToConfig(projectGraph, predicate = () => true) {
1427
1427
  }
1428
1428
 
1429
1429
  // packages/plugin-eslint/src/lib/nx/find-all-projects.ts
1430
- async function eslintConfigFromNxProjects() {
1430
+ async function eslintConfigFromAllNxProjects() {
1431
1431
  const { createProjectGraphAsync } = await import("@nx/devkit");
1432
1432
  const projectGraph = await createProjectGraphAsync({ exitOnError: false });
1433
1433
  return nxProjectsToConfig(projectGraph);
1434
1434
  }
1435
+ var eslintConfigFromNxProjects = eslintConfigFromAllNxProjects;
1436
+
1437
+ // packages/plugin-eslint/src/lib/nx/find-project-without-deps.ts
1438
+ async function eslintConfigFromNxProject(projectName) {
1439
+ const { createProjectGraphAsync } = await import("@nx/devkit");
1440
+ const projectGraph = await createProjectGraphAsync({ exitOnError: false });
1441
+ const [project] = await nxProjectsToConfig(
1442
+ projectGraph,
1443
+ ({ name: name2 }) => !!name2 && name2 === projectName
1444
+ );
1445
+ if (!project) {
1446
+ throw new Error(`Couldn't find Nx project named "${projectName}"`);
1447
+ }
1448
+ return project;
1449
+ }
1435
1450
 
1436
1451
  // packages/plugin-eslint/src/lib/nx/traverse-graph.ts
1437
1452
  function findAllDependencies(entry, projectGraph) {
@@ -1451,7 +1466,7 @@ function findAllDependencies(entry, projectGraph) {
1451
1466
  }
1452
1467
 
1453
1468
  // packages/plugin-eslint/src/lib/nx/find-project-with-deps.ts
1454
- async function eslintConfigFromNxProject(projectName) {
1469
+ async function eslintConfigFromNxProjectAndDeps(projectName) {
1455
1470
  const { createProjectGraphAsync } = await import("@nx/devkit");
1456
1471
  const projectGraph = await createProjectGraphAsync({ exitOnError: false });
1457
1472
  const dependencies = findAllDependencies(projectName, projectGraph);
@@ -1465,6 +1480,8 @@ async function eslintConfigFromNxProject(projectName) {
1465
1480
  var src_default = eslintPlugin;
1466
1481
  export {
1467
1482
  src_default as default,
1483
+ eslintConfigFromAllNxProjects,
1468
1484
  eslintConfigFromNxProject,
1485
+ eslintConfigFromNxProjectAndDeps,
1469
1486
  eslintConfigFromNxProjects
1470
1487
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.42.1",
3
+ "version": "0.44.1",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@code-pushup/utils": "0.42.1",
7
- "@code-pushup/models": "0.42.1",
6
+ "@code-pushup/utils": "0.44.1",
7
+ "@code-pushup/models": "0.44.1",
8
8
  "eslint": "^8.46.0",
9
9
  "zod": "^3.22.4"
10
10
  },
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { eslintPlugin } from './lib/eslint-plugin';
2
2
  export default eslintPlugin;
3
3
  export type { ESLintPluginConfig } from './lib/config';
4
- export { eslintConfigFromNxProject, eslintConfigFromNxProjects, } from './lib/nx';
4
+ export { eslintConfigFromNxProjectAndDeps, eslintConfigFromNxProjects, eslintConfigFromAllNxProjects, eslintConfigFromNxProject, } from './lib/nx';
@@ -3,21 +3,26 @@ import type { ESLintTarget } from '../config';
3
3
  * Finds all Nx projects in workspace and converts their lint configurations to Code PushUp ESLint plugin parameters.
4
4
  *
5
5
  * 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 eslintConfigFromNxProject} instead.
6
+ * If you prefer to only include a subset of your Nx monorepo, refer to {@link eslintConfigFromNxProjectAndDeps} instead.
7
7
  *
8
8
  * @example
9
9
  * import eslintPlugin, {
10
- * eslintConfigFromNxProjects,
10
+ * eslintConfigFromAllNxProjects,
11
11
  * } from '@code-pushup/eslint-plugin';
12
12
  *
13
13
  * export default {
14
14
  * plugins: [
15
15
  * await eslintPlugin(
16
- * await eslintConfigFromNxProjects()
16
+ * await eslintConfigFromAllNxProjects()
17
17
  * )
18
18
  * ]
19
19
  * }
20
20
  *
21
21
  * @returns ESLint config and patterns, intended to be passed to {@link eslintPlugin}
22
22
  */
23
- export declare function eslintConfigFromNxProjects(): Promise<ESLintTarget[]>;
23
+ export declare function eslintConfigFromAllNxProjects(): Promise<ESLintTarget[]>;
24
+ /**
25
+ * @deprecated
26
+ * Helper is renamed, please use `eslintConfigFromAllNxProjects` function instead.
27
+ */
28
+ export declare const eslintConfigFromNxProjects: typeof eslintConfigFromAllNxProjects;
@@ -2,12 +2,13 @@ import type { ESLintTarget } from '../config';
2
2
  /**
3
3
  * Accepts a target Nx projects, finds projects it depends on, and converts lint configurations to Code PushUp ESLint plugin parameters.
4
4
  *
5
- * Use when you wish to include a targetted subset of your Nx monorepo in your Code PushUp project.
6
- * If you prefer to include all Nx projects, refer to {@link eslintConfigFromNxProjects} instead.
5
+ * Use when you wish to include a targeted subset of your Nx monorepo in your Code PushUp project.
6
+ * If you prefer to include all Nx projects, refer to {@link eslintConfigFromAllNxProjects} instead.
7
+ * if you'd like to skip dependencies of the provided target project use {@link eslintConfigFromNxProject} instead.
7
8
  *
8
9
  * @example
9
10
  * import eslintPlugin, {
10
- * eslintConfigFromNxProject,
11
+ * eslintConfigFromNxProjectAndDeps,
11
12
  * } from '@code-pushup/eslint-plugin';
12
13
  *
13
14
  * const projectName = 'backoffice'; // <-- name from project.json
@@ -15,7 +16,7 @@ import type { ESLintTarget } from '../config';
15
16
  * export default {
16
17
  * plugins: [
17
18
  * await eslintPlugin(
18
- * await eslintConfigFromNxProject(projectName)
19
+ * await eslintConfigFromNxProjectAndDeps(projectName)
19
20
  * )
20
21
  * ]
21
22
  * }
@@ -23,4 +24,4 @@ import type { ESLintTarget } from '../config';
23
24
  * @param projectName Nx project serving as main entry point
24
25
  * @returns ESLint config and patterns, intended to be passed to {@link eslintPlugin}
25
26
  */
26
- export declare function eslintConfigFromNxProject(projectName: string): Promise<ESLintTarget[]>;
27
+ export declare function eslintConfigFromNxProjectAndDeps(projectName: string): Promise<ESLintTarget[]>;
@@ -0,0 +1,27 @@
1
+ import type { ESLintTarget } from '../config';
2
+ /**
3
+ * Accepts a target Nx project, converts its lint configuration to Code PushUp ESLint plugin parameters.
4
+ *
5
+ * Use when you wish to only have a single Nx project as your Code PushUp project, without any other dependencies.
6
+ * If you prefer to include all Nx projects, refer to {@link eslintConfigFromAllNxProjects} instead.
7
+ * If you'd like to auto include all dependencies of the provided target project use {@link eslintConfigFromNxProjectAndDeps} instead.
8
+ *
9
+ * @example
10
+ * import eslintPlugin, {
11
+ * eslintConfigFromNxProject,
12
+ * } from '@code-pushup/eslint-plugin';
13
+ *
14
+ * const projectName = 'backoffice'; // <-- name from project.json
15
+ *
16
+ * export default {
17
+ * plugins: [
18
+ * await eslintPlugin(
19
+ * await eslintConfigFromNxProject(projectName)
20
+ * )
21
+ * ]
22
+ * }
23
+ *
24
+ * @param projectName Nx project name
25
+ * @returns ESLint config and patterns, intended to be passed to {@link eslintPlugin}
26
+ */
27
+ export declare function eslintConfigFromNxProject(projectName: string): Promise<ESLintTarget>;
@@ -1,2 +1,3 @@
1
- export { eslintConfigFromNxProjects } from './find-all-projects';
2
- export { eslintConfigFromNxProject } from './find-project-with-deps';
1
+ export { eslintConfigFromNxProjects, eslintConfigFromAllNxProjects, } from './find-all-projects';
2
+ export { eslintConfigFromNxProject } from './find-project-without-deps';
3
+ export { eslintConfigFromNxProjectAndDeps } from './find-project-with-deps';