@rebeccastevens/eslint-config 1.5.7 → 1.6.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/common-overrides.cjs +2 -1
- package/dist/common-overrides.mjs +2 -1
- package/dist/modern.cjs +88 -6
- package/dist/modern.mjs +89 -7
- package/dist/typescript.cjs +97 -24
- package/dist/typescript.mjs +98 -25
- package/package.json +20 -15
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const jsxExtensions = [".jsx", ".tsx"];
|
|
4
|
+
const jsxFiles = [`**/*{${jsxExtensions.join(",")}}`];
|
|
4
5
|
const testFiles = ["{test,tests}/**/*", "**/*.{spec,test}.*"];
|
|
5
6
|
|
|
6
7
|
var commonOverrides = {
|
package/dist/modern.cjs
CHANGED
|
@@ -401,9 +401,15 @@ const rules$2 = {
|
|
|
401
401
|
};
|
|
402
402
|
const overrides$2 = [];
|
|
403
403
|
|
|
404
|
-
const
|
|
405
|
-
const
|
|
406
|
-
const
|
|
404
|
+
const typescriptExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
405
|
+
const typescriptDeclarationExtensions = [".d.ts", ".d.mts", ".d.cts"];
|
|
406
|
+
const jsExtensions = [".js", ".mjs", ".cjs"];
|
|
407
|
+
const commonJsExtensions = [".cjs", ".cts"];
|
|
408
|
+
const typescriptFiles = [`**/*{${typescriptExtensions.join(",")}}`];
|
|
409
|
+
const typescriptDeclarationFiles = [
|
|
410
|
+
`**/*{${typescriptDeclarationExtensions.join(",")}}`,
|
|
411
|
+
];
|
|
412
|
+
const commonJsFiles = [`**/*{${commonJsExtensions.join(",")}}`];
|
|
407
413
|
|
|
408
414
|
const useNumberIsFinite = "Please use Number.isFinite instead";
|
|
409
415
|
const useNumberIsNan = "Please use Number.isNaN instead";
|
|
@@ -608,6 +614,76 @@ const overrides = [
|
|
|
608
614
|
...overrides$1,
|
|
609
615
|
];
|
|
610
616
|
|
|
617
|
+
/**
|
|
618
|
+
* Merge multiple eslint configs into one.
|
|
619
|
+
*/
|
|
620
|
+
const mergeConfigs = deepmergeTs.deepmergeCustom({
|
|
621
|
+
metaDataUpdater: (previousMeta, metaMeta) => {
|
|
622
|
+
if (previousMeta === undefined) {
|
|
623
|
+
if (metaMeta.key === undefined) {
|
|
624
|
+
return { keyPath: [] };
|
|
625
|
+
}
|
|
626
|
+
return { keyPath: [metaMeta.key] };
|
|
627
|
+
}
|
|
628
|
+
if (metaMeta.key === undefined) {
|
|
629
|
+
return previousMeta;
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
...metaMeta,
|
|
633
|
+
keyPath: [...previousMeta.keyPath, metaMeta.key],
|
|
634
|
+
};
|
|
635
|
+
},
|
|
636
|
+
mergeArrays(values, utils, meta) {
|
|
637
|
+
if (isRuleSettings(meta)) {
|
|
638
|
+
return mergeRuleSettings(values, utils);
|
|
639
|
+
}
|
|
640
|
+
return [...new Set(utils.defaultMergeFunctions.mergeArrays(values))];
|
|
641
|
+
},
|
|
642
|
+
mergeOthers(values, utils, meta) {
|
|
643
|
+
if (isRuleSettings(meta)) {
|
|
644
|
+
return mergeRuleSettings(values, utils);
|
|
645
|
+
}
|
|
646
|
+
return utils.actions.defaultMerge;
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
/**
|
|
650
|
+
* Based on the meta data, should the current data be for rule settings.
|
|
651
|
+
*/
|
|
652
|
+
function isRuleSettings(meta) {
|
|
653
|
+
return (meta !== undefined &&
|
|
654
|
+
((meta.keyPath.length === 2 && meta.keyPath[0] === "rules") ||
|
|
655
|
+
(meta.keyPath.length === 4 &&
|
|
656
|
+
meta.keyPath[1] === "overrides" &&
|
|
657
|
+
typeof meta.keyPath[2] === "number" &&
|
|
658
|
+
meta.keyPath[3] === "rules")));
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Merge eslint rule settings.
|
|
662
|
+
*
|
|
663
|
+
* @throws When invalid rule setting syntax are given.
|
|
664
|
+
*/
|
|
665
|
+
function mergeRuleSettings(values, utils) {
|
|
666
|
+
const settingsData = values.findLast((value) => Array.isArray(value) && value.length >= 2);
|
|
667
|
+
if (settingsData === undefined) {
|
|
668
|
+
return utils.actions.defaultMerge;
|
|
669
|
+
}
|
|
670
|
+
const severityData = values.at(-1);
|
|
671
|
+
const severity = Array.isArray(severityData)
|
|
672
|
+
? severityData[0]
|
|
673
|
+
: severityData;
|
|
674
|
+
if (severity === "off" || severity === 0) {
|
|
675
|
+
return severity;
|
|
676
|
+
}
|
|
677
|
+
if (severity !== "error" &&
|
|
678
|
+
severity !== 2 &&
|
|
679
|
+
severity !== "warn" &&
|
|
680
|
+
severity !== 1) {
|
|
681
|
+
throw new Error(`Unknow rule severity: "${String(severity)}"`);
|
|
682
|
+
}
|
|
683
|
+
const settings = settingsData.slice(1);
|
|
684
|
+
return [severity, ...settings];
|
|
685
|
+
}
|
|
686
|
+
|
|
611
687
|
const settings$9 = {
|
|
612
688
|
plugins: ["eslint-comments"],
|
|
613
689
|
extends: ["plugin:eslint-comments/recommended"],
|
|
@@ -779,7 +855,7 @@ const settings$7 = {
|
|
|
779
855
|
"import/no-named-export": "off",
|
|
780
856
|
"import/no-namespace": "off",
|
|
781
857
|
"import/no-nodejs-modules": "off",
|
|
782
|
-
"import/no-relative-parent-imports": "
|
|
858
|
+
"import/no-relative-parent-imports": "off",
|
|
783
859
|
"import/no-restricted-paths": "off",
|
|
784
860
|
"import/no-self-import": "error",
|
|
785
861
|
"import/no-unassigned-import": "error",
|
|
@@ -821,7 +897,13 @@ const settings$7 = {
|
|
|
821
897
|
"import/unambiguous": "off",
|
|
822
898
|
},
|
|
823
899
|
settings: {
|
|
900
|
+
"import/external-module-folders": ["node_modules"],
|
|
824
901
|
"import/internal-regex": "^(?:@|~)\\/.+",
|
|
902
|
+
"import/resolver": {
|
|
903
|
+
node: {
|
|
904
|
+
extensions: jsExtensions,
|
|
905
|
+
},
|
|
906
|
+
},
|
|
825
907
|
},
|
|
826
908
|
overrides: [
|
|
827
909
|
{
|
|
@@ -1114,9 +1196,9 @@ const baseConfig = {
|
|
|
1114
1196
|
extends: ["eslint:recommended"],
|
|
1115
1197
|
rules: rules,
|
|
1116
1198
|
overrides: overrides,
|
|
1117
|
-
ignorePatterns: ["dist
|
|
1199
|
+
ignorePatterns: ["/dist"],
|
|
1118
1200
|
reportUnusedDisableDirectives: true,
|
|
1119
1201
|
};
|
|
1120
|
-
var modern =
|
|
1202
|
+
var modern = mergeConfigs(baseConfig, settings$9, settings$8, settings$7, settings$6, settings$5, settings$4, settings$3, settings$2, settings$1, settings);
|
|
1121
1203
|
|
|
1122
1204
|
module.exports = modern;
|
package/dist/modern.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deepmergeCustom } from 'deepmerge-ts';
|
|
2
2
|
|
|
3
3
|
const rules$4 = {
|
|
4
4
|
"callback-return": "off",
|
|
@@ -399,9 +399,15 @@ const rules$2 = {
|
|
|
399
399
|
};
|
|
400
400
|
const overrides$2 = [];
|
|
401
401
|
|
|
402
|
-
const
|
|
403
|
-
const
|
|
404
|
-
const
|
|
402
|
+
const typescriptExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
403
|
+
const typescriptDeclarationExtensions = [".d.ts", ".d.mts", ".d.cts"];
|
|
404
|
+
const jsExtensions = [".js", ".mjs", ".cjs"];
|
|
405
|
+
const commonJsExtensions = [".cjs", ".cts"];
|
|
406
|
+
const typescriptFiles = [`**/*{${typescriptExtensions.join(",")}}`];
|
|
407
|
+
const typescriptDeclarationFiles = [
|
|
408
|
+
`**/*{${typescriptDeclarationExtensions.join(",")}}`,
|
|
409
|
+
];
|
|
410
|
+
const commonJsFiles = [`**/*{${commonJsExtensions.join(",")}}`];
|
|
405
411
|
|
|
406
412
|
const useNumberIsFinite = "Please use Number.isFinite instead";
|
|
407
413
|
const useNumberIsNan = "Please use Number.isNaN instead";
|
|
@@ -606,6 +612,76 @@ const overrides = [
|
|
|
606
612
|
...overrides$1,
|
|
607
613
|
];
|
|
608
614
|
|
|
615
|
+
/**
|
|
616
|
+
* Merge multiple eslint configs into one.
|
|
617
|
+
*/
|
|
618
|
+
const mergeConfigs = deepmergeCustom({
|
|
619
|
+
metaDataUpdater: (previousMeta, metaMeta) => {
|
|
620
|
+
if (previousMeta === undefined) {
|
|
621
|
+
if (metaMeta.key === undefined) {
|
|
622
|
+
return { keyPath: [] };
|
|
623
|
+
}
|
|
624
|
+
return { keyPath: [metaMeta.key] };
|
|
625
|
+
}
|
|
626
|
+
if (metaMeta.key === undefined) {
|
|
627
|
+
return previousMeta;
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
...metaMeta,
|
|
631
|
+
keyPath: [...previousMeta.keyPath, metaMeta.key],
|
|
632
|
+
};
|
|
633
|
+
},
|
|
634
|
+
mergeArrays(values, utils, meta) {
|
|
635
|
+
if (isRuleSettings(meta)) {
|
|
636
|
+
return mergeRuleSettings(values, utils);
|
|
637
|
+
}
|
|
638
|
+
return [...new Set(utils.defaultMergeFunctions.mergeArrays(values))];
|
|
639
|
+
},
|
|
640
|
+
mergeOthers(values, utils, meta) {
|
|
641
|
+
if (isRuleSettings(meta)) {
|
|
642
|
+
return mergeRuleSettings(values, utils);
|
|
643
|
+
}
|
|
644
|
+
return utils.actions.defaultMerge;
|
|
645
|
+
},
|
|
646
|
+
});
|
|
647
|
+
/**
|
|
648
|
+
* Based on the meta data, should the current data be for rule settings.
|
|
649
|
+
*/
|
|
650
|
+
function isRuleSettings(meta) {
|
|
651
|
+
return (meta !== undefined &&
|
|
652
|
+
((meta.keyPath.length === 2 && meta.keyPath[0] === "rules") ||
|
|
653
|
+
(meta.keyPath.length === 4 &&
|
|
654
|
+
meta.keyPath[1] === "overrides" &&
|
|
655
|
+
typeof meta.keyPath[2] === "number" &&
|
|
656
|
+
meta.keyPath[3] === "rules")));
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Merge eslint rule settings.
|
|
660
|
+
*
|
|
661
|
+
* @throws When invalid rule setting syntax are given.
|
|
662
|
+
*/
|
|
663
|
+
function mergeRuleSettings(values, utils) {
|
|
664
|
+
const settingsData = values.findLast((value) => Array.isArray(value) && value.length >= 2);
|
|
665
|
+
if (settingsData === undefined) {
|
|
666
|
+
return utils.actions.defaultMerge;
|
|
667
|
+
}
|
|
668
|
+
const severityData = values.at(-1);
|
|
669
|
+
const severity = Array.isArray(severityData)
|
|
670
|
+
? severityData[0]
|
|
671
|
+
: severityData;
|
|
672
|
+
if (severity === "off" || severity === 0) {
|
|
673
|
+
return severity;
|
|
674
|
+
}
|
|
675
|
+
if (severity !== "error" &&
|
|
676
|
+
severity !== 2 &&
|
|
677
|
+
severity !== "warn" &&
|
|
678
|
+
severity !== 1) {
|
|
679
|
+
throw new Error(`Unknow rule severity: "${String(severity)}"`);
|
|
680
|
+
}
|
|
681
|
+
const settings = settingsData.slice(1);
|
|
682
|
+
return [severity, ...settings];
|
|
683
|
+
}
|
|
684
|
+
|
|
609
685
|
const settings$9 = {
|
|
610
686
|
plugins: ["eslint-comments"],
|
|
611
687
|
extends: ["plugin:eslint-comments/recommended"],
|
|
@@ -777,7 +853,7 @@ const settings$7 = {
|
|
|
777
853
|
"import/no-named-export": "off",
|
|
778
854
|
"import/no-namespace": "off",
|
|
779
855
|
"import/no-nodejs-modules": "off",
|
|
780
|
-
"import/no-relative-parent-imports": "
|
|
856
|
+
"import/no-relative-parent-imports": "off",
|
|
781
857
|
"import/no-restricted-paths": "off",
|
|
782
858
|
"import/no-self-import": "error",
|
|
783
859
|
"import/no-unassigned-import": "error",
|
|
@@ -819,7 +895,13 @@ const settings$7 = {
|
|
|
819
895
|
"import/unambiguous": "off",
|
|
820
896
|
},
|
|
821
897
|
settings: {
|
|
898
|
+
"import/external-module-folders": ["node_modules"],
|
|
822
899
|
"import/internal-regex": "^(?:@|~)\\/.+",
|
|
900
|
+
"import/resolver": {
|
|
901
|
+
node: {
|
|
902
|
+
extensions: jsExtensions,
|
|
903
|
+
},
|
|
904
|
+
},
|
|
823
905
|
},
|
|
824
906
|
overrides: [
|
|
825
907
|
{
|
|
@@ -1112,9 +1194,9 @@ const baseConfig = {
|
|
|
1112
1194
|
extends: ["eslint:recommended"],
|
|
1113
1195
|
rules: rules,
|
|
1114
1196
|
overrides: overrides,
|
|
1115
|
-
ignorePatterns: ["dist
|
|
1197
|
+
ignorePatterns: ["/dist"],
|
|
1116
1198
|
reportUnusedDisableDirectives: true,
|
|
1117
1199
|
};
|
|
1118
|
-
var modern =
|
|
1200
|
+
var modern = mergeConfigs(baseConfig, settings$9, settings$8, settings$7, settings$6, settings$5, settings$4, settings$3, settings$2, settings$1, settings);
|
|
1119
1201
|
|
|
1120
1202
|
export { modern as default };
|
package/dist/typescript.cjs
CHANGED
|
@@ -2,13 +2,98 @@
|
|
|
2
2
|
|
|
3
3
|
var deepmergeTs = require('deepmerge-ts');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const typescriptExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
6
|
+
const typescriptDeclarationExtensions = [".d.ts", ".d.mts", ".d.cts"];
|
|
7
|
+
const jsExtensions = [".js", ".mjs", ".cjs"];
|
|
8
|
+
const jsxExtensions = [".jsx", ".tsx"];
|
|
9
|
+
const commonJsExtensions = [".cjs", ".cts"];
|
|
10
|
+
const typescriptSupportedExtensions = [
|
|
11
|
+
...new Set([
|
|
12
|
+
...typescriptExtensions,
|
|
13
|
+
...typescriptDeclarationExtensions,
|
|
14
|
+
...jsExtensions,
|
|
15
|
+
...jsxExtensions,
|
|
16
|
+
]),
|
|
17
|
+
];
|
|
18
|
+
[`**/*{${typescriptExtensions.join(",")}}`];
|
|
19
|
+
const typescriptDeclarationFiles = [
|
|
20
|
+
`**/*{${typescriptDeclarationExtensions.join(",")}}`,
|
|
21
|
+
];
|
|
22
|
+
const commonJsFiles = [`**/*{${commonJsExtensions.join(",")}}`];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Merge multiple eslint configs into one.
|
|
26
|
+
*/
|
|
27
|
+
const mergeConfigs = deepmergeTs.deepmergeCustom({
|
|
28
|
+
metaDataUpdater: (previousMeta, metaMeta) => {
|
|
29
|
+
if (previousMeta === undefined) {
|
|
30
|
+
if (metaMeta.key === undefined) {
|
|
31
|
+
return { keyPath: [] };
|
|
32
|
+
}
|
|
33
|
+
return { keyPath: [metaMeta.key] };
|
|
34
|
+
}
|
|
35
|
+
if (metaMeta.key === undefined) {
|
|
36
|
+
return previousMeta;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...metaMeta,
|
|
40
|
+
keyPath: [...previousMeta.keyPath, metaMeta.key],
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
mergeArrays(values, utils, meta) {
|
|
44
|
+
if (isRuleSettings(meta)) {
|
|
45
|
+
return mergeRuleSettings(values, utils);
|
|
46
|
+
}
|
|
47
|
+
return [...new Set(utils.defaultMergeFunctions.mergeArrays(values))];
|
|
48
|
+
},
|
|
49
|
+
mergeOthers(values, utils, meta) {
|
|
50
|
+
if (isRuleSettings(meta)) {
|
|
51
|
+
return mergeRuleSettings(values, utils);
|
|
52
|
+
}
|
|
53
|
+
return utils.actions.defaultMerge;
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Based on the meta data, should the current data be for rule settings.
|
|
58
|
+
*/
|
|
59
|
+
function isRuleSettings(meta) {
|
|
60
|
+
return (meta !== undefined &&
|
|
61
|
+
((meta.keyPath.length === 2 && meta.keyPath[0] === "rules") ||
|
|
62
|
+
(meta.keyPath.length === 4 &&
|
|
63
|
+
meta.keyPath[1] === "overrides" &&
|
|
64
|
+
typeof meta.keyPath[2] === "number" &&
|
|
65
|
+
meta.keyPath[3] === "rules")));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Merge eslint rule settings.
|
|
69
|
+
*
|
|
70
|
+
* @throws When invalid rule setting syntax are given.
|
|
71
|
+
*/
|
|
72
|
+
function mergeRuleSettings(values, utils) {
|
|
73
|
+
const settingsData = values.findLast((value) => Array.isArray(value) && value.length >= 2);
|
|
74
|
+
if (settingsData === undefined) {
|
|
75
|
+
return utils.actions.defaultMerge;
|
|
76
|
+
}
|
|
77
|
+
const severityData = values.at(-1);
|
|
78
|
+
const severity = Array.isArray(severityData)
|
|
79
|
+
? severityData[0]
|
|
80
|
+
: severityData;
|
|
81
|
+
if (severity === "off" || severity === 0) {
|
|
82
|
+
return severity;
|
|
83
|
+
}
|
|
84
|
+
if (severity !== "error" &&
|
|
85
|
+
severity !== 2 &&
|
|
86
|
+
severity !== "warn" &&
|
|
87
|
+
severity !== 1) {
|
|
88
|
+
throw new Error(`Unknow rule severity: "${String(severity)}"`);
|
|
89
|
+
}
|
|
90
|
+
const settings = settingsData.slice(1);
|
|
91
|
+
return [severity, ...settings];
|
|
92
|
+
}
|
|
7
93
|
|
|
8
94
|
const settings = {
|
|
9
95
|
plugins: ["@typescript-eslint"],
|
|
10
96
|
extends: [
|
|
11
|
-
"plugin:import/typescript",
|
|
12
97
|
"plugin:@typescript-eslint/eslint-recommended",
|
|
13
98
|
"plugin:@typescript-eslint/recommended",
|
|
14
99
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
|
@@ -307,30 +392,18 @@ const baseConfig = {
|
|
|
307
392
|
"space-infix-ops": "off",
|
|
308
393
|
},
|
|
309
394
|
settings: {
|
|
310
|
-
"import/extensions":
|
|
311
|
-
|
|
312
|
-
".ts",
|
|
313
|
-
".jsx",
|
|
314
|
-
".tsx",
|
|
315
|
-
".mjs",
|
|
316
|
-
".mts",
|
|
317
|
-
".mtsx",
|
|
318
|
-
".cjs",
|
|
319
|
-
".cts",
|
|
320
|
-
".ctsx",
|
|
321
|
-
],
|
|
395
|
+
"import/extensions": typescriptSupportedExtensions,
|
|
396
|
+
"import/external-module-folders": ["node_modules", "node_modules/@types"],
|
|
322
397
|
"import/parsers": {
|
|
323
|
-
"@typescript-eslint/parser":
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
".ctsx",
|
|
330
|
-
],
|
|
398
|
+
"@typescript-eslint/parser": typescriptExtensions,
|
|
399
|
+
},
|
|
400
|
+
"import/resolver": {
|
|
401
|
+
typescript: {
|
|
402
|
+
extensions: typescriptSupportedExtensions,
|
|
403
|
+
},
|
|
331
404
|
},
|
|
332
405
|
},
|
|
333
406
|
};
|
|
334
|
-
var typescript =
|
|
407
|
+
var typescript = mergeConfigs(baseConfig, settings);
|
|
335
408
|
|
|
336
409
|
module.exports = typescript;
|
package/dist/typescript.mjs
CHANGED
|
@@ -1,12 +1,97 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deepmergeCustom } from 'deepmerge-ts';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const typescriptExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
4
|
+
const typescriptDeclarationExtensions = [".d.ts", ".d.mts", ".d.cts"];
|
|
5
|
+
const jsExtensions = [".js", ".mjs", ".cjs"];
|
|
6
|
+
const jsxExtensions = [".jsx", ".tsx"];
|
|
7
|
+
const commonJsExtensions = [".cjs", ".cts"];
|
|
8
|
+
const typescriptSupportedExtensions = [
|
|
9
|
+
...new Set([
|
|
10
|
+
...typescriptExtensions,
|
|
11
|
+
...typescriptDeclarationExtensions,
|
|
12
|
+
...jsExtensions,
|
|
13
|
+
...jsxExtensions,
|
|
14
|
+
]),
|
|
15
|
+
];
|
|
16
|
+
[`**/*{${typescriptExtensions.join(",")}}`];
|
|
17
|
+
const typescriptDeclarationFiles = [
|
|
18
|
+
`**/*{${typescriptDeclarationExtensions.join(",")}}`,
|
|
19
|
+
];
|
|
20
|
+
const commonJsFiles = [`**/*{${commonJsExtensions.join(",")}}`];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Merge multiple eslint configs into one.
|
|
24
|
+
*/
|
|
25
|
+
const mergeConfigs = deepmergeCustom({
|
|
26
|
+
metaDataUpdater: (previousMeta, metaMeta) => {
|
|
27
|
+
if (previousMeta === undefined) {
|
|
28
|
+
if (metaMeta.key === undefined) {
|
|
29
|
+
return { keyPath: [] };
|
|
30
|
+
}
|
|
31
|
+
return { keyPath: [metaMeta.key] };
|
|
32
|
+
}
|
|
33
|
+
if (metaMeta.key === undefined) {
|
|
34
|
+
return previousMeta;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...metaMeta,
|
|
38
|
+
keyPath: [...previousMeta.keyPath, metaMeta.key],
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
mergeArrays(values, utils, meta) {
|
|
42
|
+
if (isRuleSettings(meta)) {
|
|
43
|
+
return mergeRuleSettings(values, utils);
|
|
44
|
+
}
|
|
45
|
+
return [...new Set(utils.defaultMergeFunctions.mergeArrays(values))];
|
|
46
|
+
},
|
|
47
|
+
mergeOthers(values, utils, meta) {
|
|
48
|
+
if (isRuleSettings(meta)) {
|
|
49
|
+
return mergeRuleSettings(values, utils);
|
|
50
|
+
}
|
|
51
|
+
return utils.actions.defaultMerge;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Based on the meta data, should the current data be for rule settings.
|
|
56
|
+
*/
|
|
57
|
+
function isRuleSettings(meta) {
|
|
58
|
+
return (meta !== undefined &&
|
|
59
|
+
((meta.keyPath.length === 2 && meta.keyPath[0] === "rules") ||
|
|
60
|
+
(meta.keyPath.length === 4 &&
|
|
61
|
+
meta.keyPath[1] === "overrides" &&
|
|
62
|
+
typeof meta.keyPath[2] === "number" &&
|
|
63
|
+
meta.keyPath[3] === "rules")));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Merge eslint rule settings.
|
|
67
|
+
*
|
|
68
|
+
* @throws When invalid rule setting syntax are given.
|
|
69
|
+
*/
|
|
70
|
+
function mergeRuleSettings(values, utils) {
|
|
71
|
+
const settingsData = values.findLast((value) => Array.isArray(value) && value.length >= 2);
|
|
72
|
+
if (settingsData === undefined) {
|
|
73
|
+
return utils.actions.defaultMerge;
|
|
74
|
+
}
|
|
75
|
+
const severityData = values.at(-1);
|
|
76
|
+
const severity = Array.isArray(severityData)
|
|
77
|
+
? severityData[0]
|
|
78
|
+
: severityData;
|
|
79
|
+
if (severity === "off" || severity === 0) {
|
|
80
|
+
return severity;
|
|
81
|
+
}
|
|
82
|
+
if (severity !== "error" &&
|
|
83
|
+
severity !== 2 &&
|
|
84
|
+
severity !== "warn" &&
|
|
85
|
+
severity !== 1) {
|
|
86
|
+
throw new Error(`Unknow rule severity: "${String(severity)}"`);
|
|
87
|
+
}
|
|
88
|
+
const settings = settingsData.slice(1);
|
|
89
|
+
return [severity, ...settings];
|
|
90
|
+
}
|
|
5
91
|
|
|
6
92
|
const settings = {
|
|
7
93
|
plugins: ["@typescript-eslint"],
|
|
8
94
|
extends: [
|
|
9
|
-
"plugin:import/typescript",
|
|
10
95
|
"plugin:@typescript-eslint/eslint-recommended",
|
|
11
96
|
"plugin:@typescript-eslint/recommended",
|
|
12
97
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
|
@@ -305,30 +390,18 @@ const baseConfig = {
|
|
|
305
390
|
"space-infix-ops": "off",
|
|
306
391
|
},
|
|
307
392
|
settings: {
|
|
308
|
-
"import/extensions":
|
|
309
|
-
|
|
310
|
-
".ts",
|
|
311
|
-
".jsx",
|
|
312
|
-
".tsx",
|
|
313
|
-
".mjs",
|
|
314
|
-
".mts",
|
|
315
|
-
".mtsx",
|
|
316
|
-
".cjs",
|
|
317
|
-
".cts",
|
|
318
|
-
".ctsx",
|
|
319
|
-
],
|
|
393
|
+
"import/extensions": typescriptSupportedExtensions,
|
|
394
|
+
"import/external-module-folders": ["node_modules", "node_modules/@types"],
|
|
320
395
|
"import/parsers": {
|
|
321
|
-
"@typescript-eslint/parser":
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
".ctsx",
|
|
328
|
-
],
|
|
396
|
+
"@typescript-eslint/parser": typescriptExtensions,
|
|
397
|
+
},
|
|
398
|
+
"import/resolver": {
|
|
399
|
+
typescript: {
|
|
400
|
+
extensions: typescriptSupportedExtensions,
|
|
401
|
+
},
|
|
329
402
|
},
|
|
330
403
|
},
|
|
331
404
|
};
|
|
332
|
-
var typescript =
|
|
405
|
+
var typescript = mergeConfigs(baseConfig, settings);
|
|
333
406
|
|
|
334
407
|
export { typescript as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebeccastevens/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "My ESLint shareable config.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint config"
|
|
@@ -44,18 +44,22 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "
|
|
47
|
+
"build": "pnpm run build:node",
|
|
48
|
+
"build:node": "rimraf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
48
49
|
"cz": "git-cz",
|
|
49
|
-
"generate-
|
|
50
|
+
"generate-preview": "ts-node -P scripts/tsconfig.json -r tsconfig-paths/register scripts/generate-preview.ts",
|
|
50
51
|
"lint": "pnpm run lint:js && pnpm run lint:md && pnpm run lint:prettier && pnpm run lint:knip && pnpm run lint:spelling",
|
|
51
|
-
"lint:js": "pnpm run build &&
|
|
52
|
-
"lint:js-fix": "pnpm run
|
|
53
|
-
"lint:knip": "
|
|
52
|
+
"lint:js": "pnpm run build && eslint .",
|
|
53
|
+
"lint:js-fix": "pnpm run build && eslint . --fix",
|
|
54
|
+
"lint:knip": "pnpm run lint:knip:development && pnpm run lint:knip:production",
|
|
55
|
+
"lint:knip:development": "knip --exclude exports",
|
|
56
|
+
"lint:knip:production": "knip --production --strict --exclude exports",
|
|
54
57
|
"lint:md": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
|
|
55
58
|
"lint:prettier": "prettier \"**/*\" --ignore-unknown --list-different",
|
|
56
59
|
"lint:prettier-fix": "prettier \"**/*\" --ignore-unknown --write",
|
|
57
60
|
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
58
61
|
"prepare": "husky install",
|
|
62
|
+
"release": "semantic-release",
|
|
59
63
|
"test": "echo no tests",
|
|
60
64
|
"type-check": "tsc --noEmit"
|
|
61
65
|
},
|
|
@@ -66,7 +70,6 @@
|
|
|
66
70
|
"@commitlint/cli": "17.4.4",
|
|
67
71
|
"@commitlint/config-conventional": "17.4.4",
|
|
68
72
|
"@cspell/dict-cryptocurrencies": "3.0.1",
|
|
69
|
-
"@rebeccastevens/eslint-config": "1.5.3",
|
|
70
73
|
"@rollup/plugin-commonjs": "24.0.1",
|
|
71
74
|
"@rollup/plugin-node-resolve": "15.0.1",
|
|
72
75
|
"@rollup/plugin-typescript": "11.0.0",
|
|
@@ -76,13 +79,15 @@
|
|
|
76
79
|
"@semantic-release/github": "8.0.7",
|
|
77
80
|
"@semantic-release/npm": "9.0.2",
|
|
78
81
|
"@semantic-release/release-notes-generator": "10.0.3",
|
|
79
|
-
"@types/eslint": "8.21.
|
|
80
|
-
"@types/
|
|
82
|
+
"@types/eslint": "8.21.2",
|
|
83
|
+
"@types/eslint-config-prettier": "^6.11.0",
|
|
84
|
+
"@types/eslint-plugin-prettier": "^3.1.0",
|
|
85
|
+
"@types/node": "18.15.3",
|
|
81
86
|
"@types/rollup-plugin-auto-external": "2.0.2",
|
|
82
87
|
"@typescript-eslint/eslint-plugin": "5.55.0",
|
|
83
88
|
"@typescript-eslint/parser": "5.55.0",
|
|
84
89
|
"commitizen": "4.3.0",
|
|
85
|
-
"cspell": "6.
|
|
90
|
+
"cspell": "6.30.0",
|
|
86
91
|
"cz-conventional-changelog": "3.3.0",
|
|
87
92
|
"eslint": "8.36.0",
|
|
88
93
|
"eslint-config-prettier": "8.7.0",
|
|
@@ -90,7 +95,7 @@
|
|
|
90
95
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
91
96
|
"eslint-plugin-functional": "5.0.6",
|
|
92
97
|
"eslint-plugin-import": "2.27.5",
|
|
93
|
-
"eslint-plugin-jsdoc": "40.0.
|
|
98
|
+
"eslint-plugin-jsdoc": "40.0.3",
|
|
94
99
|
"eslint-plugin-markdown": "3.0.0",
|
|
95
100
|
"eslint-plugin-node": "11.1.0",
|
|
96
101
|
"eslint-plugin-optimize-regex": "1.2.1",
|
|
@@ -99,7 +104,7 @@
|
|
|
99
104
|
"eslint-plugin-sonarjs": "0.18.0",
|
|
100
105
|
"eslint-plugin-unicorn": "46.0.0",
|
|
101
106
|
"husky": "8.0.3",
|
|
102
|
-
"knip": "2.0.0-
|
|
107
|
+
"knip": "2.0.0-beta.0",
|
|
103
108
|
"lint-staged": "13.2.0",
|
|
104
109
|
"markdownlint-cli": "0.33.0",
|
|
105
110
|
"prettier": "2.8.4",
|
|
@@ -107,11 +112,11 @@
|
|
|
107
112
|
"rimraf": "4.4.0",
|
|
108
113
|
"rollup": "3.19.1",
|
|
109
114
|
"rollup-plugin-auto-external": "2.0.0",
|
|
110
|
-
"semantic-release": "20.1.
|
|
115
|
+
"semantic-release": "20.1.3",
|
|
111
116
|
"ts-node": "10.9.1",
|
|
112
117
|
"tsconfig-paths": "4.1.2",
|
|
113
118
|
"tslib": "2.5.0",
|
|
114
|
-
"typescript": "
|
|
119
|
+
"typescript": "5.0.2"
|
|
115
120
|
},
|
|
116
121
|
"peerDependencies": {
|
|
117
122
|
"@typescript-eslint/eslint-plugin": "*",
|
|
@@ -131,6 +136,6 @@
|
|
|
131
136
|
},
|
|
132
137
|
"packageManager": "pnpm@7.29.0",
|
|
133
138
|
"engines": {
|
|
134
|
-
"node": "
|
|
139
|
+
"node": ">=18.12.1"
|
|
135
140
|
}
|
|
136
141
|
}
|