@eslinted/core 13.3.0-rc.0 → 13.3.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/dist/factory/factory.d.ts +185 -83
  2. package/dist/factory/factory.d.ts.map +1 -1
  3. package/dist/factory/factory.js +22 -3
  4. package/dist/factory/factory.js.map +1 -1
  5. package/dist/factory/index.d.ts +1 -2
  6. package/dist/factory/index.d.ts.map +1 -1
  7. package/dist/factory/index.js +1 -2
  8. package/dist/factory/index.js.map +1 -1
  9. package/dist/factory/settings/index.d.ts +1 -2
  10. package/dist/factory/settings/index.d.ts.map +1 -1
  11. package/dist/factory/settings/index.js +1 -1
  12. package/dist/factory/settings/index.js.map +1 -1
  13. package/dist/factory/settings/scopes/html.d.ts +4 -3
  14. package/dist/factory/settings/scopes/html.d.ts.map +1 -1
  15. package/dist/factory/settings/scopes/html.js +2 -4
  16. package/dist/factory/settings/scopes/html.js.map +1 -1
  17. package/dist/factory/settings/scopes/js.d.ts +3 -2
  18. package/dist/factory/settings/scopes/js.d.ts.map +1 -1
  19. package/dist/factory/settings/scopes/js.js +2 -3
  20. package/dist/factory/settings/scopes/js.js.map +1 -1
  21. package/dist/factory/settings/scopes/json.d.ts +4 -3
  22. package/dist/factory/settings/scopes/json.d.ts.map +1 -1
  23. package/dist/factory/settings/scopes/json.js +2 -4
  24. package/dist/factory/settings/scopes/json.js.map +1 -1
  25. package/dist/factory/settings/scopes/jsonc.d.ts +4 -3
  26. package/dist/factory/settings/scopes/jsonc.d.ts.map +1 -1
  27. package/dist/factory/settings/scopes/jsonc.js +2 -4
  28. package/dist/factory/settings/scopes/jsonc.js.map +1 -1
  29. package/dist/factory/settings/scopes/mocha.d.ts +5 -3
  30. package/dist/factory/settings/scopes/mocha.d.ts.map +1 -1
  31. package/dist/factory/settings/scopes/mocha.js +11 -12
  32. package/dist/factory/settings/scopes/mocha.js.map +1 -1
  33. package/dist/factory/settings/scopes/svelte.d.ts +16 -12
  34. package/dist/factory/settings/scopes/svelte.d.ts.map +1 -1
  35. package/dist/factory/settings/scopes/svelte.js +12 -13
  36. package/dist/factory/settings/scopes/svelte.js.map +1 -1
  37. package/dist/factory/settings/scopes/ts.d.ts +10 -6
  38. package/dist/factory/settings/scopes/ts.d.ts.map +1 -1
  39. package/dist/factory/settings/scopes/ts.js +10 -11
  40. package/dist/factory/settings/scopes/ts.js.map +1 -1
  41. package/dist/factory/settings/scopes/yml.d.ts +4 -3
  42. package/dist/factory/settings/scopes/yml.d.ts.map +1 -1
  43. package/dist/factory/settings/scopes/yml.js +2 -4
  44. package/dist/factory/settings/scopes/yml.js.map +1 -1
  45. package/dist/factory/settings/setting.d.ts +50 -37
  46. package/dist/factory/settings/setting.d.ts.map +1 -1
  47. package/dist/factory/settings/setting.js +5 -6
  48. package/dist/factory/settings/setting.js.map +1 -1
  49. package/dist/index.js +10 -10
  50. package/dist/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/factory/factory.ts +24 -4
  53. package/src/factory/index.ts +1 -3
  54. package/src/factory/settings/index.ts +1 -1
  55. package/src/factory/settings/scopes/html.ts +3 -8
  56. package/src/factory/settings/scopes/js.ts +3 -5
  57. package/src/factory/settings/scopes/json.ts +3 -8
  58. package/src/factory/settings/scopes/jsonc.ts +3 -8
  59. package/src/factory/settings/scopes/mocha.ts +13 -17
  60. package/src/factory/settings/scopes/svelte.ts +19 -21
  61. package/src/factory/settings/scopes/ts.ts +16 -17
  62. package/src/factory/settings/scopes/yml.ts +3 -9
  63. package/src/factory/settings/setting.ts +39 -43
  64. package/src/index.ts +11 -11
@@ -2,27 +2,23 @@ import { ScopeSetting } from "../setting";
2
2
  import type TsSetting from "./ts";
3
3
 
4
4
  export default class MochaSetting extends ScopeSetting<
5
- "mocha",
6
- TsSetting["option"]["languageOptions"]["parserOptions"],
7
- 1,
5
+ "ts",
6
+ TsSetting["parserOptions"],
8
7
  "mocha"
9
8
  > {
10
9
  public readonly scope = "mocha";
11
10
  public readonly processor = {} as const;
12
11
  public readonly language = {} as const;
13
12
  public readonly types = ["mocha"] as const;
14
-
15
- public get languageOptions() {
16
- const [parser] = this.parser;
17
-
18
- return {
19
- parser,
20
- parserOptions: {
21
- project: "tsconfig.json",
22
- sourceType: "module",
23
- ecmaVersion: 2023,
24
- } as const,
25
- globals: this.globals("mocha"),
26
- } as const;
27
- }
13
+ public readonly parserOptions = {
14
+ parserOptions: {
15
+ project: "tsconfig.json",
16
+ sourceType: "module",
17
+ ecmaVersion: 2023,
18
+ } as const,
19
+ } as const;
20
+ public readonly languageOptions = {
21
+ parser: "ts",
22
+ globals: this.globals("mocha"),
23
+ } as const;
28
24
  }
@@ -2,31 +2,29 @@ import { ScopeSetting } from "../setting";
2
2
  import type TsSetting from "./ts";
3
3
 
4
4
  export default class SvelteSetting extends ScopeSetting<
5
- "svelte",
6
- {
7
- readonly parser: unknown;
8
- readonly extraFileExtensions: readonly [".svelte"];
9
- } & TsSetting["option"]["languageOptions"]["parserOptions"],
10
- 2,
5
+ "svelte" | "ts",
6
+ TsSetting["parserOptions"] & {
7
+ parserOptions: {
8
+ readonly parser: "ts";
9
+ readonly extraFileExtensions: readonly [".svelte"];
10
+ };
11
+ },
11
12
  false,
12
13
  { readonly processor: "svelte/svelte" }
13
14
  > {
14
15
  public readonly scope = "svelte";
15
16
  public readonly processor = { processor: "svelte/svelte" } as const;
16
17
  public readonly language = {} as const;
17
-
18
- public get languageOptions() {
19
- const [parser, tsParser] = this.parser;
20
-
21
- return {
22
- parser,
23
- parserOptions: {
24
- parser: tsParser,
25
- extraFileExtensions: [".svelte"] as const,
26
- project: "tsconfig.json",
27
- sourceType: "module",
28
- ecmaVersion: 2023,
29
- } as const,
30
- } as const;
31
- }
18
+ public readonly parserOptions = {
19
+ parserOptions: {
20
+ project: "tsconfig.json",
21
+ sourceType: "module",
22
+ ecmaVersion: 2023,
23
+ parser: "ts",
24
+ extraFileExtensions: [".svelte"] as const,
25
+ } as const,
26
+ } as const;
27
+ public readonly languageOptions = {
28
+ parser: "svelte",
29
+ } as const;
32
30
  }
@@ -3,26 +3,25 @@ import { ScopeSetting } from "../setting";
3
3
  export default class TsSetting extends ScopeSetting<
4
4
  "ts",
5
5
  {
6
- readonly project: "tsconfig.json";
7
- readonly sourceType: "module";
8
- readonly ecmaVersion: 2023;
9
- },
10
- 1
6
+ parserOptions: {
7
+ readonly project: "tsconfig.json";
8
+ readonly sourceType: "module";
9
+ readonly ecmaVersion: 2023;
10
+ };
11
+ }
11
12
  > {
12
13
  public readonly scope = "ts";
13
14
  public readonly processor = {} as const;
14
15
  public readonly language = {} as const;
16
+ public readonly parserOptions = {
17
+ parserOptions: {
18
+ project: "tsconfig.json",
19
+ sourceType: "module",
20
+ ecmaVersion: 2023,
21
+ } as const,
22
+ } as const;
23
+ public readonly languageOptions = {
24
+ parser: "ts",
15
25
 
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
- }
26
+ } as const;
28
27
  }
@@ -1,17 +1,11 @@
1
1
  import { ScopeSetting } from "../setting";
2
2
 
3
3
  export default class YmlSetting extends ScopeSetting<
4
- "yml",
5
- true,
6
- 1
4
+ "yml"
7
5
  > {
8
6
  public readonly scope = "yml";
9
7
  public readonly processor = {} as const;
10
8
  public readonly language = {} as const;
11
-
12
- public get languageOptions() {
13
- const [parser] = this.parser;
14
-
15
- return { parser } as const;
16
- }
9
+ public readonly parserOptions = {} as const;
10
+ public readonly languageOptions = { parser: "yml" } as const;
17
11
  }
@@ -2,61 +2,57 @@ import globals from "globals";
2
2
  import type { Scopes } from "../..";
3
3
 
4
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 | false = false,
5
+ Parser extends Scopes | false = false,
6
+ ParserOptions extends object = object,
7
+ Global extends keyof typeof globals | false = false,
11
8
  Processor extends object = object,
12
9
  Language extends object = object,
13
10
  > {
14
- public abstract readonly scope: S;
15
- public abstract readonly processor: (Processor extends never
16
- ? object
17
- : Processor extends { readonly processor: infer P }
18
- ? string extends P
19
- ? object
20
- : { readonly processor: P }
21
- : object);
22
- public abstract readonly language: (Language extends never
23
- ? object
24
- : Language extends { readonly language: infer L }
25
- ? string extends L
26
- ? object
27
- : { readonly language: L }
28
- : object);
29
- constructor(public readonly parser: readonly unknown[] & { length: ParserCount }) {}
11
+ public abstract readonly scope: Scopes;
12
+ public abstract readonly processor: (Processor extends { readonly processor: infer P }
13
+ ? string extends P
14
+ ? Record<string, never>
15
+ : { readonly processor: P }
16
+ : Record<string, never>);
17
+ public abstract readonly language: (Language extends { readonly language: infer L }
18
+ ? string extends L
19
+ ? Record<string, never>
20
+ : { readonly language: L }
21
+ : Record<string, never>);
22
+ public abstract readonly parserOptions: (ParserOptions extends { readonly parserOptions: infer PO }
23
+ ? PO extends { readonly parser: infer P }
24
+ ? P extends Parser
25
+ ? ParserOptions
26
+ : Record<string, never>
27
+ : ParserOptions
28
+ : Record<string, never>);
29
+ public abstract readonly languageOptions: (
30
+ [Parser] extends [boolean]
31
+ ? { readonly parser?: never }
32
+ : { parser: Parser }
33
+
34
+ ) & (
35
+ Global extends boolean
36
+ ? { readonly globals?: never }
37
+ : { readonly globals: Readonly<Record<string, unknown>> }
38
+ );
30
39
 
31
40
  public get option() {
32
- const { languageOptions, processor, language } = this;
41
+ const {
42
+ languageOptions, parserOptions, processor, language,
43
+ } = this;
33
44
 
34
45
  return {
35
- languageOptions,
46
+ languageOptions: {
47
+ ...languageOptions,
48
+ ...parserOptions,
49
+ },
36
50
  ...processor,
37
51
  ...language,
38
52
  } as const;
39
53
  }
40
54
 
41
- protected abstract get languageOptions():
42
- (G extends never
43
- ? object
44
- : G extends boolean
45
- ? object
46
- : G extends string
47
- ? string extends G
48
- ? object
49
- : { readonly globals: Readonly<Record<string, unknown>> }
50
- : object
51
- ) & ParserOptions extends never
52
- ? object
53
- : ParserOptions extends boolean
54
- ? ParserOptions extends true
55
- ? { readonly parser: unknown }
56
- : object
57
- : { readonly parser: unknown; readonly parserOptions: ParserOptions };
58
-
59
- protected globals(global: G & keyof typeof globals) {
55
+ protected globals(global: Global & keyof typeof globals) {
60
56
  if (typeof global === "boolean")
61
57
  throw new TypeError("`global` must be a string key of `globals` package");
62
58
 
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Input, Output } from "./interface";
2
2
  import { scopes } from "./scopes";
3
- import { Factory, Options } from "./factory";
3
+ import { Factory, ScopeSettings } from "./factory";
4
4
 
5
5
  export type * from "./interface";
6
6
  export type * from "./scopes";
@@ -10,16 +10,16 @@ export default function ({
10
10
  extensions,
11
11
  }: Input): Output {
12
12
  try {
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),
13
+ const factory = new Factory(parsers, defaults, extensions),
14
+ options: { readonly [S in typeof scopes[number]]: InstanceType<typeof ScopeSettings[S]> } = {
15
+ js: new ScopeSettings.js(),
16
+ ts: new ScopeSettings.ts(),
17
+ svelte: new ScopeSettings.svelte(),
18
+ mocha: new ScopeSettings.mocha(),
19
+ html: new ScopeSettings.html(),
20
+ json: new ScopeSettings.json(),
21
+ jsonc: new ScopeSettings.jsonc(),
22
+ yml: new ScopeSettings.yml(),
23
23
  } as const;
24
24
 
25
25
  return [