@code-pushup/eslint-plugin 0.44.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 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 path to your ESLint config file, along with glob patterns for which files you wish to target (relative to `process.cwd()`).
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,7 +52,7 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
52
52
  // ...
53
53
  plugins: [
54
54
  // ...
55
- await eslintPlugin({ eslintrc: '.eslintrc.js', patterns: ['src/**/*.js'] }),
55
+ await eslintPlugin(['src/**/*.js']),
56
56
  ],
57
57
  };
58
58
  ```
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" ? { overrideConfigFile: eslintrc } : { baseConfig: eslintrc },
1189
- useEslintrc: false,
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 === "string") {
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.44.1";
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 eslintTargetSchema = z16.object({
1111
- eslintrc: z16.union(
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" ? { overrideConfigFile: eslintrc } : { baseConfig: eslintrc },
1144
- useEslintrc: false,
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 ?? `./${project.root}/.eslintrc.json`;
1406
+ return options?.eslintConfig;
1399
1407
  }
1400
1408
 
1401
1409
  // packages/plugin-eslint/src/lib/nx/projects-to-config.ts
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.44.1",
3
+ "version": "0.44.2",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@code-pushup/utils": "0.44.1",
7
- "@code-pushup/models": "0.44.1",
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
  },
@@ -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
- }>, z.ZodArray<z.ZodObject<{
24
- eslintrc: z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>;
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
- eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
52
+ eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
53
+ }[], string | string[] | {
37
54
  patterns: (string | string[]) & (string | string[] | undefined);
38
- } | {
39
- eslintrc: (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord>) & (string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined);
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[];
@@ -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;