@eslinted/core 26.0.0-rc.0 → 26.0.0-rc.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.
Files changed (106) hide show
  1. package/dist/factory.d.ts +4 -5
  2. package/dist/factory.d.ts.map +1 -1
  3. package/dist/factory.js +4 -6
  4. package/dist/factory.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/{_test/index.d.ts → index.input.spec.d.ts} +51 -68
  8. package/dist/index.input.spec.d.ts.map +1 -0
  9. package/dist/{_test/index.js → index.input.spec.js} +29 -52
  10. package/dist/index.input.spec.js.map +1 -0
  11. package/dist/index.js +4 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.spec.js +2 -2
  14. package/dist/index.spec.js.map +1 -1
  15. package/dist/interface/configuration/defaults/index.d.ts +12 -0
  16. package/dist/interface/configuration/defaults/index.d.ts.map +1 -0
  17. package/dist/interface/configuration/defaults/index.js.map +1 -0
  18. package/dist/interface/configuration/defaults/settings/index.d.ts +3 -0
  19. package/dist/interface/configuration/defaults/settings/index.d.ts.map +1 -0
  20. package/dist/interface/configuration/defaults/settings/index.js.map +1 -0
  21. package/dist/interface/{input/configuration/manifest/index.d.ts → configuration/defaults/settings/manifest.d.ts} +3 -3
  22. package/dist/interface/configuration/defaults/settings/manifest.d.ts.map +1 -0
  23. package/dist/interface/configuration/defaults/settings/manifest.js +2 -0
  24. package/dist/interface/configuration/defaults/settings/manifest.js.map +1 -0
  25. package/dist/interface/configuration/extensions/global.d.ts +7 -0
  26. package/dist/interface/configuration/extensions/global.d.ts.map +1 -0
  27. package/dist/interface/configuration/extensions/global.js +2 -0
  28. package/dist/interface/configuration/extensions/global.js.map +1 -0
  29. package/dist/interface/configuration/extensions/index.d.ts +4 -0
  30. package/dist/interface/configuration/extensions/index.d.ts.map +1 -0
  31. package/dist/interface/configuration/extensions/index.js.map +1 -0
  32. package/dist/interface/configuration/extensions/scopes.d.ts +10 -0
  33. package/dist/interface/configuration/extensions/scopes.d.ts.map +1 -0
  34. package/dist/interface/configuration/extensions/scopes.js +2 -0
  35. package/dist/interface/configuration/extensions/scopes.js.map +1 -0
  36. package/dist/interface/configuration/index.d.ts +7 -0
  37. package/dist/interface/configuration/index.d.ts.map +1 -0
  38. package/dist/interface/configuration/index.js.map +1 -0
  39. package/dist/interface/imports.d.ts.map +1 -0
  40. package/dist/interface/{input/imports.js.map → imports.js.map} +1 -1
  41. package/dist/interface/index.d.ts +6 -2
  42. package/dist/interface/index.d.ts.map +1 -1
  43. package/dist/interface/{config/rule.d.ts → rules.d.ts} +2 -2
  44. package/dist/interface/rules.d.ts.map +1 -0
  45. package/dist/interface/rules.js +2 -0
  46. package/dist/interface/rules.js.map +1 -0
  47. package/package.json +1 -1
  48. package/src/factory.ts +17 -26
  49. package/src/{_test/index.ts → index.input.spec.ts} +52 -73
  50. package/src/index.spec.ts +2 -2
  51. package/src/index.ts +20 -33
  52. package/src/interface/{input/configuration/defaults.ts → configuration/defaults/index.ts} +8 -2
  53. package/src/interface/configuration/defaults/settings/index.ts +6 -0
  54. package/src/interface/{input/configuration/manifest/index.ts → configuration/defaults/settings/manifest.ts} +2 -2
  55. package/src/interface/configuration/extensions/global.ts +6 -0
  56. package/src/interface/configuration/extensions/index.ts +9 -0
  57. package/src/interface/configuration/extensions/scopes.ts +21 -0
  58. package/src/interface/{input/configuration → configuration}/index.ts +2 -6
  59. package/src/interface/index.ts +22 -2
  60. package/tsconfig.json +2 -2
  61. package/dist/_test/index.d.ts.map +0 -1
  62. package/dist/_test/index.js.map +0 -1
  63. package/dist/interface/config/index.d.ts +0 -21
  64. package/dist/interface/config/index.d.ts.map +0 -1
  65. package/dist/interface/config/index.js.map +0 -1
  66. package/dist/interface/config/rule.d.ts.map +0 -1
  67. package/dist/interface/config/rule.js +0 -2
  68. package/dist/interface/config/rule.js.map +0 -1
  69. package/dist/interface/input/configuration/attachment.d.ts +0 -5
  70. package/dist/interface/input/configuration/attachment.d.ts.map +0 -1
  71. package/dist/interface/input/configuration/attachment.js +0 -2
  72. package/dist/interface/input/configuration/attachment.js.map +0 -1
  73. package/dist/interface/input/configuration/defaults.d.ts +0 -10
  74. package/dist/interface/input/configuration/defaults.d.ts.map +0 -1
  75. package/dist/interface/input/configuration/defaults.js +0 -2
  76. package/dist/interface/input/configuration/defaults.js.map +0 -1
  77. package/dist/interface/input/configuration/extensions.d.ts +0 -15
  78. package/dist/interface/input/configuration/extensions.d.ts.map +0 -1
  79. package/dist/interface/input/configuration/extensions.js +0 -2
  80. package/dist/interface/input/configuration/extensions.js.map +0 -1
  81. package/dist/interface/input/configuration/index.d.ts +0 -11
  82. package/dist/interface/input/configuration/index.d.ts.map +0 -1
  83. package/dist/interface/input/configuration/index.js.map +0 -1
  84. package/dist/interface/input/configuration/manifest/index.d.ts.map +0 -1
  85. package/dist/interface/input/configuration/manifest/index.js.map +0 -1
  86. package/dist/interface/input/configuration/settings.d.ts +0 -7
  87. package/dist/interface/input/configuration/settings.d.ts.map +0 -1
  88. package/dist/interface/input/configuration/settings.js +0 -2
  89. package/dist/interface/input/configuration/settings.js.map +0 -1
  90. package/dist/interface/input/imports.d.ts.map +0 -1
  91. package/dist/interface/input/index.d.ts +0 -7
  92. package/dist/interface/input/index.d.ts.map +0 -1
  93. package/dist/interface/input/index.js.map +0 -1
  94. package/src/interface/config/index.ts +0 -42
  95. package/src/interface/input/configuration/attachment.ts +0 -12
  96. package/src/interface/input/configuration/extensions.ts +0 -34
  97. package/src/interface/input/configuration/settings.ts +0 -18
  98. package/src/interface/input/index.ts +0 -22
  99. package/dist/interface/{config → configuration/defaults}/index.js +0 -0
  100. package/dist/interface/{input/configuration → configuration/defaults/settings}/index.js +0 -0
  101. package/dist/interface/{input/configuration/manifest → configuration/extensions}/index.js +0 -0
  102. package/dist/interface/{input → configuration}/index.js +0 -0
  103. package/dist/interface/{input/imports.d.ts → imports.d.ts} +0 -0
  104. package/dist/interface/{input/imports.js → imports.js} +0 -0
  105. package/src/interface/{input/imports.ts → imports.ts} +0 -0
  106. package/src/interface/{config/rule.ts → rules.ts} +7 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interface/configuration/defaults/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { ScopeManifest } from "./manifest.js";
2
+ export type Settings<Scope extends string, Parser extends Scope> = Record<Scope, ScopeManifest<Parser>>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/interface/configuration/defaults/settings/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,QAAQ,CAClB,KAAK,SAAS,MAAM,EACpB,MAAM,SAAS,KAAK,IAClB,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/interface/configuration/defaults/settings/index.ts"],"names":[],"mappings":""}
@@ -1,13 +1,13 @@
1
1
  export interface ScopeManifest<Parser extends string> {
2
- languageOptions: {
2
+ languageOptions?: {
3
3
  [property: string]: unknown;
4
4
  parser?: Parser;
5
5
  };
6
- parserOptions: {
6
+ parserOptions?: {
7
7
  [property: string]: unknown;
8
8
  parser?: Parser;
9
9
  };
10
10
  language?: string;
11
11
  processor?: string;
12
12
  }
13
- //# sourceMappingURL=index.d.ts.map
13
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../../../src/interface/configuration/defaults/settings/manifest.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAC5B,MAAM,SAAS,MAAM;IAErB,eAAe,CAAC,EAAE;QAChB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,aAAa,CAAC,EAAE;QACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../../../src/interface/configuration/defaults/settings/manifest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface GlobalExtension {
2
+ "*": {
3
+ ignores?: string[];
4
+ override?: boolean;
5
+ };
6
+ }
7
+ //# sourceMappingURL=global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../../src/interface/configuration/extensions/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE;QACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/interface/configuration/extensions/global.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { GlobalExtension } from "./global.js";
2
+ import type { ScopeExtensions } from "./scopes.js";
3
+ export type Extensions<Scope extends string, OptionalScope extends Scope> = Partial<GlobalExtension> & Partial<ScopeExtensions<Scope, OptionalScope>>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/interface/configuration/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,MAAM,UAAU,CACpB,KAAK,SAAS,MAAM,EACpB,aAAa,SAAS,KAAK,IAEzB,OAAO,CAAC,eAAe,CAAC,GACxB,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interface/configuration/extensions/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { Rules } from "../../rules.js";
2
+ export type ScopeExtensions<Scope extends string, OptionalScope extends Scope> = Record<Scope, {
3
+ files?: string[];
4
+ ignores?: string[];
5
+ rules?: Rules;
6
+ }> & Record<OptionalScope, {
7
+ plugin: unknown;
8
+ parser: unknown;
9
+ }>;
10
+ //# sourceMappingURL=scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../../src/interface/configuration/extensions/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,eAAe,CACzB,KAAK,SAAS,MAAM,EACpB,aAAa,SAAS,KAAK,IAEzB,MAAM,CACR,KAAK,EACL;IACE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CACF,GACC,MAAM,CACN,aAAa,EACb;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACjB,CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../../../src/interface/configuration/extensions/scopes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { Defaults } from "./defaults/index.js";
2
+ import type { Extensions } from "./extensions/index.js";
3
+ export interface Configuration<Scope extends string, OptionalScope extends Scope, Parser extends Scope> {
4
+ defaults: Defaults<Scope, Parser>;
5
+ extensions: Extensions<Scope, OptionalScope>;
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interface/configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,aAAa,CAC5B,KAAK,SAAS,MAAM,EACpB,aAAa,SAAS,KAAK,EAC3B,MAAM,SAAS,KAAK;IAEpB,QAAQ,EAAE,QAAQ,CAChB,KAAK,EACL,MAAM,CACP,CAAC;IACF,UAAU,EAAE,UAAU,CACpB,KAAK,EACL,aAAa,CACd,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interface/configuration/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/interface/imports.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO,CACtB,cAAc,SAAS,MAAM,EAC7B,cAAc,SAAS,MAAM;IAE7B,OAAO,EAAE,MAAM,CACb,cAAc,EACd,OAAO,CACR,CAAC;IACF,OAAO,EAAE,MAAM,CACb,cAAc,EACd,OAAO,CACR,CAAC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"imports.js","sourceRoot":"","sources":["../../../src/interface/input/imports.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"imports.js","sourceRoot":"","sources":["../../src/interface/imports.ts"],"names":[],"mappings":""}
@@ -1,3 +1,7 @@
1
- export type * from "./input/index.js";
2
- export type * from "./config/index.js";
1
+ import type { Imports } from "./imports.js";
2
+ import type { Configuration } from "./configuration/index.js";
3
+ export interface Input<Scope extends string, OptionalScope extends Scope, RequiredPlugin extends string, RequiredParser extends Scope> {
4
+ imports: Imports<RequiredPlugin, RequiredParser>;
5
+ configuration: Configuration<Scope, OptionalScope, (RequiredParser | OptionalScope)>;
6
+ }
3
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,KAAK,CACpB,KAAK,SAAS,MAAM,EACpB,aAAa,SAAS,KAAK,EAC3B,cAAc,SAAS,MAAM,EAC7B,cAAc,SAAS,KAAK;IAE5B,OAAO,EAAE,OAAO,CACd,cAAc,EACd,cAAc,CACf,CAAC;IACF,aAAa,EAAE,aAAa,CAC1B,KAAK,EACL,aAAa,EACb,CACI,cAAc,GACd,aAAa,CAChB,CACF,CAAC;CACH"}
@@ -1,6 +1,6 @@
1
- export type State = 0 | 1 | 2 | "off" | "warn" | "error";
2
1
  export type Rules = Record<string, State | readonly [
3
2
  State,
4
3
  ...unknown[]
5
4
  ]>;
6
- //# sourceMappingURL=rule.d.ts.map
5
+ export type State = 0 | 1 | 2 | "off" | "warn" | "error";
6
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/interface/rules.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,MAAM,CACxB,MAAM,EACJ,KAAK,GACL,SAAS;IACT,KAAK;IACL,GAAG,OAAO,EAAE;CACb,CACF,CAAC;AACF,MAAM,MAAM,KAAK,GACb,CAAC,GACD,CAAC,GACD,CAAC,GACD,KAAK,GACL,MAAM,GACN,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/interface/rules.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -3,7 +3,7 @@
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": "26.0.0-rc.0",
6
+ "version": "26.0.0-rc.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": [],
package/src/factory.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import type { Input } from "./interface";
2
2
 
3
3
  export class Factory<
4
- RequiredPlugin extends string,
5
- RequiredParser extends Scope,
6
4
  Scope extends string,
7
5
  OptionalScope extends Scope,
6
+ RequiredPlugin extends string,
7
+ RequiredParser extends Scope,
8
8
  > {
9
9
  public globalConfigs;
10
10
  public scopes;
11
11
  public parsers;
12
+ private readonly settings;
12
13
 
13
14
  constructor(
14
15
  tree: Array<
@@ -22,36 +23,26 @@ export class Factory<
22
23
  plugins,
23
24
  parsers,
24
25
  }: Input<
25
- RequiredPlugin,
26
- RequiredParser,
27
26
  Scope,
28
- OptionalScope
29
- >["imports"],
30
- private readonly settings: Input<
27
+ OptionalScope,
31
28
  RequiredPlugin,
32
- RequiredParser,
33
- Scope,
34
- OptionalScope
35
- >["configuration"]["settings"],
29
+ RequiredParser
30
+ >["imports"],
36
31
  defaults: Input<
37
- RequiredPlugin,
38
- RequiredParser,
39
32
  Scope,
40
- OptionalScope
33
+ OptionalScope,
34
+ RequiredPlugin,
35
+ RequiredParser
41
36
  >["configuration"]["defaults"],
42
37
  extensions: Input<
43
- RequiredPlugin,
44
- RequiredParser,
45
38
  Scope,
46
- OptionalScope
47
- >["configuration"]["extensions"] = {},
48
- public readonly attachments: Input<
39
+ OptionalScope,
49
40
  RequiredPlugin,
50
- RequiredParser,
51
- Scope,
52
- OptionalScope
53
- >["configuration"]["attachments"] = [],
41
+ RequiredParser
42
+ >["configuration"]["extensions"] = {},
54
43
  ) {
44
+ this.settings = defaults.settings;
45
+
55
46
  if ("svelte" in extensions && "plugin" in (extensions.svelte as object)) {
56
47
  Object.assign(
57
48
  plugins,
@@ -182,11 +173,11 @@ export class Factory<
182
173
  return [];
183
174
  else {
184
175
  const {
185
- languageOptions,
186
- parserOptions,
176
+ languageOptions = {},
177
+ parserOptions = {},
187
178
  processor,
188
179
  language,
189
- } = this.settings.registry[scope];
180
+ } = this.settings[scope];
190
181
 
191
182
  if ("parser" in languageOptions)
192
183
  if (languageOptions.parser in this.parsers)
@@ -1,10 +1,12 @@
1
- const
2
- ERROR = 2,
3
- OFF = 0,
4
- Plugin = "MOCK_PLUGIN",
1
+ const enum State {
2
+ OFF = 0,
3
+ WARN = 1,
4
+ ERROR = 2,
5
+ }
6
+ const Plugin = "MOCK_PLUGIN",
5
7
  Parser = (scope: string) => `MOCK_PARSER:${scope}`;
6
8
 
7
- export const TEST_INPUT = {
9
+ export const MOCK_INPUT = {
8
10
  imports: {
9
11
  plugins: {
10
12
  "@stylistic": Plugin,
@@ -25,28 +27,15 @@ export const TEST_INPUT = {
25
27
  },
26
28
  },
27
29
  configuration: {
28
- settings: {
29
- global: {
30
- ecmaVersion: 2024,
31
- sourceType: "module",
32
- noInlineConfig: true,
33
- reportUnusedDisableDirectives: "error",
34
- } as const,
35
- registry: {
36
- js: {
37
- languageOptions: {},
38
- parserOptions: {},
39
- },
30
+ defaults: {
31
+ settings: {
32
+ js: {},
40
33
  ts: {
41
34
  languageOptions: {
42
35
  parser: "ts" as const,
43
36
  },
44
- parserOptions: {},
45
- },
46
- mocha: {
47
- languageOptions: {},
48
- parserOptions: {},
49
37
  },
38
+ mocha: {},
50
39
  svelte: {
51
40
  languageOptions: {
52
41
  parser: "svelte" as const,
@@ -70,35 +59,26 @@ export const TEST_INPUT = {
70
59
  languageOptions: {
71
60
  tolerant: false,
72
61
  },
73
- parserOptions: {},
74
62
  language: "css/css",
75
63
  },
76
64
  json: {
77
65
  languageOptions: {
78
66
  allowTrailingCommas: true,
79
67
  },
80
- parserOptions: {},
81
68
  language: "json/jsonc",
82
69
  },
83
70
  jsonc: {
84
- languageOptions: {},
85
- parserOptions: {},
86
71
  language: "json/jsonc",
87
72
  },
88
73
  jsoncc: {
89
- languageOptions: {},
90
- parserOptions: {},
91
74
  language: "json/jsonc",
92
75
  },
93
76
  yml: {
94
77
  languageOptions: {
95
78
  parser: "yml" as const,
96
79
  },
97
- parserOptions: {},
98
80
  },
99
81
  },
100
- },
101
- defaults: {
102
82
  files: {
103
83
  js: ["default.js"],
104
84
  ts: ["default.ts"],
@@ -129,99 +109,99 @@ export const TEST_INPUT = {
129
109
  {
130
110
  id: "enable",
131
111
  rules: {
132
- vanilla: ERROR,
133
- vanilla0: ERROR,
134
- vanilla1: ERROR,
135
- vanilla2: ERROR,
136
- } as const,
112
+ vanilla: State.ERROR,
113
+ vanilla0: State.ERROR,
114
+ vanilla1: State.ERROR,
115
+ vanilla2: State.ERROR,
116
+ },
137
117
  },
138
118
  {
139
119
  id: "enable/stylistic",
140
120
  rules: {
141
- "@stylistic/style-rule": ERROR,
142
- } as const,
121
+ "@stylistic/style-rule": State.ERROR,
122
+ },
143
123
  },
144
124
  ],
145
125
  ts: [
146
126
  {
147
127
  id: "disable",
148
128
  rules: {
149
- vanilla0: OFF,
150
- } as const,
129
+ vanilla0: State.OFF,
130
+ },
151
131
  },
152
132
  {
153
133
  id: "enable/extension",
154
134
  rules: {
155
- "@typescript-eslint/enums": ERROR,
156
- "@typescript-eslint/destructure-expression": ERROR,
157
- "@typescript-eslint/global": ERROR,
158
- } as const,
135
+ "@typescript-eslint/enums": State.ERROR,
136
+ "@typescript-eslint/destructure-expression": State.ERROR,
137
+ "@typescript-eslint/global": State.ERROR,
138
+ },
159
139
  },
160
140
  ],
161
141
  mocha: [
162
142
  {
163
143
  id: "disable",
164
144
  rules: {
165
- vanilla2: OFF,
166
- } as const,
145
+ vanilla2: State.OFF,
146
+ },
167
147
  },
168
148
  {
169
149
  id: "disable/ts",
170
150
  rules: {
171
- "@typescript-eslint/global": ERROR,
172
- } as const,
151
+ "@typescript-eslint/global": State.ERROR,
152
+ },
173
153
  },
174
154
  {
175
155
  id: "enable",
176
156
  rules: {
177
- "mocha/test-expression": ERROR,
178
- } as const,
157
+ "mocha/test-expression": State.ERROR,
158
+ },
179
159
  },
180
160
  ],
181
161
  svelte: [
182
162
  {
183
163
  id: "disable",
184
164
  rules: {
185
- vanilla1: OFF,
186
- } as const,
165
+ vanilla1: State.OFF,
166
+ },
187
167
  },
188
168
  {
189
169
  id: "enable-extension",
190
170
  rules: {
191
- "svelte/tags": ERROR,
192
- } as const,
171
+ "svelte/tags": State.ERROR,
172
+ },
193
173
  },
194
174
  ],
195
175
  html: [
196
176
  {
197
177
  id: "enable",
198
178
  rules: {
199
- "html/attribute": ERROR,
200
- } as const,
179
+ "html/attribute": State.ERROR,
180
+ },
201
181
  },
202
182
  ],
203
183
  css: [
204
184
  {
205
185
  id: "enable",
206
186
  rules: {
207
- "css/property": ERROR,
208
- } as const,
187
+ "css/property": State.ERROR,
188
+ },
209
189
  },
210
190
  ],
211
191
  json: [
212
192
  {
213
193
  id: "enable",
214
194
  rules: {
215
- "jsonc/property-check": ERROR,
195
+ "jsonc/property-check": State.ERROR,
216
196
  "jsonc/comment": [
217
- ERROR,
197
+ State.ERROR,
218
198
  "never",
219
- ],
199
+ ] as const,
220
200
  "jsonc/trailing-comma": [
221
- ERROR,
201
+ State.ERROR,
222
202
  "never",
223
- ],
224
- } as const,
203
+ ] as const,
204
+ },
225
205
  },
226
206
  ],
227
207
  jsonc: [
@@ -229,10 +209,10 @@ export const TEST_INPUT = {
229
209
  id: "override-comment",
230
210
  rules: {
231
211
  "jsonc/comment": [
232
- ERROR,
212
+ State.ERROR,
233
213
  "allow",
234
- ],
235
- } as const,
214
+ ] as const,
215
+ },
236
216
  },
237
217
  ],
238
218
  jsoncc: [
@@ -240,23 +220,22 @@ export const TEST_INPUT = {
240
220
  id: "override-comma",
241
221
  rules: {
242
222
  "jsonc/trailing-comma": [
243
- ERROR,
223
+ State.ERROR,
244
224
  "allow",
245
- ],
246
- } as const,
225
+ ] as const,
226
+ },
247
227
  },
248
228
  ],
249
229
  yml: [
250
230
  {
251
231
  id: "enable",
252
232
  rules: {
253
- "yml/property-check": ERROR,
254
- } as const,
233
+ "yml/property-check": State.ERROR,
234
+ },
255
235
  },
256
236
  ],
257
237
  },
258
238
  },
259
239
  extensions: {},
260
- attachments: [],
261
240
  },
262
241
  };
package/src/index.spec.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import "chai/register-should.js";
2
2
  import Core from ".";
3
3
  import { scopes } from "./scope";
4
- import { TEST_INPUT } from "./_test";
4
+ import { MOCK_INPUT } from "./index.input.spec";
5
5
 
6
- const configs = Core(TEST_INPUT);
6
+ const configs = Core(MOCK_INPUT);
7
7
 
8
8
  describe(
9
9
  "Core",
package/src/index.ts CHANGED
@@ -14,46 +14,33 @@ export default function (
14
14
  {
15
15
  imports,
16
16
  configuration: {
17
- settings,
18
17
  defaults,
19
18
  extensions,
20
- attachments,
21
19
  },
22
20
  }: Input<
23
- RequiredPlugin,
24
- RequiredParser,
25
21
  (typeof scopes[number]),
26
- (typeof optionalScopes[number])
22
+ (typeof optionalScopes[number]),
23
+ RequiredPlugin,
24
+ RequiredParser
27
25
  >,
28
26
  ) {
29
- try {
30
- const factory = new Factory<
31
- RequiredPlugin,
32
- RequiredParser,
33
- (typeof scopes[number]),
34
- (typeof optionalScopes[number])
35
- >(
36
- tree,
37
- optionalScopes,
38
- imports,
39
- settings,
40
- defaults,
41
- extensions,
42
- attachments,
43
- );
27
+ const factory = new Factory<
28
+ (typeof scopes[number]),
29
+ (typeof optionalScopes[number]),
30
+ RequiredPlugin,
31
+ RequiredParser
32
+ >(
33
+ tree,
34
+ optionalScopes,
35
+ imports,
36
+ defaults,
37
+ extensions,
38
+ );
44
39
 
45
- return (factory.globals as unknown[])
46
- .concat(
47
- scopes.flatMap(
48
- scope => factory.scope(scope),
49
- ),
50
- factory.attachments,
51
- );
52
- }
53
- catch (e) {
54
- throw TypeError(
55
- "linted-core: ",
56
- { cause: e },
40
+ return (factory.globals as unknown[])
41
+ .concat(
42
+ scopes.flatMap(
43
+ scope => factory.scope(scope),
44
+ ),
57
45
  );
58
- }
59
46
  }
@@ -1,8 +1,14 @@
1
- import type { IConfig } from "../../config";
1
+ import type { Settings } from "./settings";
2
+ import type { Rules } from "../../rules";
2
3
 
3
4
  export interface Defaults<
4
5
  Scope extends string,
6
+ Parser extends Scope,
5
7
  > {
8
+ settings: Settings<
9
+ Scope,
10
+ Parser
11
+ >;
6
12
  files: Record<
7
13
  Scope,
8
14
  string[]
@@ -18,7 +24,7 @@ export interface Defaults<
18
24
  Scope,
19
25
  {
20
26
  id: string;
21
- rules: IConfig["rules"];
27
+ rules: Rules;
22
28
  }[]
23
29
  >;
24
30
  }
@@ -0,0 +1,6 @@
1
+ import type { ScopeManifest } from "./manifest";
2
+
3
+ export type Settings<
4
+ Scope extends string,
5
+ Parser extends Scope,
6
+ > = Record<Scope, ScopeManifest<Parser>>;
@@ -1,11 +1,11 @@
1
1
  export interface ScopeManifest<
2
2
  Parser extends string,
3
3
  > {
4
- languageOptions: {
4
+ languageOptions?: {
5
5
  [property: string]: unknown;
6
6
  parser?: Parser;
7
7
  };
8
- parserOptions: {
8
+ parserOptions?: {
9
9
  [property: string]: unknown;
10
10
  parser?: Parser;
11
11
  };
@@ -0,0 +1,6 @@
1
+ export interface GlobalExtension {
2
+ "*": {
3
+ ignores?: string[];
4
+ override?: boolean;
5
+ };
6
+ }