@eslinted/core 31.1.1 → 31.2.1
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/factory.d.ts +12 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +56 -34
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tests/index.spec.js +6 -3
- package/dist/tests/index.spec.js.map +1 -1
- package/package.json +1 -4
- package/src/factory.ts +92 -53
- package/src/index.ts +14 -18
- package/tests/index.spec.ts +8 -3
- package/typings/rules.d.ts +0 -24
package/dist/factory.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type Core from "./index.js";
|
|
2
|
-
export default function factory<Scope extends string, Optional extends Scope, RequiredPlugin extends string, RequiredParser extends Scope, Parser extends RequiredParser | Optional>(scopes: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[0], optional: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[1], tree: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[2], imports: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[3], settings: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[4], defaults: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[5], extensions?: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[6]):
|
|
2
|
+
export default function factory<Scope extends string, Optional extends Scope, RequiredPlugin extends string, RequiredParser extends Scope, Parser extends RequiredParser | Optional>(scopes: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[0], optional: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[1], tree: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[2], imports: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[3], settings: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[4], defaults: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[5], extensions?: Parameters<typeof Core<Scope, Optional, RequiredPlugin, RequiredParser, Parser>>[6]): {
|
|
3
|
+
plugins?: unknown;
|
|
4
|
+
rules?: (typeof defaults.rules)[Scope][number]["rules"];
|
|
5
|
+
files?: Array<string | [
|
|
6
|
+
string,
|
|
7
|
+
string
|
|
8
|
+
]>;
|
|
9
|
+
ignores?: string[];
|
|
10
|
+
languageOptions?: unknown;
|
|
11
|
+
language?: string;
|
|
12
|
+
processor?: string;
|
|
13
|
+
}[];
|
|
3
14
|
//# sourceMappingURL=factory.d.ts.map
|
package/dist/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,GAAG,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,KAAK,SAAS,MAAM,EACpB,QAAQ,SAAS,KAAK,EACtB,cAAc,SAAS,MAAM,EAC7B,cAAc,SAAS,KAAK,EAC5B,MAAM,SAAS,cAAc,GAAG,QAAQ,EAExC,MAAM,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3F,QAAQ,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7F,IAAI,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EACzF,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5F,QAAQ,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7F,QAAQ,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7F,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;cAyGlF,OAAO;YACT,CAAA,OAAO,QAAQ,CAAC,KAAK,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;cAC9B,MAAM,EAAE;sBACA,OAAO;eACd,MAAM;gBACL,MAAM;IAqBvB"}
|
package/dist/factory.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { defineConfig, globalIgnores, } from "@eslint/config-helpers";
|
|
2
1
|
export default function factory(scopes, optional, tree, imports, settings, defaults, extensions) {
|
|
3
2
|
const Scopes = new Set(scopes);
|
|
4
3
|
if (extensions) {
|
|
4
|
+
const global = extensions["*"];
|
|
5
|
+
if (global)
|
|
6
|
+
if (global.override
|
|
7
|
+
|| !defaults.ignores["*"])
|
|
8
|
+
defaults.ignores["*"] = global.ignores ?? [];
|
|
9
|
+
else if (global.ignores?.length)
|
|
10
|
+
void defaults.ignores["*"].push(...global.ignores);
|
|
5
11
|
for (const scope of optional)
|
|
6
12
|
if (extensions[scope]) {
|
|
7
13
|
imports.plugins[scope] = extensions[scope].plugin;
|
|
@@ -11,47 +17,63 @@ export default function factory(scopes, optional, tree, imports, settings, defau
|
|
|
11
17
|
Scopes.delete(scope);
|
|
12
18
|
for (const scope of Scopes)
|
|
13
19
|
if (extensions[scope]) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
const extension = extensions[scope];
|
|
21
|
+
if (extension.files)
|
|
22
|
+
void defaults.files[scope].push(...extension.files);
|
|
23
|
+
if (extension.ignores)
|
|
17
24
|
if (defaults.ignores[scope])
|
|
18
|
-
void defaults.ignores[scope].push(...
|
|
25
|
+
void defaults.ignores[scope].push(...extension.ignores);
|
|
19
26
|
else
|
|
20
|
-
defaults.ignores[scope] =
|
|
21
|
-
if (
|
|
22
|
-
defaults.rules[scope][defaults.rules[scope].length] = { rules:
|
|
27
|
+
defaults.ignores[scope] = extension.ignores;
|
|
28
|
+
if (extension.rules)
|
|
29
|
+
defaults.rules[scope][defaults.rules[scope].length] = { rules: extension.rules };
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
32
|
for (const [scope, parents] of tree)
|
|
26
33
|
if (Scopes.has(scope)
|
|
27
|
-
&& defaults.files[scope].length)
|
|
34
|
+
&& defaults.files[scope].length) {
|
|
35
|
+
const { [scope]: files } = defaults.files;
|
|
28
36
|
for (const parent of parents)
|
|
29
|
-
void defaults.files[parent].push(...
|
|
30
|
-
|
|
31
|
-
if (extensions["*"])
|
|
32
|
-
if (extensions["*"].override
|
|
33
|
-
|| !defaults.ignores["*"])
|
|
34
|
-
defaults.ignores["*"] = extensions["*"].ignores ?? [];
|
|
35
|
-
else if (extensions["*"].ignores?.length)
|
|
36
|
-
void defaults.ignores["*"].push(...extensions["*"].ignores);
|
|
37
|
+
void defaults.files[parent].push(...files);
|
|
38
|
+
}
|
|
37
39
|
const enabledScopes = [...Scopes]
|
|
38
|
-
.filter(scope => defaults.files[scope].length)
|
|
39
|
-
.filter(scope =>
|
|
40
|
-
for (const scope of enabledScopes)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
.filter(scope => defaults.files[scope].length), setScopes = enabledScopes
|
|
41
|
+
.filter(scope => settings[scope]);
|
|
42
|
+
for (const scope of enabledScopes) {
|
|
43
|
+
const files = defaults.files[scope], ignores = defaults.ignores[scope] ?? [];
|
|
44
|
+
for (const rule of defaults.rules[scope]) {
|
|
45
|
+
rule.files = files;
|
|
46
|
+
rule.ignores = ignores;
|
|
47
|
+
}
|
|
48
|
+
const setting = settings[scope];
|
|
49
|
+
if (setting) {
|
|
50
|
+
setting.files = files;
|
|
51
|
+
setting.ignores = ignores;
|
|
52
|
+
if (setting.languageOptions) {
|
|
53
|
+
const { parser, parserOptions: { parser: subparser } = {}, } = setting.languageOptions;
|
|
54
|
+
if (parser)
|
|
55
|
+
setting
|
|
56
|
+
.languageOptions
|
|
57
|
+
.parser = imports.parsers[parser];
|
|
58
|
+
if (subparser)
|
|
59
|
+
setting
|
|
60
|
+
.languageOptions
|
|
61
|
+
.parserOptions
|
|
62
|
+
.parser = imports.parsers[subparser];
|
|
46
63
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const configs = enabledScopes.flatMap(scope => defaults.rules[scope]), rulesGlobalTotal = configs.length + 2;
|
|
67
|
+
configs.length = rulesGlobalTotal + setScopes.length;
|
|
68
|
+
configs[rulesGlobalTotal - 2] = {
|
|
69
|
+
plugins: imports.plugins,
|
|
70
|
+
};
|
|
71
|
+
configs[rulesGlobalTotal - 1] = {
|
|
72
|
+
ignores: defaults.ignores["*"] ?? [],
|
|
73
|
+
};
|
|
74
|
+
setScopes.forEach((scope, i) => {
|
|
75
|
+
configs[rulesGlobalTotal + i] = settings[scope];
|
|
76
|
+
});
|
|
77
|
+
return configs;
|
|
56
78
|
}
|
|
57
79
|
//# sourceMappingURL=factory.js.map
|
package/dist/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,OAAO,CAO7B,MAA2F,EAC3F,QAA6F,EAC7F,IAAyF,EACzF,OAA4F,EAC5F,QAA6F,EAC7F,QAA6F,EAC7F,UAAgG;IAEhG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAE/B,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,MAAM;YACR,IACE,MAAM,CAAC,QAAQ;mBACZ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC;gBAEzB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;iBAE7C,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM;gBACxB,KAAK,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAC7B,GAAG,MAAM,CAAC,OAAO,CAClB,CAAC;QAER,KAAK,MAAM,KAAK,IAAI,QAAQ;YAC1B,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,MAA0C,CAAC;gBACtF,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,MAA0C,CAAC;YAExF,CAAC;;gB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AK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAC/B,EACD,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAEtC,OAAO,CAAC,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC;IACrD,OAAO,CAAC,gBAAgB,GAAG,CAAC,CAAC,GAAG;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;IACF,OAAO,CAAC,gBAAgB,GAAG,CAAC,CAAC,GAAG;QAC9B,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;KACrC,CAAC;IACF,SAAS,CAAC,OAAO,CACf,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QACX,OAAO,CAAC,gBAAgB,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAE,CAAC;IACnD,CAAC,CACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Settings, Defaults, Extensions } from "../typings";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Rules } from "../typings/rules";
|
|
3
3
|
export default function <Scope extends string, Optional extends Scope, RequiredPlugin extends string, RequiredParser extends Scope, Parser extends RequiredParser | Optional>(scopes: readonly Scope[], optional: readonly Optional[], tree: Array<readonly [Scope, readonly Scope[]]>, imports: {
|
|
4
4
|
plugins: Record<RequiredPlugin, unknown> & Partial<Record<Optional, unknown>>;
|
|
5
5
|
parsers: Record<RequiredParser, unknown> & Partial<Record<Optional, unknown>>;
|
|
6
6
|
}, settings: Settings<Scope, Parser>, defaults: Defaults<Scope>, extensions?: Extensions<Scope, Optional>): Array<{
|
|
7
|
-
files?:
|
|
8
|
-
ignores?:
|
|
9
|
-
rules?:
|
|
7
|
+
files?: Array<string | [string, string]>;
|
|
8
|
+
ignores?: string[];
|
|
9
|
+
rules?: Rules;
|
|
10
10
|
}>;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,WACZ,KAAK,SAAS,MAAM,EACpB,QAAQ,SAAS,KAAK,EACtB,cAAc,SAAS,MAAM,EAC7B,cAAc,SAAS,KAAK,EAC5B,MAAM,SAAS,cAAc,GAAG,QAAQ,EAExC,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,QAAQ,EAAE,SAAS,QAAQ,EAAE,EAC7B,IAAI,EAAE,KAAK,CACT,SAAS,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC,CACnC,EACD,OAAO,EAAE;IACP,OAAO,EACH,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,OAAO,EACH,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;CACxC,EACD,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,EACjC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,EACzB,UAAU,CAAC,EAAE,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,GACvC,KAAK,CACN;IACE,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CACF,CAUA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAQhC,MAAM,CAAC,OAAO,WAOZ,MAAwB,EACxB,QAA6B,EAC7B,IAEC,EACD,OAOC,EACD,QAAiC,EACjC,QAAyB,EACzB,UAAwC;IAQxC,OAAO,OAAO,CACZ,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,CACX,CAAC;AACJ,CAAC"}
|
package/dist/tests/index.spec.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "chai/register-should.js";
|
|
2
2
|
import Core from "../index.js";
|
|
3
3
|
import { scopes, optional, tree, imports, settings, defaults, extensions, } from "./index.input.spec.js";
|
|
4
|
-
const configs = Core(scopes, optional, tree, imports, settings, defaults, extensions);
|
|
4
|
+
const configs = Core(scopes, optional, tree, imports, settings, defaults, extensions), Scopes = new Set(scopes);
|
|
5
|
+
for (const scope of optional)
|
|
6
|
+
Scopes.delete(scope);
|
|
5
7
|
describe("Core", () => {
|
|
6
8
|
describe("module", () => {
|
|
7
9
|
it("is a function", () => {
|
|
@@ -17,10 +19,11 @@ describe("Core", () => {
|
|
|
17
19
|
.an("array")
|
|
18
20
|
.not.empty;
|
|
19
21
|
});
|
|
20
|
-
it(`length >= (
|
|
22
|
+
it(`length >= (*/plugins + */ignores + ${Scopes.size} scopes = ${Scopes.size + 2}) [Actual: ${configs.length}]`, () => {
|
|
21
23
|
configs
|
|
22
24
|
.should.have
|
|
23
|
-
.lengthOf
|
|
25
|
+
.lengthOf
|
|
26
|
+
.at.least(Scopes.size + 2);
|
|
24
27
|
});
|
|
25
28
|
it("of config objects", () => {
|
|
26
29
|
for (const config of configs)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../tests/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,IAAI,MAAM,IAAI,CAAC;AACtB,OAAO,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,GAAG,IAAI,CAClB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../tests/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,IAAI,MAAM,IAAI,CAAC;AACtB,OAAO,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,GAAG,IAAI,CAClB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,CACX,EACD,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;AAEzB,KAAK,MAAM,KAAK,IAAI,QAAQ;IAC1B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEvB,QAAQ,CACN,MAAM,EACN,GAAG,EAAE;IACH,QAAQ,CACN,QAAQ,EACR,GAAG,EAAE;QACH,EAAE,CACA,eAAe,EACf,GAAG,EAAE;YACH,IAAI;iBACD,MAAM,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@
|
|
|
3
3
|
"$schema": "https://json.schemastore.org/package",
|
|
4
4
|
"$help": "https://docs.npmjs.com/cli/configuring-npm/package-json",
|
|
5
5
|
"name": "@eslinted/core",
|
|
6
|
-
"version": "31.
|
|
6
|
+
"version": "31.2.1",
|
|
7
7
|
"repository": "github:jimmy-zhening-luo/linted-core",
|
|
8
8
|
"description": "Internal core for npm package `linted`, responsible for producing an array of fully-formed ESLint configurations according to `linted` spec.",
|
|
9
9
|
"keywords": [],
|
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"types": "dist/index.d.ts",
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@eslint/config-helpers": "^0.5.0"
|
|
22
|
-
},
|
|
23
20
|
"devDependencies": {
|
|
24
21
|
"@types/chai": "^5.2.3",
|
|
25
22
|
"@types/mocha": "^10.0.10",
|
package/src/factory.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineConfig,
|
|
3
|
-
globalIgnores,
|
|
4
|
-
} from "@eslint/config-helpers";
|
|
5
1
|
import type Core from ".";
|
|
6
|
-
import type { MutableRuleConfigs } from "../typings/rules";
|
|
7
2
|
|
|
8
3
|
export default function factory<
|
|
9
4
|
Scope extends string,
|
|
@@ -23,33 +18,50 @@ export default function factory<
|
|
|
23
18
|
const Scopes = new Set(scopes);
|
|
24
19
|
|
|
25
20
|
if (extensions) {
|
|
21
|
+
const global = extensions["*"];
|
|
22
|
+
|
|
23
|
+
if (global)
|
|
24
|
+
if (
|
|
25
|
+
global.override
|
|
26
|
+
|| !defaults.ignores["*"]
|
|
27
|
+
)
|
|
28
|
+
defaults.ignores["*"] = global.ignores ?? [];
|
|
29
|
+
else
|
|
30
|
+
if (global.ignores?.length)
|
|
31
|
+
void defaults.ignores["*"].push(
|
|
32
|
+
...global.ignores,
|
|
33
|
+
);
|
|
34
|
+
|
|
26
35
|
for (const scope of optional)
|
|
27
36
|
if (extensions[scope]) {
|
|
28
37
|
imports.plugins[scope] = extensions[scope].plugin as typeof imports.plugins[Optional];
|
|
29
38
|
imports.parsers[scope] = extensions[scope].parser as typeof imports.parsers[Optional];
|
|
39
|
+
|
|
30
40
|
}
|
|
31
41
|
else
|
|
32
42
|
Scopes.delete(scope);
|
|
33
43
|
|
|
34
44
|
for (const scope of Scopes)
|
|
35
45
|
if (extensions[scope]) {
|
|
36
|
-
|
|
46
|
+
const extension = extensions[scope]!;
|
|
47
|
+
|
|
48
|
+
if (extension.files)
|
|
37
49
|
void defaults.files[scope].push(
|
|
38
|
-
...
|
|
50
|
+
...extension.files,
|
|
39
51
|
);
|
|
40
52
|
|
|
41
|
-
if (
|
|
53
|
+
if (extension.ignores)
|
|
42
54
|
if (defaults.ignores[scope])
|
|
43
55
|
void defaults.ignores[scope].push(
|
|
44
|
-
...
|
|
56
|
+
...extension.ignores,
|
|
45
57
|
);
|
|
46
58
|
else
|
|
47
|
-
defaults.ignores[scope] =
|
|
59
|
+
defaults.ignores[scope] = extension.ignores;
|
|
48
60
|
|
|
49
|
-
if (
|
|
61
|
+
if (extension.rules)
|
|
50
62
|
defaults.rules[scope][
|
|
51
63
|
defaults.rules[scope].length
|
|
52
|
-
] = { rules:
|
|
64
|
+
] = { rules: extension.rules };
|
|
53
65
|
}
|
|
54
66
|
}
|
|
55
67
|
|
|
@@ -57,53 +69,80 @@ export default function factory<
|
|
|
57
69
|
if (
|
|
58
70
|
Scopes.has(scope)
|
|
59
71
|
&& defaults.files[scope].length
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
void defaults.files[parent].push(
|
|
63
|
-
...defaults.files[scope],
|
|
64
|
-
);
|
|
72
|
+
) {
|
|
73
|
+
const { [scope]: files } = defaults.files;
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
extensions["*"].override
|
|
70
|
-
|| !defaults.ignores["*"]
|
|
71
|
-
)
|
|
72
|
-
defaults.ignores["*"] = extensions["*"].ignores ?? [];
|
|
73
|
-
else
|
|
74
|
-
if (
|
|
75
|
-
extensions["*"].ignores?.length
|
|
76
|
-
)
|
|
77
|
-
void defaults.ignores["*"].push(
|
|
78
|
-
...extensions["*"].ignores,
|
|
79
|
-
);
|
|
75
|
+
for (const parent of parents)
|
|
76
|
+
void defaults.files[parent].push(...files);
|
|
77
|
+
}
|
|
80
78
|
|
|
81
79
|
const enabledScopes = [...Scopes]
|
|
82
|
-
.filter(scope => defaults.files[scope].length)
|
|
83
|
-
|
|
80
|
+
.filter(scope => defaults.files[scope].length),
|
|
81
|
+
setScopes = enabledScopes
|
|
82
|
+
.filter(scope => settings[scope]);
|
|
83
|
+
|
|
84
|
+
for (const scope of enabledScopes) {
|
|
85
|
+
const files = defaults.files[scope],
|
|
86
|
+
ignores = defaults.ignores[scope] ?? [];
|
|
87
|
+
|
|
88
|
+
for (const rule of defaults.rules[scope]) {
|
|
89
|
+
(rule as typeof rule & { files: Array<string | [string, string]> }).files = files;
|
|
90
|
+
(rule as typeof rule & { ignores: string[] }).ignores = ignores;
|
|
91
|
+
}
|
|
84
92
|
|
|
85
|
-
|
|
86
|
-
if (settings[scope])
|
|
87
|
-
if (settings[scope].languageOptions) {
|
|
88
|
-
settings[scope].languageOptions.parser &&= imports.parsers[settings[scope].languageOptions.parser] as Parser;
|
|
93
|
+
const setting = settings[scope];
|
|
89
94
|
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
if (setting) {
|
|
96
|
+
(setting as typeof setting & { files: Array<string | [string, string]> }).files = files;
|
|
97
|
+
(setting as typeof setting & { ignores: string[] }).ignores = ignores;
|
|
98
|
+
|
|
99
|
+
if (setting.languageOptions) {
|
|
100
|
+
const {
|
|
101
|
+
parser,
|
|
102
|
+
parserOptions: { parser: subparser } = {},
|
|
103
|
+
} = setting.languageOptions;
|
|
104
|
+
|
|
105
|
+
if (parser)
|
|
106
|
+
setting
|
|
107
|
+
.languageOptions
|
|
108
|
+
.parser = imports.parsers[parser] as Parser;
|
|
109
|
+
|
|
110
|
+
if (subparser)
|
|
111
|
+
setting
|
|
112
|
+
.languageOptions
|
|
113
|
+
.parserOptions!
|
|
114
|
+
.parser = imports.parsers[subparser] as Parser;
|
|
92
115
|
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const configs: Array<
|
|
120
|
+
{
|
|
121
|
+
plugins?: unknown;
|
|
122
|
+
rules?: typeof defaults.rules[Scope][number]["rules"];
|
|
123
|
+
files?: Array<string | [string, string]>;
|
|
124
|
+
ignores?: string[];
|
|
125
|
+
languageOptions?: unknown;
|
|
126
|
+
language?: string;
|
|
127
|
+
processor?: string;
|
|
128
|
+
}
|
|
129
|
+
> = enabledScopes.flatMap(
|
|
130
|
+
scope => defaults.rules[scope],
|
|
131
|
+
),
|
|
132
|
+
rulesGlobalTotal = configs.length + 2;
|
|
93
133
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
}),
|
|
107
|
-
),
|
|
134
|
+
configs.length = rulesGlobalTotal + setScopes.length;
|
|
135
|
+
configs[rulesGlobalTotal - 2] = {
|
|
136
|
+
plugins: imports.plugins,
|
|
137
|
+
};
|
|
138
|
+
configs[rulesGlobalTotal - 1] = {
|
|
139
|
+
ignores: defaults.ignores["*"] ?? [],
|
|
140
|
+
};
|
|
141
|
+
setScopes.forEach(
|
|
142
|
+
(scope, i) => {
|
|
143
|
+
configs[rulesGlobalTotal + i] = settings[scope]!;
|
|
144
|
+
},
|
|
108
145
|
);
|
|
146
|
+
|
|
147
|
+
return configs;
|
|
109
148
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import factory from "./factory";
|
|
2
2
|
import type {
|
|
3
|
-
Settings,
|
|
3
|
+
Settings,
|
|
4
|
+
Defaults,
|
|
5
|
+
Extensions,
|
|
4
6
|
} from "../typings";
|
|
5
|
-
import type {
|
|
7
|
+
import type { Rules } from "../typings/rules";
|
|
6
8
|
|
|
7
9
|
export default function<
|
|
8
10
|
Scope extends string,
|
|
@@ -24,16 +26,16 @@ export default function<
|
|
|
24
26
|
& Record<RequiredParser, unknown>
|
|
25
27
|
& Partial<Record<Optional, unknown>>;
|
|
26
28
|
},
|
|
27
|
-
settings: Settings<
|
|
28
|
-
Scope,
|
|
29
|
-
Parser
|
|
30
|
-
>,
|
|
29
|
+
settings: Settings<Scope, Parser>,
|
|
31
30
|
defaults: Defaults<Scope>,
|
|
32
|
-
extensions?: Extensions<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
extensions?: Extensions<Scope, Optional>,
|
|
32
|
+
): Array<
|
|
33
|
+
{
|
|
34
|
+
files?: Array<string | [string, string]>;
|
|
35
|
+
ignores?: string[];
|
|
36
|
+
rules?: Rules;
|
|
37
|
+
}
|
|
38
|
+
> {
|
|
37
39
|
return factory(
|
|
38
40
|
scopes,
|
|
39
41
|
optional,
|
|
@@ -42,11 +44,5 @@ export default function<
|
|
|
42
44
|
settings,
|
|
43
45
|
defaults,
|
|
44
46
|
extensions,
|
|
45
|
-
)
|
|
46
|
-
{
|
|
47
|
-
files?: (string | string[])[];
|
|
48
|
-
ignores?: (string)[];
|
|
49
|
-
rules?: MutableRules;
|
|
50
|
-
}
|
|
51
|
-
>;
|
|
47
|
+
);
|
|
52
48
|
}
|
package/tests/index.spec.ts
CHANGED
|
@@ -18,7 +18,11 @@ const configs = Core(
|
|
|
18
18
|
settings,
|
|
19
19
|
defaults,
|
|
20
20
|
extensions,
|
|
21
|
-
)
|
|
21
|
+
),
|
|
22
|
+
Scopes = new Set(scopes);
|
|
23
|
+
|
|
24
|
+
for (const scope of optional)
|
|
25
|
+
Scopes.delete(scope);
|
|
22
26
|
|
|
23
27
|
describe(
|
|
24
28
|
"Core",
|
|
@@ -49,11 +53,12 @@ describe(
|
|
|
49
53
|
},
|
|
50
54
|
);
|
|
51
55
|
it(
|
|
52
|
-
`length >= (
|
|
56
|
+
`length >= (*/plugins + */ignores + ${Scopes.size} scopes = ${Scopes.size + 2}) [Actual: ${configs.length}]`,
|
|
53
57
|
() => {
|
|
54
58
|
configs
|
|
55
59
|
.should.have
|
|
56
|
-
.lengthOf
|
|
60
|
+
.lengthOf
|
|
61
|
+
.at.least(Scopes.size + 2);
|
|
57
62
|
},
|
|
58
63
|
);
|
|
59
64
|
it(
|
package/typings/rules.d.ts
CHANGED
|
@@ -10,27 +10,3 @@ export type Rules = Record<
|
|
|
10
10
|
string,
|
|
11
11
|
Readonly<Rule>
|
|
12
12
|
>;
|
|
13
|
-
|
|
14
|
-
export type MutableRules = {
|
|
15
|
-
[Rule in keyof Rules]: Mutable<Rules[Rule]>
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type MutableRuleConfigs<Configs> = Configs extends Array<
|
|
19
|
-
infer Config extends {
|
|
20
|
-
rules: Rules;
|
|
21
|
-
}
|
|
22
|
-
>
|
|
23
|
-
? Array<
|
|
24
|
-
{
|
|
25
|
-
rules: {
|
|
26
|
-
[Rule in keyof Config["rules"]]: Mutable<
|
|
27
|
-
Config["rules"][Rule]
|
|
28
|
-
>
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
>
|
|
32
|
-
: Configs;
|
|
33
|
-
|
|
34
|
-
export type Mutable<Rule> = Rule extends object
|
|
35
|
-
? { -readonly [Index in keyof Rule]: Rule[Index] }
|
|
36
|
-
: Rule;
|