@lzear/eslint-config 4.2.2 → 4.4.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 +1 -1
- package/dist/index.js +47 -49
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ export default config
|
|
|
94
94
|
|
|
95
95
|
## Included plugins
|
|
96
96
|
|
|
97
|
-
`@eslint/js` · `typescript-eslint` · `eslint-plugin-unicorn` · `eslint-plugin-sonarjs` · `eslint-plugin-import-x` · `eslint-plugin-promise` · `eslint-plugin-regexp` · `eslint-plugin-react` · `eslint-plugin-react-hooks` · `eslint-plugin-jsx-a11y` · `eslint-plugin-n` · `@vitest/eslint-plugin` · `eslint-
|
|
97
|
+
`@eslint/js` · `typescript-eslint` · `eslint-plugin-unicorn` · `eslint-plugin-sonarjs` · `eslint-plugin-import-x` · `eslint-plugin-promise` · `eslint-plugin-regexp` · `eslint-plugin-react` · `eslint-plugin-react-hooks` · `eslint-plugin-jsx-a11y` · `eslint-plugin-n` · `@vitest/eslint-plugin` · `eslint-package-json` · `eslint-config-prettier` · and more.
|
|
98
98
|
|
|
99
99
|
## Part of forge
|
|
100
100
|
|
package/dist/index.js
CHANGED
|
@@ -49,8 +49,8 @@ var simplify = (version) => {
|
|
|
49
49
|
const target = `${operator}${major}`;
|
|
50
50
|
return target === version ? null : target;
|
|
51
51
|
};
|
|
52
|
-
var isIgnored = (
|
|
53
|
-
(pattern) => pattern instanceof RegExp ? pattern.test(
|
|
52
|
+
var isIgnored = (packageName, ignore) => ignore.some(
|
|
53
|
+
(pattern) => pattern instanceof RegExp ? pattern.test(packageName) : pattern === packageName
|
|
54
54
|
);
|
|
55
55
|
var majorVersionOnly = {
|
|
56
56
|
meta: {
|
|
@@ -86,24 +86,21 @@ var majorVersionOnly = {
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
create: (context) => {
|
|
89
|
-
const
|
|
90
|
-
const ignore = (
|
|
89
|
+
const options = context.options[0];
|
|
90
|
+
const ignore = (options?.ignore ?? []).map(
|
|
91
91
|
(item) => typeof item === "string" ? item : new RegExp(item.regex)
|
|
92
92
|
);
|
|
93
93
|
return {
|
|
94
|
-
|
|
94
|
+
Member: (rawNode) => {
|
|
95
95
|
const node2 = rawNode;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
const versionNode = prop.value;
|
|
104
|
-
if (versionNode.type !== "JSONLiteral") continue;
|
|
96
|
+
if (!DEP_FIELDS.has(node2.name.value)) return;
|
|
97
|
+
const dependenciesNode = node2.value;
|
|
98
|
+
if (dependenciesNode.type !== "Object") return;
|
|
99
|
+
for (const member of dependenciesNode.members) {
|
|
100
|
+
if (isIgnored(member.name.value, ignore)) continue;
|
|
101
|
+
const versionNode = member.value;
|
|
102
|
+
if (versionNode.type !== "String") continue;
|
|
105
103
|
const version = versionNode.value;
|
|
106
|
-
if (typeof version !== "string") continue;
|
|
107
104
|
const suggested = simplify(version);
|
|
108
105
|
if (!suggested) continue;
|
|
109
106
|
context.report({
|
|
@@ -124,12 +121,12 @@ import path from "path";
|
|
|
124
121
|
// utils.ts
|
|
125
122
|
var interopDefault = async (m) => {
|
|
126
123
|
const resolved = await m;
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
const inner =
|
|
124
|
+
const module_ = resolved.default ?? resolved;
|
|
125
|
+
if (module_.__esModule) {
|
|
126
|
+
const inner = module_.default;
|
|
130
127
|
if (inner !== void 0) return inner;
|
|
131
128
|
}
|
|
132
|
-
return
|
|
129
|
+
return module_;
|
|
133
130
|
};
|
|
134
131
|
|
|
135
132
|
// plugin/rules/prefer-relative-imports.ts
|
|
@@ -144,10 +141,10 @@ var toRelative = (from, importPath, context) => {
|
|
|
144
141
|
if (!rel) return null;
|
|
145
142
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
146
143
|
if (!path.extname(importPath)) {
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
const
|
|
150
|
-
rel =
|
|
144
|
+
const extension = path.extname(rel);
|
|
145
|
+
if (extension) {
|
|
146
|
+
const withoutExtension = rel.slice(0, -extension.length);
|
|
147
|
+
rel = withoutExtension.endsWith("/index") ? withoutExtension.slice(0, -"/index".length) || "." : withoutExtension;
|
|
151
148
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
152
149
|
}
|
|
153
150
|
}
|
|
@@ -174,8 +171,8 @@ var preferRelativeImports = {
|
|
|
174
171
|
}
|
|
175
172
|
},
|
|
176
173
|
create: (context) => {
|
|
177
|
-
const
|
|
178
|
-
const maxParentPrefixes =
|
|
174
|
+
const options = context.options[0];
|
|
175
|
+
const maxParentPrefixes = options?.maxParentPrefixes ?? 1;
|
|
179
176
|
const filename = context.physicalFilename;
|
|
180
177
|
const check = (source) => {
|
|
181
178
|
const importPath = source.value;
|
|
@@ -246,8 +243,8 @@ var core = (local) => {
|
|
|
246
243
|
groups: [
|
|
247
244
|
[
|
|
248
245
|
"^node:",
|
|
249
|
-
l &&
|
|
250
|
-
l &&
|
|
246
|
+
l && "^@?(?!" + l + String.raw`\/)\w`,
|
|
247
|
+
l && "^@" + l + String.raw`\/`,
|
|
251
248
|
"^",
|
|
252
249
|
String.raw`^\.`,
|
|
253
250
|
String.raw`^.+\.s?css$`
|
|
@@ -288,8 +285,14 @@ var core = (local) => {
|
|
|
288
285
|
"sonarjs/todo-tag": 0,
|
|
289
286
|
"sonarjs/void-use": 0,
|
|
290
287
|
...unicornPlugin.configs.recommended.rules,
|
|
288
|
+
"unicorn/consistent-boolean-name": 0,
|
|
289
|
+
// a bit annoying
|
|
290
|
+
"unicorn/name-replacements": 0,
|
|
291
|
+
// i like my abbreviations
|
|
291
292
|
"unicorn/no-abusive-eslint-disable": 0,
|
|
292
293
|
"unicorn/no-null": 0,
|
|
294
|
+
"unicorn/prefer-await": 0,
|
|
295
|
+
// await fn().catch() is convenient
|
|
293
296
|
"unicorn/prevent-abbreviations": 0,
|
|
294
297
|
"unicorn/switch-case-braces": [2, "avoid"]
|
|
295
298
|
};
|
|
@@ -380,27 +383,22 @@ var node = async (config) => {
|
|
|
380
383
|
};
|
|
381
384
|
|
|
382
385
|
// configs/package-json.ts
|
|
383
|
-
import
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
rules: {
|
|
396
|
-
...packageJsonPlugin.configs.recommended.rules,
|
|
397
|
-
"lzear/major-version-only": 2,
|
|
398
|
-
"package-json/repository-shorthand": [2, { form: "shorthand" }]
|
|
386
|
+
import packageJsonPlugin from "eslint-package-json";
|
|
387
|
+
var packageJson = () => [
|
|
388
|
+
packageJsonPlugin.configs.recommended,
|
|
389
|
+
{
|
|
390
|
+
name: "lzear/package-json",
|
|
391
|
+
files: ["**/package.json"],
|
|
392
|
+
plugins: {
|
|
393
|
+
lzear: plugin
|
|
394
|
+
},
|
|
395
|
+
rules: {
|
|
396
|
+
"lzear/major-version-only": 2
|
|
397
|
+
}
|
|
399
398
|
}
|
|
400
|
-
|
|
399
|
+
];
|
|
401
400
|
|
|
402
401
|
// configs/prettier.ts
|
|
403
|
-
import "eslint";
|
|
404
402
|
import prettierConfig from "eslint-plugin-prettier/recommended";
|
|
405
403
|
var { curly: _curly, ...prettierRules } = prettierConfig.rules ?? {};
|
|
406
404
|
var prettier = {
|
|
@@ -423,7 +421,7 @@ var react = async (config) => {
|
|
|
423
421
|
const [
|
|
424
422
|
reactCompilerPlugin,
|
|
425
423
|
reactHooksPlugin,
|
|
426
|
-
|
|
424
|
+
reactPerformancePlugin,
|
|
427
425
|
reactPlugin,
|
|
428
426
|
reactXPlugin,
|
|
429
427
|
reactDomPlugin,
|
|
@@ -447,20 +445,20 @@ var react = async (config) => {
|
|
|
447
445
|
"react-compiler": reactCompilerPlugin,
|
|
448
446
|
"react-dom": reactDomPlugin,
|
|
449
447
|
"react-hooks": reactHooksPlugin,
|
|
450
|
-
"react-perf":
|
|
448
|
+
"react-perf": reactPerformancePlugin,
|
|
451
449
|
"react-web-api": reactWebApiPlugin,
|
|
452
450
|
"react-x": reactXPlugin
|
|
453
451
|
},
|
|
454
452
|
rules: {
|
|
455
453
|
"react-compiler/react-compiler": 2,
|
|
456
454
|
...reactHooksPlugin.configs.recommended.rules,
|
|
457
|
-
...
|
|
455
|
+
...reactPerformancePlugin.configs.recommended.rules,
|
|
458
456
|
"react-perf/jsx-no-new-function-as-prop": 0,
|
|
459
457
|
"react-perf/jsx-no-new-object-as-prop": 0,
|
|
460
458
|
...reactPlugin.configs.recommended.rules,
|
|
461
459
|
"react/react-in-jsx-scope": 0,
|
|
462
460
|
"react/no-unknown-property": [2, { ignore: ["jsx", "global"] }],
|
|
463
|
-
...config.typescript ?
|
|
461
|
+
...reactXPlugin.configs[config.typescript ? "recommended-typescript" : "recommended"].rules,
|
|
464
462
|
...reactDomPlugin.configs.recommended.rules,
|
|
465
463
|
...reactWebApiPlugin.configs.recommended.rules
|
|
466
464
|
},
|
package/package.json
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lzear/eslint-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Shared ESLint flat config for lzear repos",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/lzear/forge.git",
|
|
8
9
|
"directory": "packages/eslint-config"
|
|
9
10
|
},
|
|
10
11
|
"author": "lzear",
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"sideEffects": false,
|
|
13
12
|
"type": "module",
|
|
14
|
-
"exports":
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
"exports": "./dist/index.js",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=24"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"provenance": true
|
|
19
21
|
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist"
|
|
22
|
-
],
|
|
23
22
|
"scripts": {
|
|
24
23
|
"build": "tsup",
|
|
25
24
|
"dev": "tsup --watch",
|
|
26
25
|
"test": "vitest run",
|
|
27
26
|
"typecheck": "tsc --noEmit"
|
|
28
27
|
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"eslint",
|
|
33
|
+
"eslint-config",
|
|
34
|
+
"eslintconfig",
|
|
35
|
+
"flat-config",
|
|
36
|
+
"lint"
|
|
37
|
+
],
|
|
29
38
|
"dependencies": {
|
|
30
39
|
"@eslint-community/eslint-plugin-eslint-comments": "^4",
|
|
31
40
|
"@eslint/js": "^10",
|
|
@@ -34,11 +43,11 @@
|
|
|
34
43
|
"eslint-config-prettier": "^10",
|
|
35
44
|
"eslint-import-resolver-typescript": "^4",
|
|
36
45
|
"eslint-module-utils": "^2",
|
|
46
|
+
"eslint-package-json": "^0.2",
|
|
37
47
|
"eslint-plugin-de-morgan": "^2",
|
|
38
48
|
"eslint-plugin-import-x": "^4",
|
|
39
49
|
"eslint-plugin-jsx-a11y": "^6",
|
|
40
50
|
"eslint-plugin-n": "^18",
|
|
41
|
-
"eslint-plugin-package-json": "^1",
|
|
42
51
|
"eslint-plugin-prefer-arrow": "^1",
|
|
43
52
|
"eslint-plugin-prettier": "^5",
|
|
44
53
|
"eslint-plugin-promise": "^7",
|
|
@@ -52,28 +61,19 @@
|
|
|
52
61
|
"eslint-plugin-regexp": "^3",
|
|
53
62
|
"eslint-plugin-simple-import-sort": "^13",
|
|
54
63
|
"eslint-plugin-sonarjs": "^4",
|
|
55
|
-
"eslint-plugin-unicorn": "^
|
|
64
|
+
"eslint-plugin-unicorn": "^72",
|
|
56
65
|
"globals": "^17",
|
|
57
|
-
"jsonc-eslint-parser": "^3",
|
|
58
66
|
"prettier": "^3",
|
|
59
67
|
"typescript-eslint": "^8"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
62
|
-
"@lzear/configs": "4.
|
|
70
|
+
"@lzear/configs": "4.4.0",
|
|
63
71
|
"@vitest/coverage-v8": "^4",
|
|
64
72
|
"eslint": "^10",
|
|
65
73
|
"tsup": "^8",
|
|
66
|
-
"typescript": "^6",
|
|
67
74
|
"vitest": "^4"
|
|
68
75
|
},
|
|
69
76
|
"peerDependencies": {
|
|
70
77
|
"eslint": "^10"
|
|
71
|
-
},
|
|
72
|
-
"engines": {
|
|
73
|
-
"node": ">=24"
|
|
74
|
-
},
|
|
75
|
-
"publishConfig": {
|
|
76
|
-
"access": "public",
|
|
77
|
-
"provenance": true
|
|
78
78
|
}
|
|
79
79
|
}
|