@eslinted/core 13.0.0-rc.1 → 13.1.0-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/factory/factory.d.ts +175 -0
- package/dist/factory/factory.d.ts.map +1 -0
- package/dist/factory/factory.js +42 -0
- package/dist/factory/factory.js.map +1 -0
- package/dist/factory/index.d.ts +2 -3
- package/dist/factory/index.d.ts.map +1 -1
- package/dist/factory/index.js +2 -3
- package/dist/factory/index.js.map +1 -1
- package/dist/factory/ruleset.d.ts +3 -3
- package/dist/factory/ruleset.d.ts.map +1 -1
- package/dist/factory/ruleset.js +3 -3
- package/dist/factory/ruleset.js.map +1 -1
- package/dist/factory/{options → settings}/index.d.ts +1 -2
- package/dist/factory/settings/index.d.ts.map +1 -0
- package/dist/factory/settings/index.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/html.d.ts +2 -2
- package/dist/factory/settings/scopes/html.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/html.js +2 -2
- package/dist/factory/settings/scopes/html.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/js.d.ts +2 -2
- package/dist/factory/settings/scopes/js.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/js.js +2 -2
- package/dist/factory/settings/scopes/js.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/json.d.ts +2 -2
- package/dist/factory/settings/scopes/json.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/json.js +2 -2
- package/dist/factory/settings/scopes/json.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/jsonc.d.ts +2 -2
- package/dist/factory/settings/scopes/jsonc.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/jsonc.js +2 -2
- package/dist/factory/settings/scopes/jsonc.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/mocha.d.ts +3 -3
- package/dist/factory/settings/scopes/mocha.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/mocha.js +5 -4
- package/dist/factory/settings/scopes/mocha.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/svelte.d.ts +7 -7
- package/dist/factory/settings/scopes/svelte.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/svelte.js +2 -2
- package/dist/factory/settings/scopes/svelte.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/ts.d.ts +5 -5
- package/dist/factory/settings/scopes/ts.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/ts.js +2 -2
- package/dist/factory/settings/scopes/ts.js.map +1 -0
- package/dist/factory/{options → settings}/scopes/yml.d.ts +2 -2
- package/dist/factory/settings/scopes/yml.d.ts.map +1 -0
- package/dist/factory/{options → settings}/scopes/yml.js +2 -2
- package/dist/factory/settings/scopes/yml.js.map +1 -0
- package/dist/factory/settings/setting.d.ts +48 -0
- package/dist/factory/settings/setting.d.ts.map +1 -0
- package/dist/factory/settings/setting.js +20 -0
- package/dist/factory/settings/setting.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -21
- package/dist/index.js.map +1 -1
- package/dist/interface/config/index.d.ts +23 -0
- package/dist/interface/config/index.d.ts.map +1 -0
- package/dist/{config → interface/config}/index.js.map +1 -1
- package/dist/interface/config/rule.d.ts +7 -0
- package/dist/interface/config/rule.d.ts.map +1 -0
- package/dist/{config → interface/config}/rule.js.map +1 -1
- package/dist/interface/configs/globals/ignores.d.ts +6 -0
- package/dist/interface/configs/globals/ignores.d.ts.map +1 -0
- package/dist/interface/configs/globals/ignores.js +2 -0
- package/dist/interface/configs/globals/ignores.js.map +1 -0
- package/dist/interface/configs/globals/index.d.ts +5 -0
- package/dist/interface/configs/globals/index.d.ts.map +1 -0
- package/dist/interface/configs/globals/index.js +2 -0
- package/dist/interface/configs/globals/index.js.map +1 -0
- package/dist/interface/configs/globals/only/index.d.ts +2 -0
- package/dist/interface/configs/globals/only/index.d.ts.map +1 -0
- package/dist/interface/configs/globals/only/index.js +2 -0
- package/dist/interface/configs/globals/only/index.js.map +1 -0
- package/dist/interface/configs/globals/plugins.d.ts +6 -0
- package/dist/interface/configs/globals/plugins.d.ts.map +1 -0
- package/dist/interface/configs/globals/plugins.js +2 -0
- package/dist/interface/configs/globals/plugins.js.map +1 -0
- package/dist/interface/configs/globals/settings.d.ts +7 -0
- package/dist/interface/configs/globals/settings.d.ts.map +1 -0
- package/dist/interface/configs/globals/settings.js +2 -0
- package/dist/interface/configs/globals/settings.js.map +1 -0
- package/dist/interface/configs/index.d.ts +3 -0
- package/dist/interface/configs/index.d.ts.map +1 -0
- package/dist/interface/configs/index.js +2 -0
- package/dist/interface/configs/index.js.map +1 -0
- package/dist/interface/configs/scoped.d.ts +7 -0
- package/dist/interface/configs/scoped.d.ts.map +1 -0
- package/dist/interface/configs/scoped.js +2 -0
- package/dist/interface/configs/scoped.js.map +1 -0
- package/dist/interface/imports/index.d.ts +3 -3
- package/dist/interface/imports/index.d.ts.map +1 -1
- package/dist/interface/imports/parsers.d.ts +2 -0
- package/dist/interface/imports/parsers.d.ts.map +1 -0
- package/dist/interface/imports/parsers.js +2 -0
- package/dist/interface/imports/parsers.js.map +1 -0
- package/dist/interface/imports/plugins.d.ts +2 -0
- package/dist/interface/imports/plugins.d.ts.map +1 -0
- package/dist/interface/imports/plugins.js +2 -0
- package/dist/interface/imports/plugins.js.map +1 -0
- package/dist/interface/index.d.ts +2 -1
- package/dist/interface/index.d.ts.map +1 -1
- package/dist/interface/input.d.ts +13 -13
- package/dist/interface/input.d.ts.map +1 -1
- package/dist/interface/output.d.ts +7 -15
- package/dist/interface/output.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/factory/factory.ts +89 -0
- package/src/factory/index.ts +2 -3
- package/src/factory/ruleset.ts +9 -13
- package/src/factory/{options → settings}/index.ts +1 -2
- package/src/factory/settings/scopes/html.ts +16 -0
- package/src/factory/settings/scopes/js.ts +11 -0
- package/src/factory/settings/scopes/json.ts +16 -0
- package/src/factory/settings/scopes/jsonc.ts +16 -0
- package/src/factory/settings/scopes/mocha.ts +29 -0
- package/src/factory/{options → settings}/scopes/svelte.ts +9 -9
- package/src/factory/settings/scopes/ts.ts +28 -0
- package/src/factory/settings/scopes/yml.ts +17 -0
- package/src/factory/settings/setting.ts +63 -0
- package/src/index.ts +26 -75
- package/src/interface/config/index.ts +42 -0
- package/src/interface/config/rule.ts +14 -0
- package/src/interface/configs/globals/ignores.ts +10 -0
- package/src/interface/configs/globals/index.ts +4 -0
- package/src/interface/configs/globals/only/index.ts +4 -0
- package/src/interface/configs/globals/plugins.ts +10 -0
- package/src/interface/configs/globals/settings.ts +13 -0
- package/src/interface/configs/index.ts +2 -0
- package/src/interface/configs/scoped.ts +7 -0
- package/src/interface/imports/index.ts +2 -16
- package/src/interface/imports/parsers.ts +7 -0
- package/src/interface/imports/plugins.ts +9 -0
- package/src/interface/index.ts +2 -1
- package/src/interface/input.ts +15 -19
- package/src/interface/output.ts +7 -22
- package/dist/config/index.d.ts +0 -23
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/rule.d.ts +0 -7
- package/dist/config/rule.d.ts.map +0 -1
- package/dist/factory/global.d.ts +0 -29
- package/dist/factory/global.d.ts.map +0 -1
- package/dist/factory/global.js +0 -41
- package/dist/factory/global.js.map +0 -1
- package/dist/factory/options/index.d.ts.map +0 -1
- package/dist/factory/options/index.js.map +0 -1
- package/dist/factory/options/option.d.ts +0 -3002
- package/dist/factory/options/option.d.ts.map +0 -1
- package/dist/factory/options/option.js +0 -48
- package/dist/factory/options/option.js.map +0 -1
- package/dist/factory/options/proto.d.ts +0 -19
- package/dist/factory/options/proto.d.ts.map +0 -1
- package/dist/factory/options/proto.js +0 -2
- package/dist/factory/options/proto.js.map +0 -1
- package/dist/factory/options/scopes/html.d.ts.map +0 -1
- package/dist/factory/options/scopes/html.js.map +0 -1
- package/dist/factory/options/scopes/js.d.ts.map +0 -1
- package/dist/factory/options/scopes/js.js.map +0 -1
- package/dist/factory/options/scopes/json.d.ts.map +0 -1
- package/dist/factory/options/scopes/json.js.map +0 -1
- package/dist/factory/options/scopes/jsonc.d.ts.map +0 -1
- package/dist/factory/options/scopes/jsonc.js.map +0 -1
- package/dist/factory/options/scopes/mocha.d.ts.map +0 -1
- package/dist/factory/options/scopes/mocha.js.map +0 -1
- package/dist/factory/options/scopes/svelte.d.ts.map +0 -1
- package/dist/factory/options/scopes/svelte.js.map +0 -1
- package/dist/factory/options/scopes/ts.d.ts.map +0 -1
- package/dist/factory/options/scopes/ts.js.map +0 -1
- package/dist/factory/options/scopes/yml.d.ts.map +0 -1
- package/dist/factory/options/scopes/yml.js.map +0 -1
- package/dist/factory/scoped.d.ts +0 -13
- package/dist/factory/scoped.d.ts.map +0 -1
- package/dist/factory/scoped.js +0 -17
- package/dist/factory/scoped.js.map +0 -1
- package/src/config/index.ts +0 -42
- package/src/config/rule.ts +0 -14
- package/src/factory/global.ts +0 -45
- package/src/factory/options/option.ts +0 -98
- package/src/factory/options/proto.ts +0 -46
- package/src/factory/options/scopes/html.ts +0 -16
- package/src/factory/options/scopes/js.ts +0 -11
- package/src/factory/options/scopes/json.ts +0 -16
- package/src/factory/options/scopes/jsonc.ts +0 -16
- package/src/factory/options/scopes/mocha.ts +0 -29
- package/src/factory/options/scopes/ts.ts +0 -28
- package/src/factory/options/scopes/yml.ts +0 -17
- package/src/factory/scoped.ts +0 -17
- /package/dist/factory/{options → settings}/index.js +0 -0
- /package/dist/{config → interface/config}/index.js +0 -0
- /package/dist/{config → interface/config}/rule.js +0 -0
package/src/factory/ruleset.ts
CHANGED
@@ -1,27 +1,23 @@
|
|
1
|
-
import type {
|
2
|
-
Scopes,
|
3
|
-
RuleEntry,
|
4
|
-
RuleRecord,
|
5
|
-
} from "..";
|
1
|
+
import type { Scopes, Rule } from "..";
|
6
2
|
|
7
3
|
export class Ruleset {
|
8
|
-
public readonly ruleset: { id: `${Scopes}:${string}`; rules:
|
4
|
+
public readonly ruleset: { id: `${Scopes}:${string}`; rules: Rule.Config }[];
|
9
5
|
|
10
6
|
constructor(
|
11
7
|
public readonly scope: Scopes,
|
12
|
-
defaults:
|
13
|
-
|
8
|
+
defaults: readonly Rule.Entry[],
|
9
|
+
override?: Rule.Config,
|
14
10
|
) {
|
15
|
-
const map = ([id, rules]:
|
11
|
+
const map = ([id, rules]: Rule.Entry) => ({
|
16
12
|
id: `${scope}:${id}`,
|
17
13
|
rules,
|
18
14
|
} as const);
|
19
15
|
|
20
16
|
this.ruleset = [
|
21
17
|
...defaults.map(rule => map(rule)),
|
22
|
-
...typeof
|
23
|
-
? []
|
24
|
-
: [map([`${scope}:override`,
|
25
|
-
];
|
18
|
+
...typeof override === "undefined"
|
19
|
+
? [] as const
|
20
|
+
: [map([`${scope}:override`, override])] as const,
|
21
|
+
] as const;
|
26
22
|
}
|
27
23
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
|
3
|
+
export default class HtmlSetting extends ScopeSetting<
|
4
|
+
"html",
|
5
|
+
true
|
6
|
+
> {
|
7
|
+
public readonly scope = "html";
|
8
|
+
public readonly processor = {} as const;
|
9
|
+
public readonly language = {} as const;
|
10
|
+
|
11
|
+
public get languageOptions() {
|
12
|
+
const [parser] = this.parser;
|
13
|
+
|
14
|
+
return { parser } as const;
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
|
3
|
+
export default class JsSetting extends ScopeSetting<"js"> {
|
4
|
+
public readonly scope = "js";
|
5
|
+
public readonly processor = {} as const;
|
6
|
+
public readonly language = {} as const;
|
7
|
+
|
8
|
+
public get languageOptions() {
|
9
|
+
return {} as const;
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
|
3
|
+
export default class JsonSetting extends ScopeSetting<
|
4
|
+
"json",
|
5
|
+
true
|
6
|
+
> {
|
7
|
+
public readonly scope = "json";
|
8
|
+
public readonly processor = {} as const;
|
9
|
+
public readonly language = {} as const;
|
10
|
+
|
11
|
+
public get languageOptions() {
|
12
|
+
const [parser] = this.parser;
|
13
|
+
|
14
|
+
return { parser } as const;
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
|
3
|
+
export default class JsoncSetting extends ScopeSetting<
|
4
|
+
"jsonc",
|
5
|
+
true
|
6
|
+
> {
|
7
|
+
public readonly scope = "jsonc";
|
8
|
+
public readonly processor = {} as const;
|
9
|
+
public readonly language = {} as const;
|
10
|
+
|
11
|
+
public get languageOptions() {
|
12
|
+
const [parser] = this.parser;
|
13
|
+
|
14
|
+
return { parser } as const;
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { mocha } from "globals";
|
2
|
+
import { ScopeSetting } from "../setting";
|
3
|
+
import type TsSetting from "./ts";
|
4
|
+
|
5
|
+
export default class MochaSetting extends ScopeSetting<
|
6
|
+
"mocha",
|
7
|
+
TsSetting["option"]["languageOptions"]["parserOptions"],
|
8
|
+
1,
|
9
|
+
"mocha"
|
10
|
+
> {
|
11
|
+
public readonly scope = "mocha";
|
12
|
+
public readonly processor = {} as const;
|
13
|
+
public readonly language = {} as const;
|
14
|
+
public readonly types = ["mocha"] as const;
|
15
|
+
|
16
|
+
public get languageOptions() {
|
17
|
+
const [parser] = this.parser;
|
18
|
+
|
19
|
+
return {
|
20
|
+
parser,
|
21
|
+
parserOptions: {
|
22
|
+
project: "tsconfig.json",
|
23
|
+
sourceType: "module",
|
24
|
+
ecmaVersion: 2023,
|
25
|
+
} as const,
|
26
|
+
globals: mocha,
|
27
|
+
} as const;
|
28
|
+
}
|
29
|
+
}
|
@@ -1,19 +1,19 @@
|
|
1
|
-
import
|
2
|
-
import type
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
import type TsSetting from "./ts";
|
3
3
|
|
4
|
-
export default class
|
4
|
+
export default class SvelteSetting extends ScopeSetting<
|
5
5
|
"svelte",
|
6
6
|
{
|
7
|
-
parser: unknown;
|
8
|
-
extraFileExtensions: readonly [".svelte"];
|
9
|
-
} &
|
7
|
+
readonly parser: unknown;
|
8
|
+
readonly extraFileExtensions: readonly [".svelte"];
|
9
|
+
} & TsSetting["option"]["languageOptions"]["parserOptions"],
|
10
10
|
2,
|
11
11
|
false,
|
12
|
-
{ processor: "svelte/svelte" }
|
12
|
+
{ readonly processor: "svelte/svelte" }
|
13
13
|
> {
|
14
14
|
public readonly scope = "svelte";
|
15
15
|
public readonly processor = { processor: "svelte/svelte" } as const;
|
16
|
-
public readonly language = {};
|
16
|
+
public readonly language = {} as const;
|
17
17
|
|
18
18
|
public get languageOptions() {
|
19
19
|
const [parser, tsParser] = this.parser;
|
@@ -26,7 +26,7 @@ export default class Svelte extends Option<
|
|
26
26
|
project: "tsconfig.json",
|
27
27
|
sourceType: "module",
|
28
28
|
ecmaVersion: 2023,
|
29
|
-
},
|
29
|
+
} as const,
|
30
30
|
} as const;
|
31
31
|
}
|
32
32
|
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
|
3
|
+
export default class TsSetting extends ScopeSetting<
|
4
|
+
"ts",
|
5
|
+
{
|
6
|
+
readonly project: "tsconfig.json";
|
7
|
+
readonly sourceType: "module";
|
8
|
+
readonly ecmaVersion: 2023;
|
9
|
+
},
|
10
|
+
1
|
11
|
+
> {
|
12
|
+
public readonly scope = "ts";
|
13
|
+
public readonly processor = {} as const;
|
14
|
+
public readonly language = {} as const;
|
15
|
+
|
16
|
+
public get languageOptions() {
|
17
|
+
const [parser] = this.parser;
|
18
|
+
|
19
|
+
return {
|
20
|
+
parser,
|
21
|
+
parserOptions: {
|
22
|
+
project: "tsconfig.json",
|
23
|
+
sourceType: "module",
|
24
|
+
ecmaVersion: 2023,
|
25
|
+
} as const,
|
26
|
+
} as const;
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ScopeSetting } from "../setting";
|
2
|
+
|
3
|
+
export default class YmlSetting extends ScopeSetting<
|
4
|
+
"yml",
|
5
|
+
true,
|
6
|
+
1
|
7
|
+
> {
|
8
|
+
public readonly scope = "yml";
|
9
|
+
public readonly processor = {} as const;
|
10
|
+
public readonly language = {} as const;
|
11
|
+
|
12
|
+
public get languageOptions() {
|
13
|
+
const [parser] = this.parser;
|
14
|
+
|
15
|
+
return { parser } as const;
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import type globals from "globals";
|
2
|
+
import type { Scopes } from "../..";
|
3
|
+
|
4
|
+
export abstract class ScopeSetting<
|
5
|
+
S extends Scopes,
|
6
|
+
ParserOptions extends
|
7
|
+
| object
|
8
|
+
| boolean = false,
|
9
|
+
ParserCount extends 0 | 1 | 2 = ParserOptions extends false ? 0 : 1,
|
10
|
+
G extends keyof typeof globals & (
|
11
|
+
| "mocha"
|
12
|
+
) | false = false,
|
13
|
+
Processor extends object = object,
|
14
|
+
Language extends object = object,
|
15
|
+
> {
|
16
|
+
public abstract readonly scope: S;
|
17
|
+
public abstract readonly processor: (Processor extends never
|
18
|
+
? object
|
19
|
+
: Processor extends { readonly processor: infer P }
|
20
|
+
? string extends P
|
21
|
+
? object
|
22
|
+
: { readonly processor: P }
|
23
|
+
: object);
|
24
|
+
public abstract readonly language: (Language extends never
|
25
|
+
? object
|
26
|
+
: Language extends { readonly language: infer L }
|
27
|
+
? string extends L
|
28
|
+
? object
|
29
|
+
: { readonly language: L }
|
30
|
+
: object);
|
31
|
+
constructor(public readonly parser: readonly unknown[] & { length: ParserCount }) {}
|
32
|
+
|
33
|
+
public get option() {
|
34
|
+
try {
|
35
|
+
const { languageOptions, processor, language } = this;
|
36
|
+
|
37
|
+
return {
|
38
|
+
languageOptions,
|
39
|
+
...processor,
|
40
|
+
...language,
|
41
|
+
} as const;
|
42
|
+
}
|
43
|
+
catch (e) { throw new Error(`linted.factory.Option/scope:${this.scope}: option`, { cause: e }); }
|
44
|
+
}
|
45
|
+
|
46
|
+
protected abstract get languageOptions():
|
47
|
+
(G extends never
|
48
|
+
? object
|
49
|
+
: G extends boolean
|
50
|
+
? object
|
51
|
+
: G extends string
|
52
|
+
? string extends G
|
53
|
+
? object
|
54
|
+
: { readonly globals: Readonly<Record<string, unknown>> }
|
55
|
+
: object
|
56
|
+
) & ParserOptions extends never
|
57
|
+
? object
|
58
|
+
: ParserOptions extends boolean
|
59
|
+
? ParserOptions extends true
|
60
|
+
? { readonly parser: unknown }
|
61
|
+
: object
|
62
|
+
: { readonly parser: unknown; readonly parserOptions: ParserOptions };
|
63
|
+
}
|
package/src/index.ts
CHANGED
@@ -1,84 +1,35 @@
|
|
1
|
+
import { scopes } from "./scopes";
|
2
|
+
import { Factory, Options } from "./factory";
|
1
3
|
import type { Input, Output } from "./interface";
|
2
4
|
|
3
5
|
export type { Scopes } from "./scopes";
|
4
|
-
|
5
|
-
import { scopes } from "./scopes";
|
6
|
-
import {
|
7
|
-
GlobalFactory,
|
8
|
-
ScopeFactory,
|
9
|
-
Options,
|
10
|
-
} from "./factory";
|
11
|
-
|
12
6
|
export type * from "./interface";
|
13
|
-
export
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
parsers,
|
19
|
-
},
|
20
|
-
defaults,
|
21
|
-
extensions,
|
22
|
-
}: Input,
|
23
|
-
): Output {
|
7
|
+
export default function ({
|
8
|
+
imports: { plugins, parsers },
|
9
|
+
defaults,
|
10
|
+
extensions,
|
11
|
+
}: Input): Output {
|
24
12
|
try {
|
25
|
-
const
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
js: new Options
|
37
|
-
.js(
|
38
|
-
[],
|
39
|
-
...factory.produce("js"),
|
40
|
-
).configs,
|
41
|
-
ts: new Options
|
42
|
-
.ts(
|
43
|
-
[parsers.ts],
|
44
|
-
...factory.produce("ts"),
|
45
|
-
).configs,
|
46
|
-
svelte: new Options
|
47
|
-
.svelte(
|
48
|
-
[parsers.svelte, parsers.ts],
|
49
|
-
...factory.produce("svelte"),
|
50
|
-
).configs,
|
51
|
-
mocha: new Options
|
52
|
-
.mocha(
|
53
|
-
[parsers.ts],
|
54
|
-
...factory.produce("mocha"),
|
55
|
-
).configs,
|
56
|
-
html: new Options
|
57
|
-
.html(
|
58
|
-
[parsers.html],
|
59
|
-
...factory.produce("html"),
|
60
|
-
).configs,
|
61
|
-
json: new Options
|
62
|
-
.json(
|
63
|
-
[parsers.jsonc],
|
64
|
-
...factory.produce("json"),
|
65
|
-
).configs,
|
66
|
-
jsonc: new Options
|
67
|
-
.jsonc(
|
68
|
-
[parsers.jsonc],
|
69
|
-
...factory.produce("jsonc"),
|
70
|
-
).configs,
|
71
|
-
yml: new Options
|
72
|
-
.yml(
|
73
|
-
[parsers.yml],
|
74
|
-
...factory.produce("yml"),
|
75
|
-
).configs,
|
76
|
-
};
|
13
|
+
const factory = new Factory(defaults, extensions),
|
14
|
+
options: { readonly [S in typeof scopes[number]]: InstanceType<typeof Options[S]> } = {
|
15
|
+
js: new Options.js([] as const),
|
16
|
+
ts: new Options.ts([parsers.ts] as const),
|
17
|
+
svelte: new Options.svelte([parsers.svelte, parsers.ts] as const),
|
18
|
+
mocha: new Options.mocha([parsers.ts] as const),
|
19
|
+
html: new Options.html([parsers.html] as const),
|
20
|
+
json: new Options.json([parsers.jsonc] as const),
|
21
|
+
jsonc: new Options.jsonc([parsers.jsonc] as const),
|
22
|
+
yml: new Options.yml([parsers.yml] as const),
|
23
|
+
} as const;
|
77
24
|
|
78
25
|
return [
|
79
|
-
|
80
|
-
|
81
|
-
|
26
|
+
{ name: `linted/*/plugins`, plugins } as const,
|
27
|
+
factory.settings,
|
28
|
+
factory.ignores,
|
29
|
+
...scopes.flatMap(scope => factory.scope(scope, options[scope])),
|
30
|
+
] as const;
|
31
|
+
}
|
32
|
+
catch (e) {
|
33
|
+
throw new Error(`Linted Core`, { cause: e });
|
82
34
|
}
|
83
|
-
catch (e) { throw new Error(`Linted Core`, { cause: e }); }
|
84
35
|
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import type * as Rule from "./rule";
|
2
|
+
|
3
|
+
export type { Rule };
|
4
|
+
export interface Config<Plugins extends string = string> {
|
5
|
+
readonly name: `linted/${string}`;
|
6
|
+
readonly plugins: Readonly<Record<Plugins, { readonly configs: unknown }>>;
|
7
|
+
readonly files: readonly string[];
|
8
|
+
readonly ignores: readonly string[];
|
9
|
+
readonly rules: Rule.Config;
|
10
|
+
readonly linterOptions: {
|
11
|
+
readonly noInlineConfig: boolean;
|
12
|
+
readonly reportUnusedDisableDirectives:
|
13
|
+
| "error"
|
14
|
+
| "warn"
|
15
|
+
| "off"
|
16
|
+
;
|
17
|
+
};
|
18
|
+
readonly languageOptions: {
|
19
|
+
readonly sourceType:
|
20
|
+
| "module"
|
21
|
+
| "script"
|
22
|
+
;
|
23
|
+
readonly ecmaVersion:
|
24
|
+
| "latest"
|
25
|
+
| 3
|
26
|
+
| 5
|
27
|
+
| 2015
|
28
|
+
| 2016
|
29
|
+
| 2017
|
30
|
+
| 2018
|
31
|
+
| 2019
|
32
|
+
| 2020
|
33
|
+
| 2021
|
34
|
+
| 2022
|
35
|
+
| 2023
|
36
|
+
| 2024
|
37
|
+
;
|
38
|
+
};
|
39
|
+
readonly processor?: string;
|
40
|
+
readonly language?: string;
|
41
|
+
readonly settings?: Readonly<Record<string, unknown>>;
|
42
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { Config } from "../..";
|
2
|
+
import type { Only } from "./only";
|
3
|
+
|
4
|
+
export type Settings = Only<
|
5
|
+
Config,
|
6
|
+
(
|
7
|
+
& {
|
8
|
+
readonly name: `linted/*/settings`;
|
9
|
+
readonly languageOptions: Pick<Config["languageOptions"], "ecmaVersion" | "sourceType">;
|
10
|
+
}
|
11
|
+
& Pick<Config, "linterOptions">
|
12
|
+
)
|
13
|
+
>;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { Config } from "..";
|
2
|
+
import type { Scopes } from "../..";
|
3
|
+
|
4
|
+
export type Scoped = {
|
5
|
+
readonly name: `linted/${Scopes}:${string}`;
|
6
|
+
readonly languageOptions: Omit<Config["languageOptions"], "sourceType" | "ecmaVersion">;
|
7
|
+
} & Pick<Config, "files" | "ignores" | "rules" | "processor" | "language" | "settings">;
|
@@ -1,16 +1,2 @@
|
|
1
|
-
export type
|
2
|
-
|
3
|
-
| "@typescript-eslint"
|
4
|
-
| "svelte"
|
5
|
-
| "mocha"
|
6
|
-
| "@html-eslint"
|
7
|
-
| "jsonc"
|
8
|
-
| "yml"
|
9
|
-
);
|
10
|
-
export type ImportParsers = (
|
11
|
-
| "ts"
|
12
|
-
| "svelte"
|
13
|
-
| "html"
|
14
|
-
| "jsonc"
|
15
|
-
| "yml"
|
16
|
-
);
|
1
|
+
export type * from "./plugins";
|
2
|
+
export type * from "./parsers";
|
package/src/interface/index.ts
CHANGED
package/src/interface/input.ts
CHANGED
@@ -1,26 +1,22 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
Config,
|
4
|
-
RuleEntry,
|
5
|
-
} from "..";
|
6
|
-
import type { ImportPlugins, ImportParsers } from "./imports";
|
1
|
+
import type { Config, Rule, Imports } from ".";
|
2
|
+
import type { Scopes } from "..";
|
7
3
|
|
8
4
|
export interface Input {
|
9
|
-
imports: {
|
10
|
-
plugins: Config<
|
11
|
-
parsers: Record<
|
12
|
-
|
5
|
+
readonly imports: {
|
6
|
+
readonly plugins: Config<Imports.Plugins>["plugins"];
|
7
|
+
readonly parsers: Readonly<Record<
|
8
|
+
Imports.Parsers,
|
13
9
|
unknown
|
14
|
-
|
10
|
+
>>;
|
15
11
|
};
|
16
|
-
defaults: {
|
17
|
-
settings: Config["linterOptions"] & Pick<Config["languageOptions"], "ecmaVersion" | "sourceType">;
|
18
|
-
files: Record<"*" | Scopes, string[]
|
19
|
-
ignores: Input["defaults"]["files"];
|
20
|
-
rules: Record<Scopes,
|
12
|
+
readonly defaults: {
|
13
|
+
readonly settings: Config["linterOptions"] & Pick<Config["languageOptions"], "ecmaVersion" | "sourceType">;
|
14
|
+
readonly files: Readonly<Record<"*" | Scopes, readonly string[]>>;
|
15
|
+
readonly ignores: Input["defaults"]["files"];
|
16
|
+
readonly rules: Readonly<Record<Scopes, readonly Rule.Entry[]>>;
|
21
17
|
};
|
22
|
-
extensions: Partial<
|
23
|
-
& Record<"*", Partial<Input["defaults"]["settings"] & Pick<Config, "ignores"> & { override?: boolean }>>
|
18
|
+
readonly extensions: Readonly<Partial<
|
19
|
+
& Record<"*", Partial<Input["defaults"]["settings"] & Pick<Config, "ignores"> & { readonly override?: boolean }>>
|
24
20
|
& Record<Scopes, Partial<Pick<Config, "files" | "ignores" | "rules">>>
|
25
|
-
|
21
|
+
>>;
|
26
22
|
}
|
package/src/interface/output.ts
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
-
import type
|
2
|
-
Scopes,
|
3
|
-
Config,
|
4
|
-
} from "..";
|
5
|
-
import type { ImportPlugins } from "./imports";
|
1
|
+
import type * as Configs from "./configs";
|
6
2
|
|
7
|
-
export type
|
8
|
-
export type Output = [
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
languageOptions: Pick<Config["languageOptions"], "ecmaVersion" | "sourceType">;
|
14
|
-
} & Pick<Config<ImportPlugins>, "plugins" | "linterOptions">
|
15
|
-
>,
|
16
|
-
Exclusive<
|
17
|
-
Config,
|
18
|
-
{ name: `linted/*/ignores` } & Pick<Config, "ignores">
|
19
|
-
>,
|
20
|
-
...({
|
21
|
-
name: `linted/${Scopes}:${string}`;
|
22
|
-
languageOptions: Omit<Config["languageOptions"], "sourceType" | "ecmaVersion">;
|
23
|
-
} & Pick<Config, "files" | "ignores" | "rules" | "processor" | "language" | "settings">)[],
|
3
|
+
export type { Configs };
|
4
|
+
export type Output = readonly [
|
5
|
+
Configs.Globals.Plugins,
|
6
|
+
Configs.Globals.Settings,
|
7
|
+
Configs.Globals.Ignores,
|
8
|
+
...readonly Configs.Scoped[],
|
24
9
|
];
|
package/dist/config/index.d.ts
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import type { RuleRecord } from "./rule.js";
|
2
|
-
export type * from "./rule.js";
|
3
|
-
export interface Config<Plugins extends string = string> {
|
4
|
-
name: `linted/${string}`;
|
5
|
-
plugins: Record<Plugins, {
|
6
|
-
configs: unknown;
|
7
|
-
}>;
|
8
|
-
files: string[];
|
9
|
-
ignores: string[];
|
10
|
-
rules: RuleRecord;
|
11
|
-
linterOptions: {
|
12
|
-
noInlineConfig: boolean;
|
13
|
-
reportUnusedDisableDirectives: "error" | "warn" | "off";
|
14
|
-
};
|
15
|
-
languageOptions: {
|
16
|
-
sourceType: "module" | "script";
|
17
|
-
ecmaVersion: "latest" | 3 | 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024;
|
18
|
-
};
|
19
|
-
processor?: string;
|
20
|
-
language?: string;
|
21
|
-
settings?: Record<string, unknown>;
|
22
|
-
}
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|