@lzear/eslint-config 4.1.2 → 4.2.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/dist/index.js +34 -82
- package/package.json +9 -8
- package/CHANGELOG.md +0 -13
package/dist/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// configs/a11y.ts
|
|
2
2
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
3
3
|
var a11y = (config) => {
|
|
4
|
-
if (!config.react) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
4
|
+
if (!config.react) return {};
|
|
7
5
|
const files = ["**/*.jsx"];
|
|
8
|
-
if (config.typescript)
|
|
9
|
-
files.push("**/*.tsx");
|
|
10
|
-
}
|
|
6
|
+
if (config.typescript) files.push("**/*.tsx");
|
|
11
7
|
return {
|
|
12
8
|
name: "lzear/a11y",
|
|
13
9
|
files,
|
|
@@ -44,9 +40,7 @@ var DEP_FIELDS = /* @__PURE__ */ new Set([
|
|
|
44
40
|
var VERSION_RE = /^([~^])(\d+)\.(\d+)(?:\.\d+)?$/;
|
|
45
41
|
var simplify = (version) => {
|
|
46
42
|
const match = VERSION_RE.exec(version);
|
|
47
|
-
if (!match)
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
43
|
+
if (!match) return null;
|
|
50
44
|
const [, operator, major, minor] = match;
|
|
51
45
|
if (major === "0" && operator === "^") {
|
|
52
46
|
const target2 = `^0.${minor}`;
|
|
@@ -100,30 +94,18 @@ var majorVersionOnly = {
|
|
|
100
94
|
JSONProperty: (rawNode) => {
|
|
101
95
|
const node2 = rawNode;
|
|
102
96
|
const keyName = node2.key.type === "JSONLiteral" ? String(node2.key.value) : node2.key.name ?? "";
|
|
103
|
-
if (!DEP_FIELDS.has(keyName))
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
97
|
+
if (!DEP_FIELDS.has(keyName)) return;
|
|
106
98
|
const depsNode = node2.value;
|
|
107
|
-
if (depsNode.type !== "JSONObjectExpression")
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
99
|
+
if (depsNode.type !== "JSONObjectExpression") return;
|
|
110
100
|
for (const prop of depsNode.properties) {
|
|
111
101
|
const pkgName = prop.key.type === "JSONLiteral" ? String(prop.key.value) : prop.key.name ?? "";
|
|
112
|
-
if (isIgnored(pkgName, ignore))
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
102
|
+
if (isIgnored(pkgName, ignore)) continue;
|
|
115
103
|
const versionNode = prop.value;
|
|
116
|
-
if (versionNode.type !== "JSONLiteral")
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
104
|
+
if (versionNode.type !== "JSONLiteral") continue;
|
|
119
105
|
const version = versionNode.value;
|
|
120
|
-
if (typeof version !== "string")
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
106
|
+
if (typeof version !== "string") continue;
|
|
123
107
|
const suggested = simplify(version);
|
|
124
|
-
if (!suggested)
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
108
|
+
if (!suggested) continue;
|
|
127
109
|
context.report({
|
|
128
110
|
node: versionNode,
|
|
129
111
|
messageId: "useMajorOnly",
|
|
@@ -157,24 +139,16 @@ var moduleVisitor = await interopDefault(
|
|
|
157
139
|
var resolve = await interopDefault(import("eslint-module-utils/resolve"));
|
|
158
140
|
var toRelative = (from, importPath, context) => {
|
|
159
141
|
const resolved = resolve(importPath, context);
|
|
160
|
-
if (!resolved)
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
142
|
+
if (!resolved) return null;
|
|
163
143
|
let rel = path.relative(path.dirname(from), resolved);
|
|
164
|
-
if (!rel)
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
if (!rel.startsWith(".")) {
|
|
168
|
-
rel = `./${rel}`;
|
|
169
|
-
}
|
|
144
|
+
if (!rel) return null;
|
|
145
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
170
146
|
if (!path.extname(importPath)) {
|
|
171
147
|
const ext = path.extname(rel);
|
|
172
148
|
if (ext) {
|
|
173
149
|
const withoutExt = rel.slice(0, -ext.length);
|
|
174
150
|
rel = withoutExt.endsWith("/index") ? withoutExt.slice(0, -"/index".length) || "." : withoutExt;
|
|
175
|
-
if (!rel.startsWith(".")) {
|
|
176
|
-
rel = `./${rel}`;
|
|
177
|
-
}
|
|
151
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
178
152
|
}
|
|
179
153
|
}
|
|
180
154
|
return rel;
|
|
@@ -205,16 +179,10 @@ var preferRelativeImports = {
|
|
|
205
179
|
const filename = context.physicalFilename;
|
|
206
180
|
const check = (source) => {
|
|
207
181
|
const importPath = source.value;
|
|
208
|
-
if (typeof importPath !== "string" || importPath.startsWith("."))
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
182
|
+
if (typeof importPath !== "string" || importPath.startsWith(".")) return;
|
|
211
183
|
const relative = toRelative(filename, importPath, context);
|
|
212
|
-
if (!relative || relative.length >= importPath.length)
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
if (countParentPrefixes(relative) > maxParentPrefixes) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
184
|
+
if (!relative || relative.length >= importPath.length) return;
|
|
185
|
+
if (countParentPrefixes(relative) > maxParentPrefixes) return;
|
|
218
186
|
context.report({
|
|
219
187
|
node: source,
|
|
220
188
|
messageId: "preferRelative",
|
|
@@ -254,6 +222,7 @@ var core = (local) => {
|
|
|
254
222
|
const sonarRules = (sonarjsPlugin.configs?.recommended).rules;
|
|
255
223
|
const rules = {
|
|
256
224
|
...js.configs.recommended.rules,
|
|
225
|
+
curly: [2, "multi"],
|
|
257
226
|
...eslintCommentsPlugin.configs.recommended.rules,
|
|
258
227
|
"@eslint-community/eslint-comments/disable-enable-pair": 0,
|
|
259
228
|
"@eslint-community/eslint-comments/no-unlimited-disable": 0,
|
|
@@ -321,7 +290,8 @@ var core = (local) => {
|
|
|
321
290
|
...unicornPlugin.configs.recommended.rules,
|
|
322
291
|
"unicorn/no-abusive-eslint-disable": 0,
|
|
323
292
|
"unicorn/no-null": 0,
|
|
324
|
-
"unicorn/prevent-abbreviations": 0
|
|
293
|
+
"unicorn/prevent-abbreviations": 0,
|
|
294
|
+
"unicorn/switch-case-braces": [2, "avoid"]
|
|
325
295
|
};
|
|
326
296
|
return {
|
|
327
297
|
name: "lzear/core",
|
|
@@ -384,19 +354,13 @@ var ignores = [
|
|
|
384
354
|
|
|
385
355
|
// configs/node.ts
|
|
386
356
|
var node = async (config) => {
|
|
387
|
-
if (!config.node) {
|
|
388
|
-
return {};
|
|
389
|
-
}
|
|
357
|
+
if (!config.node) return {};
|
|
390
358
|
const nodePlugin = await interopDefault(import("eslint-plugin-n"));
|
|
391
359
|
const files = ["**/*.js", "**/*.cjs", "**/*.mjs"];
|
|
392
|
-
if (config.typescript)
|
|
393
|
-
files.push("**/*.ts", "**/*.cts", "**/*.mts");
|
|
394
|
-
}
|
|
360
|
+
if (config.typescript) files.push("**/*.ts", "**/*.cts", "**/*.mts");
|
|
395
361
|
if (config.react) {
|
|
396
362
|
files.push("**/*.jsx");
|
|
397
|
-
if (config.typescript)
|
|
398
|
-
files.push("**/*.tsx");
|
|
399
|
-
}
|
|
363
|
+
if (config.typescript) files.push("**/*.tsx");
|
|
400
364
|
}
|
|
401
365
|
return {
|
|
402
366
|
name: "lzear/node",
|
|
@@ -411,10 +375,6 @@ var node = async (config) => {
|
|
|
411
375
|
"n/no-extraneous-import": 0,
|
|
412
376
|
"n/no-missing-import": 0,
|
|
413
377
|
"n/no-process-exit": 0
|
|
414
|
-
},
|
|
415
|
-
settings: {
|
|
416
|
-
// Align with the minimum version where import.meta.dirname is stable
|
|
417
|
-
node: { version: ">=22.16.0" }
|
|
418
378
|
}
|
|
419
379
|
};
|
|
420
380
|
};
|
|
@@ -442,10 +402,11 @@ var packageJson = () => ({
|
|
|
442
402
|
// configs/prettier.ts
|
|
443
403
|
import "eslint";
|
|
444
404
|
import prettierConfig from "eslint-plugin-prettier/recommended";
|
|
405
|
+
var { curly: _curly, ...prettierRules } = prettierConfig.rules ?? {};
|
|
445
406
|
var prettier = {
|
|
446
407
|
...prettierConfig,
|
|
447
408
|
rules: {
|
|
448
|
-
...
|
|
409
|
+
...prettierRules,
|
|
449
410
|
"prettier/prettier": [
|
|
450
411
|
2,
|
|
451
412
|
{
|
|
@@ -458,9 +419,7 @@ var prettier = {
|
|
|
458
419
|
|
|
459
420
|
// configs/react.ts
|
|
460
421
|
var react = async (config) => {
|
|
461
|
-
if (!config.react) {
|
|
462
|
-
return {};
|
|
463
|
-
}
|
|
422
|
+
if (!config.react) return {};
|
|
464
423
|
const [
|
|
465
424
|
reactCompilerPlugin,
|
|
466
425
|
reactHooksPlugin,
|
|
@@ -479,9 +438,7 @@ var react = async (config) => {
|
|
|
479
438
|
interopDefault(import("eslint-plugin-react-web-api"))
|
|
480
439
|
]);
|
|
481
440
|
const files = ["**/*.jsx"];
|
|
482
|
-
if (config.typescript)
|
|
483
|
-
files.push("**/*.tsx");
|
|
484
|
-
}
|
|
441
|
+
if (config.typescript) files.push("**/*.tsx");
|
|
485
442
|
return {
|
|
486
443
|
name: "lzear/react",
|
|
487
444
|
files,
|
|
@@ -523,13 +480,10 @@ var react = async (config) => {
|
|
|
523
480
|
};
|
|
524
481
|
|
|
525
482
|
// configs/typescript.ts
|
|
526
|
-
import eslint from "@eslint/js";
|
|
527
483
|
import { defineConfig } from "eslint/config";
|
|
528
484
|
import tseslint from "typescript-eslint";
|
|
529
485
|
var typescript = async (config) => {
|
|
530
|
-
if (!config.typescript)
|
|
531
|
-
return [];
|
|
532
|
-
}
|
|
486
|
+
if (!config.typescript) return [];
|
|
533
487
|
const { parser: typescriptParser } = await interopDefault(
|
|
534
488
|
import("typescript-eslint")
|
|
535
489
|
);
|
|
@@ -537,7 +491,6 @@ var typescript = async (config) => {
|
|
|
537
491
|
return defineConfig({
|
|
538
492
|
name: "lzear/typescript",
|
|
539
493
|
extends: [
|
|
540
|
-
eslint.configs.recommended,
|
|
541
494
|
tseslint.configs.strictTypeChecked,
|
|
542
495
|
tseslint.configs.stylisticTypeChecked
|
|
543
496
|
],
|
|
@@ -551,6 +504,10 @@ var typescript = async (config) => {
|
|
|
551
504
|
2,
|
|
552
505
|
{ allowConstantLoopConditions: "only-allowed-literals" }
|
|
553
506
|
],
|
|
507
|
+
"@typescript-eslint/no-unused-vars": [
|
|
508
|
+
2,
|
|
509
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" }
|
|
510
|
+
],
|
|
554
511
|
"@typescript-eslint/no-unused-expressions": [2, { allowTernary: true }],
|
|
555
512
|
"@typescript-eslint/restrict-template-expressions": [
|
|
556
513
|
2,
|
|
@@ -572,9 +529,7 @@ var typescript = async (config) => {
|
|
|
572
529
|
|
|
573
530
|
// configs/vitest.ts
|
|
574
531
|
var vitest = async (config) => {
|
|
575
|
-
if (!config.vitest) {
|
|
576
|
-
return {};
|
|
577
|
-
}
|
|
532
|
+
if (!config.vitest) return {};
|
|
578
533
|
const vitestPlugin = await interopDefault(import("@vitest/eslint-plugin"));
|
|
579
534
|
const files = [
|
|
580
535
|
"**/test/*.js",
|
|
@@ -584,7 +539,7 @@ var vitest = async (config) => {
|
|
|
584
539
|
"**/*.test.cjs",
|
|
585
540
|
"**/*.test.mjs"
|
|
586
541
|
];
|
|
587
|
-
if (config.typescript)
|
|
542
|
+
if (config.typescript)
|
|
588
543
|
files.push(
|
|
589
544
|
"**/test/*.ts",
|
|
590
545
|
"**/test/*.cts",
|
|
@@ -593,12 +548,9 @@ var vitest = async (config) => {
|
|
|
593
548
|
"**/*.test.cts",
|
|
594
549
|
"**/*.test.mts"
|
|
595
550
|
);
|
|
596
|
-
}
|
|
597
551
|
if (config.react) {
|
|
598
552
|
files.push("**/test/*.jsx", "**/*.test.jsx");
|
|
599
|
-
if (config.typescript)
|
|
600
|
-
files.push("**/test/*.tsx", "**/*.test.tsx");
|
|
601
|
-
}
|
|
553
|
+
if (config.typescript) files.push("**/test/*.tsx", "**/*.test.tsx");
|
|
602
554
|
}
|
|
603
555
|
return {
|
|
604
556
|
name: "lzear/vitest",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lzear/eslint-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Shared ESLint flat config for lzear repos",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@eslint-community/eslint-plugin-eslint-comments": "^4",
|
|
31
|
-
"@eslint/js": "^
|
|
31
|
+
"@eslint/js": "^10",
|
|
32
32
|
"@stylistic/eslint-plugin": "^5",
|
|
33
33
|
"@vitest/eslint-plugin": "^1",
|
|
34
34
|
"eslint-config-prettier": "^10",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"eslint-plugin-import-x": "^4",
|
|
39
39
|
"eslint-plugin-jsx-a11y": "^6",
|
|
40
40
|
"eslint-plugin-n": "^18",
|
|
41
|
-
"eslint-plugin-package-json": "^
|
|
41
|
+
"eslint-plugin-package-json": "^1",
|
|
42
42
|
"eslint-plugin-prefer-arrow": "^1",
|
|
43
43
|
"eslint-plugin-prettier": "^5",
|
|
44
44
|
"eslint-plugin-promise": "^7",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"typescript-eslint": "^8"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@lzear/configs": "
|
|
62
|
+
"@lzear/configs": "workspace:*",
|
|
63
63
|
"@vitest/coverage-v8": "^4",
|
|
64
|
-
"eslint": "^
|
|
64
|
+
"eslint": "^10",
|
|
65
65
|
"tsup": "^8",
|
|
66
66
|
"typescript": "^6",
|
|
67
67
|
"vitest": "^4"
|
|
@@ -70,9 +70,10 @@
|
|
|
70
70
|
"eslint": "^9"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
|
-
"node": ">=
|
|
73
|
+
"node": ">=24"
|
|
74
74
|
},
|
|
75
75
|
"publishConfig": {
|
|
76
|
-
"access": "public"
|
|
76
|
+
"access": "public",
|
|
77
|
+
"provenance": true
|
|
77
78
|
}
|
|
78
|
-
}
|
|
79
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# @lzear/eslint-config
|
|
2
|
-
|
|
3
|
-
## 4.1.2
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [`76b2ce3`](https://github.com/lzear/forge/commit/76b2ce3af6e002ae7884eec50979ce8a5d5d7e3e) Thanks [@lzear](https://github.com/lzear)! - Fix publish script
|
|
8
|
-
|
|
9
|
-
## 4.1.1
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- [`9a15611`](https://github.com/lzear/forge/commit/9a15611452c9985033183216c717aa08efba5d1e) Thanks [@lzear](https://github.com/lzear)! - Minor updates. Add @stylistic/eslint-plugin, expect less from repo-lint, ...
|