@code-pushup/eslint-plugin 0.42.1 → 0.44.2
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 +8 -8
- package/bin.js +8 -5
- package/index.js +44 -19
- package/package.json +3 -3
- package/src/index.d.ts +1 -1
- package/src/lib/config.d.ts +36 -18
- package/src/lib/nx/find-all-projects.d.ts +9 -4
- package/src/lib/nx/find-project-with-deps.d.ts +6 -5
- package/src/lib/nx/find-project-without-deps.d.ts +27 -0
- package/src/lib/nx/index.d.ts +3 -2
- package/src/lib/nx/utils.d.ts +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
|
|
|
43
43
|
|
|
44
44
|
4. Add this plugin to the `plugins` array in your Code PushUp CLI config file (e.g. `code-pushup.config.js`).
|
|
45
45
|
|
|
46
|
-
Pass in the
|
|
46
|
+
Pass in the glob patterns for which files you wish to target (relative to `process.cwd()`).
|
|
47
47
|
|
|
48
48
|
```js
|
|
49
49
|
import eslintPlugin from '@code-pushup/eslint-plugin';
|
|
@@ -52,35 +52,35 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
|
|
|
52
52
|
// ...
|
|
53
53
|
plugins: [
|
|
54
54
|
// ...
|
|
55
|
-
await eslintPlugin(
|
|
55
|
+
await eslintPlugin(['src/**/*.js']),
|
|
56
56
|
],
|
|
57
57
|
};
|
|
58
58
|
```
|
|
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 `
|
|
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, {
|
|
65
|
+
import eslintPlugin, { eslintConfigFromAllNxProjects } from '@code-pushup/eslint-plugin';
|
|
66
66
|
|
|
67
67
|
export default {
|
|
68
68
|
plugins: [
|
|
69
69
|
// ...
|
|
70
|
-
await eslintPlugin(await
|
|
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 `
|
|
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, {
|
|
78
|
+
import eslintPlugin, { eslintConfigFromNxProjectAndDeps } from '@code-pushup/eslint-plugin';
|
|
79
79
|
|
|
80
80
|
export default {
|
|
81
81
|
plugins: [
|
|
82
82
|
// ...
|
|
83
|
-
await eslintPlugin(await
|
|
83
|
+
await eslintPlugin(await eslintConfigFromNxProjectAndDeps('<PROJECT-NAME>')),
|
|
84
84
|
],
|
|
85
85
|
};
|
|
86
86
|
```
|
package/bin.js
CHANGED
|
@@ -1185,8 +1185,11 @@ import { join as join2 } from "node:path";
|
|
|
1185
1185
|
import { ESLint } from "eslint";
|
|
1186
1186
|
function setupESLint(eslintrc) {
|
|
1187
1187
|
return new ESLint({
|
|
1188
|
-
...typeof eslintrc === "string"
|
|
1189
|
-
|
|
1188
|
+
...typeof eslintrc === "string" && { overrideConfigFile: eslintrc },
|
|
1189
|
+
...typeof eslintrc === "object" && {
|
|
1190
|
+
baseConfig: eslintrc,
|
|
1191
|
+
useEslintrc: false
|
|
1192
|
+
},
|
|
1190
1193
|
errorOnUnmatchedPattern: false
|
|
1191
1194
|
});
|
|
1192
1195
|
}
|
|
@@ -1209,8 +1212,8 @@ function executeLint({
|
|
|
1209
1212
|
command: "npx",
|
|
1210
1213
|
args: [
|
|
1211
1214
|
"eslint",
|
|
1212
|
-
`--config=${configPath}
|
|
1213
|
-
"--no-eslintrc",
|
|
1215
|
+
...configPath ? [`--config=${configPath}`] : [],
|
|
1216
|
+
...typeof eslintrc === "object" ? ["--no-eslintrc"] : [],
|
|
1214
1217
|
"--no-error-on-unmatched-pattern",
|
|
1215
1218
|
"--format=json",
|
|
1216
1219
|
...toArray(patterns).map(
|
|
@@ -1252,7 +1255,7 @@ function loadRuleOptionsPerFile(eslintrc, results) {
|
|
|
1252
1255
|
}, Promise.resolve({}));
|
|
1253
1256
|
}
|
|
1254
1257
|
async function withConfig(eslintrc, fn) {
|
|
1255
|
-
if (typeof eslintrc
|
|
1258
|
+
if (typeof eslintrc !== "object") {
|
|
1256
1259
|
return fn(eslintrc);
|
|
1257
1260
|
}
|
|
1258
1261
|
const configPath = generateTempConfigPath();
|
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.44.2";
|
|
8
8
|
|
|
9
9
|
// packages/plugin-eslint/src/lib/config.ts
|
|
10
10
|
import { z as z16 } from "zod";
|
|
@@ -1107,20 +1107,25 @@ var { details: details3 } = html;
|
|
|
1107
1107
|
import chalk4 from "chalk";
|
|
1108
1108
|
|
|
1109
1109
|
// packages/plugin-eslint/src/lib/config.ts
|
|
1110
|
-
var
|
|
1111
|
-
|
|
1112
|
-
[
|
|
1113
|
-
z16.string({ description: "Path to ESLint config file" }),
|
|
1114
|
-
z16.record(z16.string(), z16.unknown(), {
|
|
1115
|
-
description: "ESLint config object"
|
|
1116
|
-
})
|
|
1117
|
-
],
|
|
1118
|
-
{ description: "ESLint config as file path or inline object" }
|
|
1119
|
-
),
|
|
1120
|
-
patterns: z16.union([z16.string(), z16.array(z16.string()).min(1)], {
|
|
1121
|
-
description: "Lint target files. May contain file paths, directory paths or glob patterns"
|
|
1122
|
-
})
|
|
1110
|
+
var patternsSchema = z16.union([z16.string(), z16.array(z16.string()).min(1)], {
|
|
1111
|
+
description: "Lint target files. May contain file paths, directory paths or glob patterns"
|
|
1123
1112
|
});
|
|
1113
|
+
var eslintrcSchema = z16.union(
|
|
1114
|
+
[
|
|
1115
|
+
z16.string({ description: "Path to ESLint config file" }),
|
|
1116
|
+
z16.record(z16.string(), z16.unknown(), {
|
|
1117
|
+
description: "ESLint config object"
|
|
1118
|
+
})
|
|
1119
|
+
],
|
|
1120
|
+
{ description: "ESLint config as file path or inline object" }
|
|
1121
|
+
);
|
|
1122
|
+
var eslintTargetObjectSchema = z16.object({
|
|
1123
|
+
eslintrc: eslintrcSchema.optional(),
|
|
1124
|
+
patterns: patternsSchema
|
|
1125
|
+
});
|
|
1126
|
+
var eslintTargetSchema = z16.union([patternsSchema, eslintTargetObjectSchema]).transform(
|
|
1127
|
+
(target) => typeof target === "string" || Array.isArray(target) ? { patterns: target } : target
|
|
1128
|
+
);
|
|
1124
1129
|
var eslintPluginConfigSchema = z16.union([eslintTargetSchema, z16.array(eslintTargetSchema).min(1)]).transform(toArray);
|
|
1125
1130
|
|
|
1126
1131
|
// packages/plugin-eslint/src/lib/meta/hash.ts
|
|
@@ -1140,8 +1145,11 @@ function jsonHash(data, bytes = 8) {
|
|
|
1140
1145
|
import { ESLint } from "eslint";
|
|
1141
1146
|
function setupESLint(eslintrc) {
|
|
1142
1147
|
return new ESLint({
|
|
1143
|
-
...typeof eslintrc === "string"
|
|
1144
|
-
|
|
1148
|
+
...typeof eslintrc === "string" && { overrideConfigFile: eslintrc },
|
|
1149
|
+
...typeof eslintrc === "object" && {
|
|
1150
|
+
baseConfig: eslintrc,
|
|
1151
|
+
useEslintrc: false
|
|
1152
|
+
},
|
|
1145
1153
|
errorOnUnmatchedPattern: false
|
|
1146
1154
|
});
|
|
1147
1155
|
}
|
|
@@ -1395,7 +1403,7 @@ function getLintFilePatterns(project) {
|
|
|
1395
1403
|
}
|
|
1396
1404
|
function getEslintConfig(project) {
|
|
1397
1405
|
const options = project.targets?.["lint"]?.options;
|
|
1398
|
-
return options?.eslintConfig
|
|
1406
|
+
return options?.eslintConfig;
|
|
1399
1407
|
}
|
|
1400
1408
|
|
|
1401
1409
|
// packages/plugin-eslint/src/lib/nx/projects-to-config.ts
|
|
@@ -1427,11 +1435,26 @@ async function nxProjectsToConfig(projectGraph, predicate = () => true) {
|
|
|
1427
1435
|
}
|
|
1428
1436
|
|
|
1429
1437
|
// packages/plugin-eslint/src/lib/nx/find-all-projects.ts
|
|
1430
|
-
async function
|
|
1438
|
+
async function eslintConfigFromAllNxProjects() {
|
|
1431
1439
|
const { createProjectGraphAsync } = await import("@nx/devkit");
|
|
1432
1440
|
const projectGraph = await createProjectGraphAsync({ exitOnError: false });
|
|
1433
1441
|
return nxProjectsToConfig(projectGraph);
|
|
1434
1442
|
}
|
|
1443
|
+
var eslintConfigFromNxProjects = eslintConfigFromAllNxProjects;
|
|
1444
|
+
|
|
1445
|
+
// packages/plugin-eslint/src/lib/nx/find-project-without-deps.ts
|
|
1446
|
+
async function eslintConfigFromNxProject(projectName) {
|
|
1447
|
+
const { createProjectGraphAsync } = await import("@nx/devkit");
|
|
1448
|
+
const projectGraph = await createProjectGraphAsync({ exitOnError: false });
|
|
1449
|
+
const [project] = await nxProjectsToConfig(
|
|
1450
|
+
projectGraph,
|
|
1451
|
+
({ name: name2 }) => !!name2 && name2 === projectName
|
|
1452
|
+
);
|
|
1453
|
+
if (!project) {
|
|
1454
|
+
throw new Error(`Couldn't find Nx project named "${projectName}"`);
|
|
1455
|
+
}
|
|
1456
|
+
return project;
|
|
1457
|
+
}
|
|
1435
1458
|
|
|
1436
1459
|
// packages/plugin-eslint/src/lib/nx/traverse-graph.ts
|
|
1437
1460
|
function findAllDependencies(entry, projectGraph) {
|
|
@@ -1451,7 +1474,7 @@ function findAllDependencies(entry, projectGraph) {
|
|
|
1451
1474
|
}
|
|
1452
1475
|
|
|
1453
1476
|
// packages/plugin-eslint/src/lib/nx/find-project-with-deps.ts
|
|
1454
|
-
async function
|
|
1477
|
+
async function eslintConfigFromNxProjectAndDeps(projectName) {
|
|
1455
1478
|
const { createProjectGraphAsync } = await import("@nx/devkit");
|
|
1456
1479
|
const projectGraph = await createProjectGraphAsync({ exitOnError: false });
|
|
1457
1480
|
const dependencies = findAllDependencies(projectName, projectGraph);
|
|
@@ -1465,6 +1488,8 @@ async function eslintConfigFromNxProject(projectName) {
|
|
|
1465
1488
|
var src_default = eslintPlugin;
|
|
1466
1489
|
export {
|
|
1467
1490
|
src_default as default,
|
|
1491
|
+
eslintConfigFromAllNxProjects,
|
|
1468
1492
|
eslintConfigFromNxProject,
|
|
1493
|
+
eslintConfigFromNxProjectAndDeps,
|
|
1469
1494
|
eslintConfigFromNxProjects
|
|
1470
1495
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@code-pushup/utils": "0.
|
|
7
|
-
"@code-pushup/models": "0.
|
|
6
|
+
"@code-pushup/utils": "0.44.2",
|
|
7
|
+
"@code-pushup/models": "0.44.2",
|
|
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 {
|
|
4
|
+
export { eslintConfigFromNxProjectAndDeps, eslintConfigFromNxProjects, eslintConfigFromAllNxProjects, eslintConfigFromNxProject, } from './lib/nx';
|
package/src/lib/config.d.ts
CHANGED
|
@@ -1,44 +1,62 @@
|
|
|
1
1
|
import type { ESLint } from 'eslint';
|
|
2
2
|
import { type ZodType, z } from 'zod';
|
|
3
|
-
export declare const eslintTargetSchema: z.ZodObject<{
|
|
4
|
-
eslintrc: z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]
|
|
3
|
+
export declare const eslintTargetSchema: z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
4
|
+
eslintrc: z.ZodOptional<z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>>;
|
|
5
5
|
patterns: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
8
7
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
8
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
9
9
|
}, {
|
|
10
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
11
10
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
11
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
12
|
+
}>]>, {
|
|
13
|
+
patterns: (string | string[]) & (string | string[] | undefined);
|
|
14
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
15
|
+
}, string | string[] | {
|
|
16
|
+
patterns: (string | string[]) & (string | string[] | undefined);
|
|
17
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
12
18
|
}>;
|
|
13
19
|
export type ESLintTarget = z.infer<typeof eslintTargetSchema>;
|
|
14
|
-
export declare const eslintPluginConfigSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
|
|
15
|
-
eslintrc: z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]
|
|
20
|
+
export declare const eslintPluginConfigSchema: z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
21
|
+
eslintrc: z.ZodOptional<z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>>;
|
|
16
22
|
patterns: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
17
23
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
19
24
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
25
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
20
26
|
}, {
|
|
21
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
22
27
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
29
|
+
}>]>, {
|
|
30
|
+
patterns: (string | string[]) & (string | string[] | undefined);
|
|
31
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
32
|
+
}, string | string[] | {
|
|
33
|
+
patterns: (string | string[]) & (string | string[] | undefined);
|
|
34
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
35
|
+
}>, z.ZodArray<z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
36
|
+
eslintrc: z.ZodOptional<z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>>;
|
|
25
37
|
patterns: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
26
38
|
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
28
39
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
40
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
29
41
|
}, {
|
|
30
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
31
42
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
43
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
44
|
+
}>]>, {
|
|
45
|
+
patterns: (string | string[]) & (string | string[] | undefined);
|
|
46
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
47
|
+
}, string | string[] | {
|
|
48
|
+
patterns: (string | string[]) & (string | string[] | undefined);
|
|
49
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
32
50
|
}>, "many">]>, {
|
|
33
|
-
eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
|
|
34
51
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
53
|
+
}[], string | string[] | {
|
|
37
54
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
56
|
+
} | (string | string[] | {
|
|
40
57
|
patterns: (string | string[]) & (string | string[] | undefined);
|
|
41
|
-
|
|
58
|
+
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
59
|
+
})[]>;
|
|
42
60
|
export type ESLintPluginConfig = z.input<typeof eslintPluginConfigSchema>;
|
|
43
61
|
export type ESLintPluginRunnerConfig = {
|
|
44
62
|
targets: ESLintTarget[];
|
|
@@ -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
|
|
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
|
-
*
|
|
10
|
+
* eslintConfigFromAllNxProjects,
|
|
11
11
|
* } from '@code-pushup/eslint-plugin';
|
|
12
12
|
*
|
|
13
13
|
* export default {
|
|
14
14
|
* plugins: [
|
|
15
15
|
* await eslintPlugin(
|
|
16
|
-
* await
|
|
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
|
|
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
|
|
6
|
-
* If you prefer to include all Nx projects, refer to {@link
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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>;
|
package/src/lib/nx/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { eslintConfigFromNxProjects } from './find-all-projects';
|
|
2
|
-
export { eslintConfigFromNxProject } from './find-project-
|
|
1
|
+
export { eslintConfigFromNxProjects, eslintConfigFromAllNxProjects, } from './find-all-projects';
|
|
2
|
+
export { eslintConfigFromNxProject } from './find-project-without-deps';
|
|
3
|
+
export { eslintConfigFromNxProjectAndDeps } from './find-project-with-deps';
|
package/src/lib/nx/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ProjectConfiguration } from '@nx/devkit';
|
|
2
2
|
export declare function findCodePushupEslintrc(project: ProjectConfiguration): Promise<string | null>;
|
|
3
3
|
export declare function getLintFilePatterns(project: ProjectConfiguration): string[];
|
|
4
|
-
export declare function getEslintConfig(project: ProjectConfiguration): string;
|
|
4
|
+
export declare function getEslintConfig(project: ProjectConfiguration): string | undefined;
|