@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.
Files changed (189) hide show
  1. package/dist/factory/factory.d.ts +175 -0
  2. package/dist/factory/factory.d.ts.map +1 -0
  3. package/dist/factory/factory.js +42 -0
  4. package/dist/factory/factory.js.map +1 -0
  5. package/dist/factory/index.d.ts +2 -3
  6. package/dist/factory/index.d.ts.map +1 -1
  7. package/dist/factory/index.js +2 -3
  8. package/dist/factory/index.js.map +1 -1
  9. package/dist/factory/ruleset.d.ts +3 -3
  10. package/dist/factory/ruleset.d.ts.map +1 -1
  11. package/dist/factory/ruleset.js +3 -3
  12. package/dist/factory/ruleset.js.map +1 -1
  13. package/dist/factory/{options → settings}/index.d.ts +1 -2
  14. package/dist/factory/settings/index.d.ts.map +1 -0
  15. package/dist/factory/settings/index.js.map +1 -0
  16. package/dist/factory/{options → settings}/scopes/html.d.ts +2 -2
  17. package/dist/factory/settings/scopes/html.d.ts.map +1 -0
  18. package/dist/factory/{options → settings}/scopes/html.js +2 -2
  19. package/dist/factory/settings/scopes/html.js.map +1 -0
  20. package/dist/factory/{options → settings}/scopes/js.d.ts +2 -2
  21. package/dist/factory/settings/scopes/js.d.ts.map +1 -0
  22. package/dist/factory/{options → settings}/scopes/js.js +2 -2
  23. package/dist/factory/settings/scopes/js.js.map +1 -0
  24. package/dist/factory/{options → settings}/scopes/json.d.ts +2 -2
  25. package/dist/factory/settings/scopes/json.d.ts.map +1 -0
  26. package/dist/factory/{options → settings}/scopes/json.js +2 -2
  27. package/dist/factory/settings/scopes/json.js.map +1 -0
  28. package/dist/factory/{options → settings}/scopes/jsonc.d.ts +2 -2
  29. package/dist/factory/settings/scopes/jsonc.d.ts.map +1 -0
  30. package/dist/factory/{options → settings}/scopes/jsonc.js +2 -2
  31. package/dist/factory/settings/scopes/jsonc.js.map +1 -0
  32. package/dist/factory/{options → settings}/scopes/mocha.d.ts +3 -3
  33. package/dist/factory/settings/scopes/mocha.d.ts.map +1 -0
  34. package/dist/factory/{options → settings}/scopes/mocha.js +5 -4
  35. package/dist/factory/settings/scopes/mocha.js.map +1 -0
  36. package/dist/factory/{options → settings}/scopes/svelte.d.ts +7 -7
  37. package/dist/factory/settings/scopes/svelte.d.ts.map +1 -0
  38. package/dist/factory/{options → settings}/scopes/svelte.js +2 -2
  39. package/dist/factory/settings/scopes/svelte.js.map +1 -0
  40. package/dist/factory/{options → settings}/scopes/ts.d.ts +5 -5
  41. package/dist/factory/settings/scopes/ts.d.ts.map +1 -0
  42. package/dist/factory/{options → settings}/scopes/ts.js +2 -2
  43. package/dist/factory/settings/scopes/ts.js.map +1 -0
  44. package/dist/factory/{options → settings}/scopes/yml.d.ts +2 -2
  45. package/dist/factory/settings/scopes/yml.d.ts.map +1 -0
  46. package/dist/factory/{options → settings}/scopes/yml.js +2 -2
  47. package/dist/factory/settings/scopes/yml.js.map +1 -0
  48. package/dist/factory/settings/setting.d.ts +48 -0
  49. package/dist/factory/settings/setting.d.ts.map +1 -0
  50. package/dist/factory/settings/setting.js +20 -0
  51. package/dist/factory/settings/setting.js.map +1 -0
  52. package/dist/index.d.ts +1 -2
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +15 -21
  55. package/dist/index.js.map +1 -1
  56. package/dist/interface/config/index.d.ts +23 -0
  57. package/dist/interface/config/index.d.ts.map +1 -0
  58. package/dist/{config → interface/config}/index.js.map +1 -1
  59. package/dist/interface/config/rule.d.ts +7 -0
  60. package/dist/interface/config/rule.d.ts.map +1 -0
  61. package/dist/{config → interface/config}/rule.js.map +1 -1
  62. package/dist/interface/configs/globals/ignores.d.ts +6 -0
  63. package/dist/interface/configs/globals/ignores.d.ts.map +1 -0
  64. package/dist/interface/configs/globals/ignores.js +2 -0
  65. package/dist/interface/configs/globals/ignores.js.map +1 -0
  66. package/dist/interface/configs/globals/index.d.ts +5 -0
  67. package/dist/interface/configs/globals/index.d.ts.map +1 -0
  68. package/dist/interface/configs/globals/index.js +2 -0
  69. package/dist/interface/configs/globals/index.js.map +1 -0
  70. package/dist/interface/configs/globals/only/index.d.ts +2 -0
  71. package/dist/interface/configs/globals/only/index.d.ts.map +1 -0
  72. package/dist/interface/configs/globals/only/index.js +2 -0
  73. package/dist/interface/configs/globals/only/index.js.map +1 -0
  74. package/dist/interface/configs/globals/plugins.d.ts +6 -0
  75. package/dist/interface/configs/globals/plugins.d.ts.map +1 -0
  76. package/dist/interface/configs/globals/plugins.js +2 -0
  77. package/dist/interface/configs/globals/plugins.js.map +1 -0
  78. package/dist/interface/configs/globals/settings.d.ts +7 -0
  79. package/dist/interface/configs/globals/settings.d.ts.map +1 -0
  80. package/dist/interface/configs/globals/settings.js +2 -0
  81. package/dist/interface/configs/globals/settings.js.map +1 -0
  82. package/dist/interface/configs/index.d.ts +3 -0
  83. package/dist/interface/configs/index.d.ts.map +1 -0
  84. package/dist/interface/configs/index.js +2 -0
  85. package/dist/interface/configs/index.js.map +1 -0
  86. package/dist/interface/configs/scoped.d.ts +7 -0
  87. package/dist/interface/configs/scoped.d.ts.map +1 -0
  88. package/dist/interface/configs/scoped.js +2 -0
  89. package/dist/interface/configs/scoped.js.map +1 -0
  90. package/dist/interface/imports/index.d.ts +3 -3
  91. package/dist/interface/imports/index.d.ts.map +1 -1
  92. package/dist/interface/imports/parsers.d.ts +2 -0
  93. package/dist/interface/imports/parsers.d.ts.map +1 -0
  94. package/dist/interface/imports/parsers.js +2 -0
  95. package/dist/interface/imports/parsers.js.map +1 -0
  96. package/dist/interface/imports/plugins.d.ts +2 -0
  97. package/dist/interface/imports/plugins.d.ts.map +1 -0
  98. package/dist/interface/imports/plugins.js +2 -0
  99. package/dist/interface/imports/plugins.js.map +1 -0
  100. package/dist/interface/index.d.ts +2 -1
  101. package/dist/interface/index.d.ts.map +1 -1
  102. package/dist/interface/input.d.ts +13 -13
  103. package/dist/interface/input.d.ts.map +1 -1
  104. package/dist/interface/output.d.ts +7 -15
  105. package/dist/interface/output.d.ts.map +1 -1
  106. package/package.json +1 -1
  107. package/src/factory/factory.ts +89 -0
  108. package/src/factory/index.ts +2 -3
  109. package/src/factory/ruleset.ts +9 -13
  110. package/src/factory/{options → settings}/index.ts +1 -2
  111. package/src/factory/settings/scopes/html.ts +16 -0
  112. package/src/factory/settings/scopes/js.ts +11 -0
  113. package/src/factory/settings/scopes/json.ts +16 -0
  114. package/src/factory/settings/scopes/jsonc.ts +16 -0
  115. package/src/factory/settings/scopes/mocha.ts +29 -0
  116. package/src/factory/{options → settings}/scopes/svelte.ts +9 -9
  117. package/src/factory/settings/scopes/ts.ts +28 -0
  118. package/src/factory/settings/scopes/yml.ts +17 -0
  119. package/src/factory/settings/setting.ts +63 -0
  120. package/src/index.ts +26 -75
  121. package/src/interface/config/index.ts +42 -0
  122. package/src/interface/config/rule.ts +14 -0
  123. package/src/interface/configs/globals/ignores.ts +10 -0
  124. package/src/interface/configs/globals/index.ts +4 -0
  125. package/src/interface/configs/globals/only/index.ts +4 -0
  126. package/src/interface/configs/globals/plugins.ts +10 -0
  127. package/src/interface/configs/globals/settings.ts +13 -0
  128. package/src/interface/configs/index.ts +2 -0
  129. package/src/interface/configs/scoped.ts +7 -0
  130. package/src/interface/imports/index.ts +2 -16
  131. package/src/interface/imports/parsers.ts +7 -0
  132. package/src/interface/imports/plugins.ts +9 -0
  133. package/src/interface/index.ts +2 -1
  134. package/src/interface/input.ts +15 -19
  135. package/src/interface/output.ts +7 -22
  136. package/dist/config/index.d.ts +0 -23
  137. package/dist/config/index.d.ts.map +0 -1
  138. package/dist/config/rule.d.ts +0 -7
  139. package/dist/config/rule.d.ts.map +0 -1
  140. package/dist/factory/global.d.ts +0 -29
  141. package/dist/factory/global.d.ts.map +0 -1
  142. package/dist/factory/global.js +0 -41
  143. package/dist/factory/global.js.map +0 -1
  144. package/dist/factory/options/index.d.ts.map +0 -1
  145. package/dist/factory/options/index.js.map +0 -1
  146. package/dist/factory/options/option.d.ts +0 -3002
  147. package/dist/factory/options/option.d.ts.map +0 -1
  148. package/dist/factory/options/option.js +0 -48
  149. package/dist/factory/options/option.js.map +0 -1
  150. package/dist/factory/options/proto.d.ts +0 -19
  151. package/dist/factory/options/proto.d.ts.map +0 -1
  152. package/dist/factory/options/proto.js +0 -2
  153. package/dist/factory/options/proto.js.map +0 -1
  154. package/dist/factory/options/scopes/html.d.ts.map +0 -1
  155. package/dist/factory/options/scopes/html.js.map +0 -1
  156. package/dist/factory/options/scopes/js.d.ts.map +0 -1
  157. package/dist/factory/options/scopes/js.js.map +0 -1
  158. package/dist/factory/options/scopes/json.d.ts.map +0 -1
  159. package/dist/factory/options/scopes/json.js.map +0 -1
  160. package/dist/factory/options/scopes/jsonc.d.ts.map +0 -1
  161. package/dist/factory/options/scopes/jsonc.js.map +0 -1
  162. package/dist/factory/options/scopes/mocha.d.ts.map +0 -1
  163. package/dist/factory/options/scopes/mocha.js.map +0 -1
  164. package/dist/factory/options/scopes/svelte.d.ts.map +0 -1
  165. package/dist/factory/options/scopes/svelte.js.map +0 -1
  166. package/dist/factory/options/scopes/ts.d.ts.map +0 -1
  167. package/dist/factory/options/scopes/ts.js.map +0 -1
  168. package/dist/factory/options/scopes/yml.d.ts.map +0 -1
  169. package/dist/factory/options/scopes/yml.js.map +0 -1
  170. package/dist/factory/scoped.d.ts +0 -13
  171. package/dist/factory/scoped.d.ts.map +0 -1
  172. package/dist/factory/scoped.js +0 -17
  173. package/dist/factory/scoped.js.map +0 -1
  174. package/src/config/index.ts +0 -42
  175. package/src/config/rule.ts +0 -14
  176. package/src/factory/global.ts +0 -45
  177. package/src/factory/options/option.ts +0 -98
  178. package/src/factory/options/proto.ts +0 -46
  179. package/src/factory/options/scopes/html.ts +0 -16
  180. package/src/factory/options/scopes/js.ts +0 -11
  181. package/src/factory/options/scopes/json.ts +0 -16
  182. package/src/factory/options/scopes/jsonc.ts +0 -16
  183. package/src/factory/options/scopes/mocha.ts +0 -29
  184. package/src/factory/options/scopes/ts.ts +0 -28
  185. package/src/factory/options/scopes/yml.ts +0 -17
  186. package/src/factory/scoped.ts +0 -17
  187. /package/dist/factory/{options → settings}/index.js +0 -0
  188. /package/dist/{config → interface/config}/index.js +0 -0
  189. /package/dist/{config → interface/config}/rule.js +0 -0
@@ -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: RuleRecord }[];
4
+ public readonly ruleset: { id: `${Scopes}:${string}`; rules: Rule.Config }[];
9
5
 
10
6
  constructor(
11
7
  public readonly scope: Scopes,
12
- defaults: RuleEntry[],
13
- extension?: RuleRecord,
8
+ defaults: readonly Rule.Entry[],
9
+ override?: Rule.Config,
14
10
  ) {
15
- const map = ([id, rules]: RuleEntry) => ({
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 extension === "undefined"
23
- ? []
24
- : [map([`${scope}:override`, extension])],
25
- ];
18
+ ...typeof override === "undefined"
19
+ ? [] as const
20
+ : [map([`${scope}:override`, override])] as const,
21
+ ] as const;
26
22
  }
27
23
  }
@@ -7,8 +7,7 @@ import json from "./scopes/json";
7
7
  import jsonc from "./scopes/jsonc";
8
8
  import yml from "./scopes/yml";
9
9
 
10
- export type * from "./option";
11
- export type * from "./proto";
10
+ export type * from "./setting";
12
11
  export default {
13
12
  js,
14
13
  ts,
@@ -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 Option from "../option";
2
- import type Ts from "./ts";
1
+ import { ScopeSetting } from "../setting";
2
+ import type TsSetting from "./ts";
3
3
 
4
- export default class Svelte extends Option<
4
+ export default class SvelteSetting extends ScopeSetting<
5
5
  "svelte",
6
6
  {
7
- parser: unknown;
8
- extraFileExtensions: readonly [".svelte"];
9
- } & Ts["option"]["languageOptions"]["parserOptions"],
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 type * from "./config";
14
- export default function (
15
- {
16
- imports: {
17
- plugins,
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 global = new GlobalFactory(
26
- plugins,
27
- defaults.settings,
28
- defaults.ignores["*"],
29
- extensions["*"],
30
- ),
31
- factory = new ScopeFactory(
32
- defaults,
33
- extensions,
34
- ),
35
- options: { [S in typeof scopes[number]]: InstanceType<typeof Options[S]>["configs"] } = {
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
- ...global.configs,
80
- ...scopes.flatMap(scope => options[scope]),
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,14 @@
1
+ export type Entry = readonly [
2
+ string,
3
+ Config,
4
+ ];
5
+ export type Config = Readonly<Record<
6
+ string,
7
+ | State
8
+ | readonly [State, ...readonly unknown[]]
9
+ >>;
10
+ export type State = (
11
+ | "error"
12
+ | "warn"
13
+ | "off"
14
+ );
@@ -0,0 +1,10 @@
1
+ import type { Config } from "../..";
2
+ import type { Only } from "./only";
3
+
4
+ export type Ignores = Only<
5
+ Config,
6
+ (
7
+ & { readonly name: `linted/*/ignores` }
8
+ & Pick<Config, "ignores">
9
+ )
10
+ >;
@@ -0,0 +1,4 @@
1
+ export type * from "./plugins";
2
+ export type * from "./settings";
3
+ export type * from "./ignores";
4
+ export type * from "./only";
@@ -0,0 +1,4 @@
1
+ export type Only<
2
+ Base extends object,
3
+ This extends object,
4
+ > = This & Readonly<Partial<Record<Exclude<keyof Base, keyof This>, never>>>;
@@ -0,0 +1,10 @@
1
+ import type { Config, Imports } from "../..";
2
+ import type { Only } from "./only";
3
+
4
+ export type Plugins = Only<
5
+ Config,
6
+ (
7
+ & { readonly name: `linted/*/plugins` }
8
+ & Pick<Config<Imports.Plugins>, "plugins">
9
+ )
10
+ >;
@@ -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,2 @@
1
+ export type * as Globals from "./globals";
2
+ export type * from "./scoped";
@@ -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 ImportPlugins = (
2
- | "@stylistic"
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";
@@ -0,0 +1,7 @@
1
+ export type Parsers = (
2
+ | "ts"
3
+ | "svelte"
4
+ | "html"
5
+ | "jsonc"
6
+ | "yml"
7
+ );
@@ -0,0 +1,9 @@
1
+ export type Plugins = (
2
+ | "@stylistic"
3
+ | "@typescript-eslint"
4
+ | "svelte"
5
+ | "mocha"
6
+ | "@html-eslint"
7
+ | "jsonc"
8
+ | "yml"
9
+ );
@@ -1,3 +1,4 @@
1
+ export type * as Imports from "./imports";
2
+ export type * from "./config";
1
3
  export type * from "./input";
2
4
  export type * from "./output";
3
- export type * from "./imports";
@@ -1,26 +1,22 @@
1
- import type {
2
- Scopes,
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<ImportPlugins>["plugins"];
11
- parsers: Record<
12
- ImportParsers & Scopes,
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, RuleEntry[]>;
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
  }
@@ -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 Exclusive<Base extends object, Cool extends object> = Cool & Partial<Record<Exclude<keyof Base, keyof Cool>, never>>;
8
- export type Output = [
9
- Exclusive<
10
- Config,
11
- {
12
- name: `linted/*/settings`;
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
  ];
@@ -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