@eslinted/core 4.0.5-rc.5 → 4.0.5-rc.7

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/files.d.ts +8 -0
  2. package/dist/factory/files.d.ts.map +1 -0
  3. package/dist/factory/files.js +19 -0
  4. package/dist/factory/files.js.map +1 -0
  5. package/dist/factory/index.d.ts +6 -0
  6. package/dist/factory/index.d.ts.map +1 -0
  7. package/dist/factory/index.js +5 -0
  8. package/dist/factory/index.js.map +1 -0
  9. package/dist/factory/options/html.d.ts +9 -0
  10. package/dist/factory/options/html.d.ts.map +1 -0
  11. package/dist/factory/options/html.js +10 -0
  12. package/dist/factory/options/html.js.map +1 -0
  13. package/dist/factory/options/index.d.ts +23 -0
  14. package/dist/factory/options/index.d.ts.map +1 -0
  15. package/dist/factory/options/index.js +21 -0
  16. package/dist/factory/options/index.js.map +1 -0
  17. package/dist/factory/options/js.d.ts +10 -0
  18. package/dist/factory/options/js.d.ts.map +1 -0
  19. package/dist/factory/options/js.js +12 -0
  20. package/dist/factory/options/js.js.map +1 -0
  21. package/dist/factory/options/json.d.ts +9 -0
  22. package/dist/factory/options/json.d.ts.map +1 -0
  23. package/dist/factory/options/json.js +10 -0
  24. package/dist/factory/options/json.js.map +1 -0
  25. package/dist/factory/options/jsonc.d.ts +9 -0
  26. package/dist/factory/options/jsonc.d.ts.map +1 -0
  27. package/dist/factory/options/jsonc.js +10 -0
  28. package/dist/factory/options/jsonc.js.map +1 -0
  29. package/dist/factory/options/md.d.ts +9 -0
  30. package/dist/factory/options/md.d.ts.map +1 -0
  31. package/dist/factory/options/md.js +10 -0
  32. package/dist/factory/options/md.js.map +1 -0
  33. package/dist/factory/options/mocha.d.ts +40 -0
  34. package/dist/factory/options/mocha.d.ts.map +1 -0
  35. package/dist/factory/options/mocha.js +17 -0
  36. package/dist/factory/options/mocha.js.map +1 -0
  37. package/dist/factory/options/option/index.d.ts +2986 -0
  38. package/dist/factory/options/option/index.d.ts.map +1 -0
  39. package/dist/factory/options/option/index.js +47 -0
  40. package/dist/factory/options/option/index.js.map +1 -0
  41. package/dist/factory/options/option/template/globals.d.ts +3 -0
  42. package/dist/factory/options/option/template/globals.d.ts.map +1 -0
  43. package/dist/factory/options/option/template/globals.js +1 -0
  44. package/dist/factory/options/option/template/globals.js.map +1 -0
  45. package/dist/factory/options/option/template/index.d.ts +15 -0
  46. package/dist/factory/options/option/template/index.d.ts.map +1 -0
  47. package/dist/factory/options/option/template/index.js +1 -0
  48. package/dist/factory/options/option/template/index.js.map +1 -0
  49. package/dist/factory/options/option/template/language/ecma.d.ts +2 -0
  50. package/dist/factory/options/option/template/language/ecma.d.ts.map +1 -0
  51. package/dist/factory/options/option/template/language/ecma.js +1 -0
  52. package/dist/factory/options/option/template/language/ecma.js.map +1 -0
  53. package/dist/factory/options/option/template/language/index.d.ts +14 -0
  54. package/dist/factory/options/option/template/language/index.d.ts.map +1 -0
  55. package/dist/factory/options/option/template/language/index.js +1 -0
  56. package/dist/factory/options/option/template/language/index.js.map +1 -0
  57. package/dist/factory/options/option/template/language/source.d.ts +2 -0
  58. package/dist/factory/options/option/template/language/source.d.ts.map +1 -0
  59. package/dist/factory/options/option/template/language/source.js +1 -0
  60. package/dist/factory/options/option/template/language/source.js.map +1 -0
  61. package/dist/factory/options/option/template/linter.d.ts +5 -0
  62. package/dist/factory/options/option/template/linter.d.ts.map +1 -0
  63. package/dist/factory/options/option/template/linter.js +1 -0
  64. package/dist/factory/options/option/template/linter.js.map +1 -0
  65. package/dist/factory/options/option/template/plugins.d.ts +6 -0
  66. package/dist/factory/options/option/template/plugins.d.ts.map +1 -0
  67. package/dist/factory/options/option/template/plugins.js +1 -0
  68. package/dist/factory/options/option/template/plugins.js.map +1 -0
  69. package/dist/factory/options/svelte.d.ts +27 -0
  70. package/dist/factory/options/svelte.d.ts.map +1 -0
  71. package/dist/factory/options/svelte.js +21 -0
  72. package/dist/factory/options/svelte.js.map +1 -0
  73. package/dist/factory/options/ts.d.ts +19 -0
  74. package/dist/factory/options/ts.d.ts.map +1 -0
  75. package/dist/factory/options/ts.js +15 -0
  76. package/dist/factory/options/ts.js.map +1 -0
  77. package/dist/factory/options/yml.d.ts +9 -0
  78. package/dist/factory/options/yml.d.ts.map +1 -0
  79. package/dist/factory/options/yml.js +10 -0
  80. package/dist/factory/options/yml.js.map +1 -0
  81. package/dist/factory/rulesets/index.d.ts +10 -0
  82. package/dist/factory/rulesets/index.d.ts.map +1 -0
  83. package/dist/factory/rulesets/index.js +17 -0
  84. package/dist/factory/rulesets/index.js.map +1 -0
  85. package/dist/factory/rulesets/ruleset.d.ts +10 -0
  86. package/dist/factory/rulesets/ruleset.d.ts.map +1 -0
  87. package/dist/factory/rulesets/ruleset.js +20 -0
  88. package/dist/factory/rulesets/ruleset.js.map +1 -0
  89. package/dist/index.d.ts +26 -0
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +31 -0
  92. package/dist/index.js.map +1 -0
  93. package/dist/input/files.d.ts +6 -0
  94. package/dist/input/files.d.ts.map +1 -0
  95. package/dist/input/files.js +1 -0
  96. package/dist/input/files.js.map +1 -0
  97. package/dist/input/imports/parsers.d.ts +3 -0
  98. package/dist/input/imports/parsers.d.ts.map +1 -0
  99. package/dist/input/imports/parsers.js +1 -0
  100. package/dist/input/imports/parsers.js.map +1 -0
  101. package/dist/input/imports/plugins.d.ts +2 -0
  102. package/dist/input/imports/plugins.d.ts.map +1 -0
  103. package/dist/input/imports/plugins.js +1 -0
  104. package/dist/input/imports/plugins.js.map +1 -0
  105. package/dist/input/index.d.ts +22 -0
  106. package/dist/input/index.d.ts.map +1 -0
  107. package/dist/input/index.js +1 -0
  108. package/dist/input/index.js.map +1 -0
  109. package/dist/input/parsers.d.ts +3 -0
  110. package/dist/input/parsers.d.ts.map +1 -0
  111. package/dist/input/parsers.js +1 -0
  112. package/dist/input/parsers.js.map +1 -0
  113. package/dist/input/plugins.d.ts +5 -0
  114. package/dist/input/plugins.d.ts.map +1 -0
  115. package/dist/input/plugins.js +1 -0
  116. package/dist/input/plugins.js.map +1 -0
  117. package/dist/input/rules/entry/index.d.ts +7 -0
  118. package/dist/input/rules/entry/index.d.ts.map +1 -0
  119. package/dist/input/rules/entry/index.js +1 -0
  120. package/dist/input/rules/entry/index.js.map +1 -0
  121. package/dist/input/rules/entry/record/index.d.ts +3 -0
  122. package/dist/input/rules/entry/record/index.d.ts.map +1 -0
  123. package/dist/input/rules/entry/record/index.js +1 -0
  124. package/dist/input/rules/entry/record/index.js.map +1 -0
  125. package/dist/input/rules/entry/record/state.d.ts +2 -0
  126. package/dist/input/rules/entry/record/state.d.ts.map +1 -0
  127. package/dist/input/rules/entry/record/state.js +1 -0
  128. package/dist/input/rules/entry/record/state.js.map +1 -0
  129. package/dist/input/rules/index.d.ts +14 -0
  130. package/dist/input/rules/index.d.ts.map +1 -0
  131. package/dist/input/rules/index.js +1 -0
  132. package/dist/input/rules/index.js.map +1 -0
  133. package/dist/output.d.ts +20 -0
  134. package/dist/output.d.ts.map +1 -0
  135. package/dist/output.js +1 -0
  136. package/dist/output.js.map +1 -0
  137. package/dist/scopes.d.ts +3 -0
  138. package/dist/scopes.d.ts.map +1 -0
  139. package/dist/scopes.js +12 -0
  140. package/dist/scopes.js.map +1 -0
  141. package/package.json +4 -10
  142. package/src/factory/files.ts +20 -9
  143. package/src/factory/index.ts +4 -2
  144. package/src/factory/options/index.ts +2 -0
  145. package/src/factory/options/option/index.ts +25 -33
  146. package/src/factory/options/option/template/globals.ts +5 -0
  147. package/src/factory/options/option/{template.ts → template/index.ts} +6 -4
  148. package/src/factory/options/option/template/language/ecma.ts +3 -0
  149. package/src/factory/options/option/{params/language.ts → template/language/index.ts} +3 -3
  150. package/src/factory/options/option/template/language/source.ts +4 -0
  151. package/src/factory/options/option/template/linter.ts +8 -0
  152. package/src/factory/options/option/template/plugins.ts +1 -0
  153. package/src/factory/rulesets/index.ts +24 -0
  154. package/src/factory/rulesets/ruleset.ts +25 -0
  155. package/src/index.ts +25 -21
  156. package/src/input/files.ts +6 -0
  157. package/src/{inputs → input}/imports/parsers.ts +1 -1
  158. package/src/{inputs → input}/imports/plugins.ts +3 -2
  159. package/src/input/index.ts +23 -0
  160. package/src/input/parsers.ts +3 -0
  161. package/src/input/plugins.ts +3 -0
  162. package/src/input/rules/entry/index.ts +7 -0
  163. package/src/input/rules/entry/record/index.ts +3 -0
  164. package/src/input/rules/entry/record/state.ts +5 -0
  165. package/src/input/rules/index.ts +14 -0
  166. package/src/output.ts +23 -23
  167. package/src/scopes.ts +1 -1
  168. package/tsconfig.json +5 -6
  169. package/src/factory/options/option/params/globals.ts +0 -3
  170. package/src/factory/options/option/params/languageOptions/ecma.ts +0 -1
  171. package/src/factory/options/option/params/languageOptions/source.ts +0 -1
  172. package/src/factory/options/option/params/linter.ts +0 -4
  173. package/src/factory/options/option/params/plugins.ts +0 -1
  174. package/src/factory/ruleset/index.ts +0 -41
  175. package/src/factory/ruleset/rule.ts +0 -8
  176. package/src/factory/rulesets.ts +0 -16
  177. package/src/input.ts +0 -11
  178. package/src/inputs/files/base.ts +0 -3
  179. package/src/inputs/files/includes.ts +0 -3
  180. package/src/inputs/files.ts +0 -7
  181. package/src/inputs/imports.ts +0 -2
  182. package/src/inputs/parsers.ts +0 -3
  183. package/src/inputs/plugins.ts +0 -3
  184. package/src/inputs/rules/entry/index.ts +0 -3
  185. package/src/inputs/rules/entry/object/index.ts +0 -7
  186. package/src/inputs/rules/entry/object/state/index.ts +0 -4
  187. package/src/inputs/rules/overrides.ts +0 -4
  188. package/src/inputs/rules/preset.ts +0 -4
  189. package/src/inputs/rules.ts +0 -7
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/input/plugins.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { RuleRecord } from "./record/index.js";
2
+ export type RuleEntry = readonly [string, RuleRecord];
3
+ export declare namespace RuleEntry {
4
+ type Id = string;
5
+ type Record = RuleRecord;
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/input/rules/entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACtD,yBAAiB,SAAS,CAAC;IACzB,KAAY,EAAE,GAAG,MAAM,CAAC;IACxB,KAAY,MAAM,GAAG,UAAU,CAAC;CACjC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/input/rules/entry/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { RuleState } from "./state.js";
2
+ export type RuleRecord = Table<RuleState | readonly [RuleState, ...unknown[]]>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/input/rules/entry/record/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/input/rules/entry/record/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type RuleState = ("error" | "warn" | "off");
2
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../src/input/rules/entry/record/state.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,CACpB,OAAO,GACP,MAAM,GACN,KAAK,CACR,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/input/rules/entry/record/state.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { Scope } from "../index.js";
2
+ import type { RuleEntry } from "./entry/index.js";
3
+ export interface RulesInput {
4
+ rules: Record<Scope, RuleEntry[]>;
5
+ overrides: Partial<Record<Scope, RuleEntry.Record>>;
6
+ }
7
+ export declare namespace RulesInput {
8
+ type Entry = RuleEntry;
9
+ namespace Entry {
10
+ type Id = RuleEntry.Id;
11
+ type Record = RuleEntry.Record;
12
+ }
13
+ }
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/input/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;CACrD;AACD,yBAAiB,UAAU,CAAC;IAC1B,KAAY,KAAK,GAAG,SAAS,CAAC;IAC9B,UAAiB,KAAK,CAAC;QACrB,KAAY,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;QAC9B,KAAY,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;KACvC;CACF"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/input/rules/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import type { Input } from "./index.js";
2
+ export type Output = ({
3
+ name: `linted/${string}`;
4
+ rules: Input["rules"]["rules"]["html"][number][1];
5
+ files: string[];
6
+ linterOptions: {
7
+ noInlineConfig: true;
8
+ reportUnusedDisableDirectives: "error";
9
+ };
10
+ languageOptions: {
11
+ sourceType?: "module" | "script";
12
+ ecmaVersion?: "latest";
13
+ globals?: Table<true>;
14
+ parser?: unknown;
15
+ parserOptions?: Record<string, unknown>;
16
+ };
17
+ plugins: Table<Record<"configs", unknown>>;
18
+ processor?: string;
19
+ })[];
20
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC;AAE/B,MAAM,MAAM,MAAM,GAAG,CACnB;IACE,IAAI,EAAE,UAAU,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,EAAE;QACb,cAAc,EAAE,IAAI,CAAC;QACrB,6BAA6B,EAAE,OAAO,CAAC;KACxC,CAAC;IACF,eAAe,EAAE;QACf,UAAU,CAAC,EACP,QAAQ,GACR,QAAQ,CAAC;QACb,WAAW,CAAC,EAAE,QAAQ,CAAC;QACvB,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACzC,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CACF,EAAE,CAAC"}
package/dist/output.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export type Scope = typeof scopes[number];
2
+ export declare const scopes: readonly ["js", "ts", "svelte", "mocha", "html", "json", "jsonc", "yml", "md"];
3
+ //# sourceMappingURL=scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1C,eAAO,MAAM,MAAM,gFAUT,CAAC"}
package/dist/scopes.js ADDED
@@ -0,0 +1,12 @@
1
+ export const scopes = [
2
+ "js",
3
+ "ts",
4
+ "svelte",
5
+ "mocha",
6
+ "html",
7
+ "json",
8
+ "jsonc",
9
+ "yml",
10
+ "md",
11
+ ];
12
+ //# sourceMappingURL=scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.js","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,IAAI;CACI,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "_schemaVersion": "20.18.0-core.0",
2
+ "_schemaVersion": "20.18.0",
3
3
  "name": "@eslinted/core",
4
- "version": "4.0.5-rc.5",
4
+ "version": "4.0.5-rc.7",
5
5
  "description": "Core ESLint flat config factory npm package `linted`.",
6
6
  "keywords": [],
7
7
  "repository": "github:jimmy-zhening-luo/linted-core",
@@ -13,14 +13,8 @@
13
13
  "access": "public"
14
14
  },
15
15
  "type": "module",
16
- "exports": {
17
- ".": {
18
- "import": {
19
- "types": "./dist/index.d.ts",
20
- "default": "./dist/index.js"
21
- }
22
- }
23
- },
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
24
18
  "config": {
25
19
  "language": "ts",
26
20
  "fix": "true",
@@ -1,15 +1,26 @@
1
- import type { Scope } from "@eslinted/core";
2
- import type { Input } from "@eslinted/core";
1
+ import type { Input } from ".";
3
2
 
4
3
  export class Files {
5
- constructor(private readonly input: Input["files"]) {}
4
+ private readonly _files = new Map<string, string[]>();
6
5
 
7
- public files(scope: Scope): readonly string[] {
8
- try {
9
- const { files, includes } = this.input;
6
+ constructor(private readonly input: Input["files"]) {
7
+ const { files, includes } = this.input,
8
+ scopes = Object.keys(files) as (keyof typeof files)[];
10
9
 
11
- return [...files[scope], ...includes[scope] ?? []];
12
- }
13
- catch (e) { throw new Error(`linted.factory.Files/scope:${scope}`, { cause: e }); }
10
+ for (const scope of scopes)
11
+ this._files.set(
12
+ scope,
13
+ [
14
+ ...files[scope],
15
+ ...scope in includes ? (includes[scope] as string[]) : [],
16
+ ],
17
+ );
18
+ }
19
+
20
+ public files(scope: string) {
21
+ if (!this._files.has(scope))
22
+ throw new ReferenceError(`Files not found for scope: ${scope}`);
23
+
24
+ return this._files.get(scope) as string[];
14
25
  }
15
26
  }
@@ -1,5 +1,7 @@
1
- import { Rulesets } from "./rulesets";
2
- import { Files } from "./files";
1
+ export type { Scope, Input, Output } from "..";
2
+
3
3
  import Options from "./options";
4
+ import { Files } from "./files";
5
+ import { Rulesets } from "./rulesets";
4
6
 
5
7
  export { Options, Files, Rulesets };
@@ -1,3 +1,5 @@
1
+ export type { Scope, Input, Output } from "..";
2
+
1
3
  import js from "./js";
2
4
  import ts from "./ts";
3
5
  import svelte from "./svelte";
@@ -1,14 +1,14 @@
1
- import type { Input } from "@eslinted/core";
2
- import type { Scope } from "@eslinted/core";
3
- import type { Output } from "@eslinted/core";
4
- import type { Ruleset } from "../../ruleset";
1
+ import globals from "globals";
2
+ import type { Ruleset } from "../../rulesets/ruleset";
5
3
  import type {
4
+ Scope,
5
+ Input,
6
+ Output,
6
7
  OptionTemplate,
7
8
  LanguageOptions,
8
9
  Plugins,
9
10
  Globals,
10
11
  } from "./template";
11
- import globals from "globals";
12
12
 
13
13
  export default abstract class Option<
14
14
  S extends Scope,
@@ -29,41 +29,33 @@ export default abstract class Option<
29
29
  : object;
30
30
 
31
31
  constructor(
32
- public readonly files: readonly string[],
33
- public readonly ruleset: Ruleset<S>,
34
32
  public readonly plugins: Plugins<Plugin>,
35
33
  public readonly parser: Tuple<unknown, ParserCount>,
34
+ public readonly files: string[],
35
+ public readonly ruleset: Ruleset,
36
36
  ) {}
37
37
 
38
38
  public get configs(): Output {
39
- try {
40
- const {
41
- scope,
42
- ruleset,
43
- files,
44
- option,
45
- } = this;
46
-
47
- if (ruleset.id !== scope)
48
- throw new TypeError(`Option and Ruleset scope mismatch`, { cause: { option: scope, ruleset: ruleset.id } });
49
- else if (files.length < 1)
50
- return [];
51
- else {
52
- const baseName = `linted/scope:${scope}/rule:${ruleset.id}` as const;
39
+ const {
40
+ scope,
41
+ ruleset,
42
+ files,
43
+ option,
44
+ } = this;
53
45
 
54
- return ruleset.records.map(([ruleId, rules]) => {
55
- const name = `${baseName}+${ruleId}` as const;
46
+ if (ruleset.scope !== scope)
47
+ throw new TypeError(`Scope mismatch between option and ruleset`, { cause: { option: scope, ruleset: ruleset.scope } });
56
48
 
57
- return {
58
- name,
59
- files,
60
- rules,
61
- ...option,
62
- };
63
- });
64
- }
65
- }
66
- catch (e) { throw new Error(`linted.factory.Option/scope:${this.scope}: configs`, { cause: e }); }
49
+ return files.length < 1
50
+ ? []
51
+ : ruleset.ruleset.map(({ id, rule }) => {
52
+ return {
53
+ name: `linted/${id}`,
54
+ files,
55
+ rules: rule,
56
+ ...option,
57
+ };
58
+ });
67
59
  }
68
60
 
69
61
  private get option() {
@@ -0,0 +1,5 @@
1
+ import type globals from "globals";
2
+
3
+ export type Globals = keyof typeof globals & (
4
+ | "mocha"
5
+ );
@@ -1,7 +1,9 @@
1
- import type { LanguageOptions } from "./params/language";
2
- import type { Linter } from "./params/linter";
3
- import type { Plugins } from "./params/plugins";
4
- import type { Globals } from "./params/globals";
1
+ export type { Scope, Input, Output } from "../..";
2
+
3
+ import type { LanguageOptions } from "./language";
4
+ import type { Linter } from "./linter";
5
+ import type { Plugins } from "./plugins";
6
+ import type { Globals } from "./globals";
5
7
 
6
8
  export type {
7
9
  LanguageOptions,
@@ -0,0 +1,3 @@
1
+ export type EcmaVersion = (
2
+ | "latest"
3
+ );
@@ -1,12 +1,12 @@
1
- import type { Ecma } from "./languageOptions/ecma";
2
- import type { Source } from "./languageOptions/source";
1
+ import type { EcmaVersion } from "./ecma";
2
+ import type { SourceType } from "./source";
3
3
 
4
4
  export type LanguageOptions<
5
5
  IsEcma extends boolean,
6
6
  ParserOptions extends object | boolean,
7
7
  GlobalTypes extends string,
8
8
  > =
9
- & (True<IsEcma> extends never ? object : { ecmaVersion: Ecma; sourceType: Source })
9
+ & (True<IsEcma> extends never ? object : { ecmaVersion: EcmaVersion; sourceType: SourceType })
10
10
  & (literalful<GlobalTypes> extends never ? object : { globals: Record<string, unknown> })
11
11
  & (
12
12
  ParserOptions extends boolean
@@ -0,0 +1,4 @@
1
+ export type SourceType = (
2
+ | "module"
3
+ | "script"
4
+ );
@@ -0,0 +1,8 @@
1
+ export interface Linter {
2
+ noInlineConfig: boolean;
3
+ reportUnusedDisableDirectives:
4
+ | "error"
5
+ | "warn"
6
+ | "off"
7
+ ;
8
+ }
@@ -0,0 +1 @@
1
+ export type Plugins<PluginId extends string> = { [P in literalful<PluginId>]: { configs: unknown } };
@@ -0,0 +1,24 @@
1
+ import type { Input } from "..";
2
+
3
+ export type { Input };
4
+
5
+ import { Ruleset } from "./ruleset";
6
+
7
+ export class Rulesets {
8
+ private readonly rulesets = new Map<string, Ruleset>();
9
+
10
+ constructor(private readonly input: Input["rules"]) {
11
+ const { rules, overrides } = this.input,
12
+ scopes = Object.keys(rules) as (keyof typeof rules)[];
13
+
14
+ for (const scope of scopes)
15
+ this.rulesets.set(scope, new Ruleset(scope, rules[scope], overrides[scope]));
16
+ }
17
+
18
+ public ruleset(scope: string): Ruleset {
19
+ if (!this.rulesets.has(scope))
20
+ throw new ReferenceError(`Ruleset not found for scope: ${scope}`);
21
+
22
+ return this.rulesets.get(scope) as Ruleset;
23
+ }
24
+ }
@@ -0,0 +1,25 @@
1
+ import type { Input } from ".";
2
+
3
+ export class Ruleset {
4
+ public readonly ruleset: { id: string; rule: Input.Rule.Entry.Record }[];
5
+
6
+ constructor(
7
+ public readonly scope: string,
8
+ rules: (readonly [string, Input.Rule.Entry.Record])[],
9
+ override?: Input.Rule.Entry.Record,
10
+ ) {
11
+ const map = ([id, rule]: typeof rules[number]) => {
12
+ return {
13
+ id: `${scope}:${id}`,
14
+ rule,
15
+ };
16
+ };
17
+
18
+ this.ruleset = [
19
+ ...rules.map(rule => map(rule)),
20
+ ...typeof override === "undefined"
21
+ ? []
22
+ : [map([`${scope}:override`, override])],
23
+ ];
24
+ }
25
+ }
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
+ export type { Scope } from "./scopes";
2
+
1
3
  import type { Input } from "./input";
2
- import type { Scope } from "./scopes";
3
4
  import type { Output } from "./output";
4
5
 
5
- export type { Input, Scope, Output };
6
+ export type { Input, Output };
6
7
 
7
8
  import { scopes } from "./scopes";
8
9
  import {
@@ -23,66 +24,66 @@ export default function (
23
24
  options: { [S in typeof scopes[number]]: InstanceType<typeof Options[S]>["configs"] } = {
24
25
  js: new Options
25
26
  .js(
26
- F.files("js"),
27
- R.ruleset("js"),
28
27
  { "@stylistic": plugins["@stylistic"] },
29
28
  [],
29
+ F.files("js"),
30
+ R.ruleset("js"),
30
31
  ).configs,
31
32
  ts: new Options
32
33
  .ts(
33
- F.files("ts"),
34
- R.ruleset("ts"),
35
34
  { "@stylistic": plugins["@stylistic"], "@typescript-eslint": plugins["@typescript-eslint"] },
36
35
  [parsers.ts],
36
+ F.files("ts"),
37
+ R.ruleset("ts"),
37
38
  ).configs,
38
39
  svelte: new Options
39
40
  .svelte(
40
- F.files("svelte"),
41
- R.ruleset("svelte"),
42
41
  { "@stylistic": plugins["@stylistic"], "@typescript-eslint": plugins["@typescript-eslint"], svelte: plugins.svelte },
43
42
  [parsers.svelte, parsers.ts],
43
+ F.files("svelte"),
44
+ R.ruleset("svelte"),
44
45
  ).configs,
45
46
  mocha: new Options
46
47
  .mocha(
47
- F.files("mocha"),
48
- R.ruleset("mocha"),
49
48
  { "@stylistic": plugins["@stylistic"], "@typescript-eslint": plugins["@typescript-eslint"], mocha: plugins.mocha },
50
49
  [parsers.ts],
50
+ F.files("mocha"),
51
+ R.ruleset("mocha"),
51
52
  ).configs,
52
53
  html: new Options
53
54
  .html(
54
- F.files("html"),
55
- R.ruleset("html"),
56
55
  { "@html-eslint": plugins["@html-eslint"] },
57
56
  [parsers.html],
57
+ F.files("html"),
58
+ R.ruleset("html"),
58
59
  ).configs,
59
60
  json: new Options
60
61
  .json(
61
- F.files("json"),
62
- R.ruleset("json"),
63
62
  { jsonc: plugins.jsonc },
64
63
  [parsers.jsonc],
64
+ F.files("json"),
65
+ R.ruleset("json"),
65
66
  ).configs,
66
67
  jsonc: new Options
67
68
  .jsonc(
68
- F.files("jsonc"),
69
- R.ruleset("jsonc"),
70
69
  { jsonc: plugins.jsonc },
71
70
  [parsers.jsonc],
71
+ F.files("jsonc"),
72
+ R.ruleset("jsonc"),
72
73
  ).configs,
73
74
  yml: new Options
74
75
  .yml(
75
- F.files("yml"),
76
- R.ruleset("yml"),
77
76
  { yml: plugins.yml },
78
77
  [parsers.yml],
78
+ F.files("yml"),
79
+ R.ruleset("yml"),
79
80
  ).configs,
80
81
  md: new Options
81
82
  .md(
82
- F.files("md"),
83
- R.ruleset("md"),
84
83
  { markdownlint: plugins.markdownlint },
85
84
  [parsers.md],
85
+ F.files("md"),
86
+ R.ruleset("md"),
86
87
  ).configs,
87
88
  };
88
89
 
@@ -91,8 +92,9 @@ export default function (
91
92
  catch (e) { throw new Error(`linted-core`, { cause: e }); }
92
93
  }
93
94
 
95
+ // #region DEPRECATED
94
96
  namespace Core {
95
- export type Scopes = Scope;
97
+ export type Scopes = typeof scopes[number];
96
98
  export namespace Input {
97
99
  export type Parsers = Input["parsers"];
98
100
  export type Plugins = Input["plugins"];
@@ -111,3 +113,5 @@ namespace Core {
111
113
  }
112
114
 
113
115
  export type { Core };
116
+
117
+ // #endregion
@@ -0,0 +1,6 @@
1
+ import type { Scope } from ".";
2
+
3
+ export interface FilesInput {
4
+ files: Record<Scope, string[]>;
5
+ includes: Partial<FilesInput["files"]>;
6
+ }
@@ -1,4 +1,4 @@
1
- import type { Scope } from "@eslinted/core";
1
+ import type { Scope } from "..";
2
2
 
3
3
  export type Parsers = Scope
4
4
  & (
@@ -1,4 +1,4 @@
1
- export type Plugins =
1
+ export type Plugins = (
2
2
  | "@stylistic"
3
3
  | "@typescript-eslint"
4
4
  | "svelte"
@@ -6,4 +6,5 @@ export type Plugins =
6
6
  | "@html-eslint"
7
7
  | "jsonc"
8
8
  | "yml"
9
- | "markdownlint";
9
+ | "markdownlint"
10
+ );
@@ -0,0 +1,23 @@
1
+ export type { Scope } from "../scopes";
2
+
3
+ import type { PluginsInput } from "./plugins";
4
+ import type { ParsersInput } from "./parsers";
5
+ import type { FilesInput } from "./files";
6
+ import type { RulesInput } from "./rules";
7
+
8
+ export interface Input {
9
+ plugins: PluginsInput;
10
+ parsers: ParsersInput;
11
+ files: FilesInput;
12
+ rules: RulesInput;
13
+ }
14
+ export namespace Input {
15
+ export type Rule = RulesInput;
16
+ export namespace Rule {
17
+ export type Entry = RulesInput.Entry;
18
+ export namespace Entry {
19
+ export type Id = RulesInput.Entry.Id;
20
+ export type Record = RulesInput.Entry.Record;
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,3 @@
1
+ import type { Parsers } from "./imports/parsers";
2
+
3
+ export type ParsersInput = Record<Parsers, unknown>;
@@ -0,0 +1,3 @@
1
+ import type { Plugins } from "./imports/plugins";
2
+
3
+ export type PluginsInput = Record<Plugins, { configs: unknown }>;
@@ -0,0 +1,7 @@
1
+ import type { RuleRecord } from "./record";
2
+
3
+ export type RuleEntry = readonly [string, RuleRecord];
4
+ export namespace RuleEntry {
5
+ export type Id = string;
6
+ export type Record = RuleRecord;
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { RuleState } from "./state";
2
+
3
+ export type RuleRecord = Table<RuleState | readonly [RuleState, ...unknown[]]>;
@@ -0,0 +1,5 @@
1
+ export type RuleState = (
2
+ | "error"
3
+ | "warn"
4
+ | "off"
5
+ );
@@ -0,0 +1,14 @@
1
+ import type { Scope } from "..";
2
+ import type { RuleEntry } from "./entry";
3
+
4
+ export interface RulesInput {
5
+ rules: Record<Scope, RuleEntry[]>;
6
+ overrides: Partial<Record<Scope, RuleEntry.Record>>;
7
+ }
8
+ export namespace RulesInput {
9
+ export type Entry = RuleEntry;
10
+ export namespace Entry {
11
+ export type Id = RuleEntry.Id;
12
+ export type Record = RuleEntry.Record;
13
+ }
14
+ }