@eslinted/core 0.0.1-rc.0 → 0.0.1-rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +65 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/options/HtmlOption.d.ts +5 -0
  6. package/dist/options/HtmlOption.d.ts.map +1 -0
  7. package/dist/options/HtmlOption.js +16 -0
  8. package/dist/options/HtmlOption.js.map +1 -0
  9. package/dist/options/JsOption.d.ts +5 -0
  10. package/dist/options/JsOption.d.ts.map +1 -0
  11. package/dist/options/JsOption.js +19 -0
  12. package/dist/options/JsOption.js.map +1 -0
  13. package/dist/options/JsonOption.d.ts +5 -0
  14. package/dist/options/JsonOption.d.ts.map +1 -0
  15. package/dist/options/JsonOption.js +16 -0
  16. package/dist/options/JsonOption.js.map +1 -0
  17. package/dist/options/JsoncOption.d.ts +5 -0
  18. package/dist/options/JsoncOption.d.ts.map +1 -0
  19. package/dist/options/JsoncOption.js +16 -0
  20. package/dist/options/JsoncOption.js.map +1 -0
  21. package/dist/options/MdOption.d.ts +5 -0
  22. package/dist/options/MdOption.d.ts.map +1 -0
  23. package/dist/options/MdOption.js +16 -0
  24. package/dist/options/MdOption.js.map +1 -0
  25. package/dist/options/SvelteOption.d.ts +10 -0
  26. package/dist/options/SvelteOption.d.ts.map +1 -0
  27. package/dist/options/SvelteOption.js +28 -0
  28. package/dist/options/SvelteOption.js.map +1 -0
  29. package/dist/options/TsOption.d.ts +8 -0
  30. package/dist/options/TsOption.d.ts.map +1 -0
  31. package/dist/options/TsOption.js +25 -0
  32. package/dist/options/TsOption.js.map +1 -0
  33. package/dist/options/YmlOption.d.ts +5 -0
  34. package/dist/options/YmlOption.d.ts.map +1 -0
  35. package/dist/options/YmlOption.js +16 -0
  36. package/dist/options/YmlOption.js.map +1 -0
  37. package/dist/options/option/Option.d.ts +5 -0
  38. package/dist/options/option/Option.d.ts.map +1 -0
  39. package/dist/options/option/Option.js +7 -0
  40. package/dist/options/option/Option.js.map +1 -0
  41. package/dist/options.d.ts +18 -0
  42. package/dist/options.d.ts.map +1 -0
  43. package/dist/options.js +17 -0
  44. package/dist/options.js.map +1 -0
  45. package/dist/rulesets/ruleset/Ruleset.d.ts +12 -0
  46. package/dist/rulesets/ruleset/Ruleset.d.ts.map +1 -0
  47. package/dist/rulesets/ruleset/Ruleset.js +27 -0
  48. package/dist/rulesets/ruleset/Ruleset.js.map +1 -0
  49. package/dist/rulesets/ruleset/rule/Rule.d.ts +6 -0
  50. package/dist/rulesets/ruleset/rule/Rule.d.ts.map +1 -0
  51. package/dist/rulesets/ruleset/rule/Rule.js +9 -0
  52. package/dist/rulesets/ruleset/rule/Rule.js.map +1 -0
  53. package/dist/scopes.d.ts +3 -0
  54. package/dist/scopes.d.ts.map +1 -0
  55. package/dist/scopes.js +11 -0
  56. package/dist/scopes.js.map +1 -0
  57. package/interface/IConfig.d.ts +21 -0
  58. package/interface/files/IFiles.d.ts +1 -0
  59. package/interface/option/IOption.d.ts +25 -0
  60. package/interface/option/language/IOLanguage.d.ts +15 -0
  61. package/interface/option/language/ecma/IOLanguageEcma.d.ts +20 -0
  62. package/interface/option/language/globals/IOLanguageGlobals.d.ts +3 -0
  63. package/interface/option/language/parser/IOLanguageParser.d.ts +3 -0
  64. package/interface/option/language/parserOptions/IOLanguageParserOptions.d.ts +5 -0
  65. package/interface/option/language/source/IOLanguageSource.d.ts +12 -0
  66. package/interface/option/linter/IOLinter.d.ts +30 -0
  67. package/interface/option/name/IOName.d.ts +3 -0
  68. package/interface/option/plugins/IOPlugins.d.ts +3 -0
  69. package/interface/option/processor/IOProcessor.d.ts +3 -0
  70. package/interface/rules/IRules.d.ts +1 -0
  71. package/interface/rules/rule/IRule.d.ts +1 -0
  72. package/interface/rules/rule/state/RuleSeverity.d.ts +5 -0
  73. package/package.json +2 -2
  74. package/src/Scope.d.ts +9 -0
  75. package/src/index.ts +113 -0
  76. package/src/options/HtmlOption.ts +31 -0
  77. package/src/options/JsOption.ts +27 -0
  78. package/src/options/JsonOption.ts +31 -0
  79. package/src/options/JsoncOption.ts +31 -0
  80. package/src/options/MdOption.ts +31 -0
  81. package/src/options/SvelteOption.ts +47 -0
  82. package/src/options/TsOption.ts +40 -0
  83. package/src/options/YmlOption.ts +31 -0
  84. package/src/options/option/Option.ts +25 -0
  85. package/src/options.ts +17 -0
  86. package/src/plugins.d.ts +24 -0
  87. package/src/rulesets/ruleset/Ruleset.ts +50 -0
  88. package/src/rulesets/ruleset/rule/Rule.ts +6 -0
  89. package/src/scopes.ts +11 -0
  90. package/tsconfig.json +4 -2
  91. package/types/literal/number/base32.d.ts +19 -0
  92. package/types/literal/number/base64.d.ts +35 -0
  93. package/types/literal/number/binary.d.ts +4 -0
  94. package/types/literal/number/decimal.d.ts +5 -0
  95. package/types/literal/number/hex.d.ts +10 -0
  96. package/types/literal/number/octal.d.ts +7 -0
  97. package/types/literal/number/quatral.d.ts +4 -0
  98. package/types/literal/number/ternary.d.ts +4 -0
  99. package/types/literal/string/base64char.d.ts +13 -0
  100. package/types/literal/string/digit.d.ts +12 -0
  101. package/types/literal/string/hexchar.d.ts +9 -0
  102. package/types/literal/string/letter.d.ts +35 -0
  103. package/types/safe/Safe.d.ts +2 -0
  104. package/types/safe/numbers/finite/Finite.d.ts +2 -0
  105. package/types/safe/numbers/finite.d.ts +1 -0
  106. package/types/safe/numbers/fint.d.ts +1 -0
  107. package/types/safe/numbers/int/Int.d.ts +2 -0
  108. package/types/safe/numbers/int.d.ts +1 -0
  109. package/types/safe/numbers/numberful.d.ts +1 -0
  110. package/types/safe/numbers/polarity/Negative.d.ts +4 -0
  111. package/types/safe/numbers/polarity/Positive.d.ts +4 -0
  112. package/types/safe/numbers/polarity/pole/Pole.d.ts +18 -0
  113. package/types/safe/primitive.d.ts +5 -0
  114. package/types/safe/strings/char.d.ts +1 -0
  115. package/types/safe/strings/length/PropLength.d.ts +3 -0
  116. package/types/safe/strings/stringful.d.ts +1 -0
  117. package/types/utility/interface/construct/Particord.d.ts +1 -0
  118. package/types/utility/interface/construct/Property.d.ts +8 -0
  119. package/types/utility/interface/construct/Recordful.d.ts +5 -0
  120. package/types/utility/interface/construct/Table.d.ts +3 -0
  121. package/types/utility/interface/construct/properties/Field.d.ts +1 -0
  122. package/types/utility/interface/construct/properties/Flag.d.ts +1 -0
  123. package/types/utility/interface/construct/properties/Limit.d.ts +8 -0
  124. package/types/utility/interface/construct/properties/List.d.ts +1 -0
  125. package/types/utility/interface/construct/properties/Listish.d.ts +1 -0
  126. package/types/utility/interface/construct/properties/Scalar.d.ts +1 -0
  127. package/types/utility/interface/construct/tables/FieldTable.d.ts +1 -0
  128. package/types/utility/interface/construct/tables/FlagTable.d.ts +1 -0
  129. package/types/utility/interface/construct/tables/ListTable.d.ts +1 -0
  130. package/types/utility/interface/construct/tables/ListishTable.d.ts +1 -0
  131. package/types/utility/interface/construct/tables/ScalarTable.d.ts +1 -0
  132. package/types/utility/interface/identity/Interface.d.ts +80 -0
  133. package/types/utility/interface/identity/Keys.d.ts +71 -0
  134. package/types/utility/interface/transform/Unrequire.d.ts +45 -0
  135. package/types/utility/iterable/construct/ArrayN.d.ts +12 -0
  136. package/types/utility/iterable/construct/Tuple.d.ts +27 -0
  137. package/types/utility/iterable/construct/arrays/Arrays.d.ts +1 -0
  138. package/types/utility/iterable/construct/tuples/Tuples.d.ts +9 -0
  139. package/types/utility/iterable/identity/DyadType.d.ts +3 -0
  140. package/types/utility/iterable/identity/MonadType.d.ts +48 -0
  141. package/types/utility/iterable/identity/TriadType.d.ts +3 -0
  142. package/types/utility/iterable/identity/array/ArrayType.d.ts +65 -0
  143. package/types/utility/iterable/identity/array/length/ArrayLength.d.ts +16 -0
  144. package/types/utility/iterable/transform/Join.d.ts +19 -0
  145. package/types/utility/iterable/transform/Unflat.d.ts +3 -0
  146. package/types/utility/iterable/transform/stringarray/Chain.d.ts +30 -0
  147. package/types/utility/iterable/transform/stringarray/PathN.d.ts +3 -0
  148. package/types/utility/iterable/transform/stringarray/stringify/Stringify.d.ts +5 -0
  149. package/types/utility/length/Length.d.ts +35 -0
  150. package/types/utility/null/null.d.ts +1 -0
  151. package/types/utility/null/nullable.d.ts +1 -0
  152. package/types/utility/primitive/Primeval.d.ts +42 -0
  153. package/types/utility/primitive/boolean/True.d.ts +30 -0
  154. package/types/utility/primitive/number/Numbered.d.ts +35 -0
  155. package/types/utility/primitive/string/literal.d.ts +22 -0
  156. package/types/utility/primitive/string/literalful.d.ts +28 -0
@@ -0,0 +1,20 @@
1
+ declare type IOLanguageEcma<Ecma extends number | IOLanguageEcma.Ecma> = [Ecma] extends [number]
2
+ ? Numbered<Ecma> extends never
3
+ ? object
4
+ : { ecmaVersion: Numbered<Ecma> }
5
+
6
+ : [Ecma] extends [string]
7
+ ? literalful<Ecma> extends never
8
+ ? object
9
+ : literalful<Ecma> extends IOLanguageEcma.Ecma
10
+ ? { ecmaVersion: literalful<Ecma> }
11
+ : object
12
+ : object;
13
+
14
+ declare namespace IOLanguageEcma {
15
+ export type Ecma =
16
+ | `${number}`
17
+ | `ES${number}`
18
+ | `es${number}`
19
+ | "latest";
20
+ }
@@ -0,0 +1,3 @@
1
+ declare type IOLanguageGlobals<GlobalTypes extends string> = literalful<GlobalTypes> extends never
2
+ ? object
3
+ : { globals: Record<literalful<GlobalTypes>, true> };
@@ -0,0 +1,3 @@
1
+ declare type IOLanguageParser<UseParser extends boolean> = True<UseParser> extends never
2
+ ? object
3
+ : { parser: unknown };
@@ -0,0 +1,5 @@
1
+ declare type IOLanguageParserOptions<ParserOptions extends object> = Interface<ParserOptions> extends never
2
+ ? object
3
+ : Keys<ParserOptions> extends never
4
+ ? object
5
+ : { parserOptions: Interface<ParserOptions> };
@@ -0,0 +1,12 @@
1
+ declare type IOLanguageSource<Source extends IOLanguageSource.Source> = literalful<Source> extends never
2
+ ? object
3
+ : literalful<Source> extends IOLanguageSource.Source
4
+ ? { sourceType: literalful<Source> }
5
+ : object;
6
+
7
+ declare namespace IOLanguageSource {
8
+ export type Source =
9
+ | "module"
10
+ | "script"
11
+ | "commonjs";
12
+ }
@@ -0,0 +1,30 @@
1
+ declare type IOLinter<
2
+ NoInline extends boolean,
3
+ ReportUnused extends
4
+ | boolean
5
+ | IOLinter.States,
6
+ > = {
7
+ linterOptions: {
8
+ noInlineConfig: True<NoInline> extends never
9
+ ? false
10
+ : True<NoInline>;
11
+ reportUnusedDisableDirectives: [ReportUnused] extends [boolean]
12
+ ? True<ReportUnused> extends never
13
+ ? false
14
+ : True<ReportUnused>
15
+ : [ReportUnused] extends [string]
16
+ ? literalful<ReportUnused> extends never
17
+ ? false
18
+ : literalful<ReportUnused> extends IOLinter.States
19
+ ? literalful<ReportUnused>
20
+ : false
21
+ : false;
22
+ };
23
+ };
24
+
25
+ declare namespace IOLinter {
26
+ export type States =
27
+ | "error"
28
+ | "warn"
29
+ | "off";
30
+ }
@@ -0,0 +1,3 @@
1
+ declare type IOName<Name extends string> = literalful<Name> extends never
2
+ ? never
3
+ : { name: literalful<Name> };
@@ -0,0 +1,3 @@
1
+ declare type IOPlugins<PluginId extends string> = literalful<PluginId> extends never
2
+ ? never
3
+ : { plugins: Record<literalful<PluginId>, { configs: unknown }> };
@@ -0,0 +1,3 @@
1
+ declare type IOProcessor<ProcessorId extends string> = literalful<ProcessorId> extends never
2
+ ? object
3
+ : { processor: literalful<ProcessorId> };
@@ -0,0 +1 @@
1
+ declare interface IRules { rules: IRule }
@@ -0,0 +1 @@
1
+ type IRule = Record<string, RuleSeverity | [RuleSeverity, ...unknown[]]>;
@@ -0,0 +1,5 @@
1
+ declare type RuleSeverity =
2
+ | "error"
3
+ | "warn"
4
+ | "off"
5
+ ;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@eslinted/core",
3
- "version": "0.0.1-rc.0",
3
+ "version": "0.0.1-rc.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "private": false,
9
9
  "config": {
10
- "PACKAGE_JSON_VERSION": "20.9.0"
10
+ "PACKAGE_JSON_VERSION": "20.9.1"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
package/src/Scope.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ declare type Scope =
2
+ | "js"
3
+ | "ts"
4
+ | "svelte"
5
+ | "html"
6
+ | "json"
7
+ | "jsonc"
8
+ | "yml"
9
+ ;
package/src/index.ts CHANGED
@@ -0,0 +1,113 @@
1
+ import scopes from "./scopes.js";
2
+ import options from "./options.js";
3
+ import type Ruleset from "./rulesets/ruleset/Ruleset.js";
4
+
5
+ export { default as Ruleset } from "./rulesets/ruleset/Ruleset.js";
6
+ export { Rule } from "./rulesets/ruleset/Ruleset.js";
7
+ export default function (
8
+ plugins: Plugins,
9
+ parsers: Record<Scope, unknown>,
10
+ files: Record<Scope, string[]>,
11
+ rulesets: { [S in Scope]: Ruleset<S> },
12
+ ): IConfig[] {
13
+ try {
14
+ const instantiatedOptions: {
15
+ [S in Scope]: InstanceType<
16
+ typeof options[S]
17
+ >["body"]
18
+ } = {
19
+ js: new options
20
+ .js(
21
+ plugins
22
+ .js,
23
+ ...files
24
+ .js,
25
+ )
26
+ .body,
27
+ ts: new options
28
+ .ts(
29
+ plugins
30
+ .ts,
31
+ parsers
32
+ .ts,
33
+ ...files
34
+ .ts,
35
+ )
36
+ .body,
37
+ svelte: new options
38
+ .svelte(
39
+ plugins
40
+ .svelte,
41
+ parsers
42
+ .svelte,
43
+ parsers
44
+ .ts,
45
+ ...files
46
+ .svelte,
47
+ )
48
+ .body,
49
+ html: new options
50
+ .html(
51
+ plugins
52
+ .html,
53
+ parsers
54
+ .html,
55
+ ...files
56
+ .html,
57
+ )
58
+ .body,
59
+ json: new options
60
+ .json(
61
+ plugins
62
+ .json,
63
+ parsers
64
+ .json,
65
+ ...files
66
+ .json,
67
+ )
68
+ .body,
69
+ jsonc: new options
70
+ .jsonc(
71
+ plugins
72
+ .jsonc,
73
+ parsers
74
+ .jsonc,
75
+ ...files
76
+ .jsonc,
77
+ )
78
+ .body,
79
+ yml: new options
80
+ .yml(
81
+ plugins
82
+ .yml,
83
+ parsers
84
+ .yml,
85
+ ...files
86
+ .yml,
87
+ )
88
+ .body,
89
+ };
90
+
91
+ return scopes
92
+ .map(
93
+ scope =>
94
+ instantiatedOptions[scope].files.length > 0
95
+ ? rulesets[scope].flat.map(
96
+ rules => {
97
+ return {
98
+ rules,
99
+ ...instantiatedOptions[scope],
100
+ };
101
+ },
102
+ )
103
+ : [],
104
+ )
105
+ .flat();
106
+ }
107
+ catch (e) {
108
+ throw new Error(
109
+ `linted(): Caught exception.`,
110
+ { cause: e },
111
+ );
112
+ }
113
+ }
@@ -0,0 +1,31 @@
1
+ import Option from "./option/Option.js";
2
+
3
+ export default class HtmlOption extends Option<
4
+ "html",
5
+ "@html-eslint",
6
+ true,
7
+ never,
8
+ never,
9
+ never,
10
+ never,
11
+ never
12
+ > {
13
+ constructor(
14
+ plugins: HtmlOption["body"]["plugins"],
15
+ parser: HtmlOption["body"]["languageOptions"]["parser"],
16
+ ...files: string[]
17
+ ) {
18
+ super(
19
+ {
20
+ name: "linted/scope:html",
21
+ files,
22
+ plugins,
23
+ linterOptions: {
24
+ noInlineConfig: true,
25
+ reportUnusedDisableDirectives: "error",
26
+ },
27
+ languageOptions: { parser },
28
+ },
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,27 @@
1
+ import Option from "./option/Option.js";
2
+
3
+ export default class JsOption extends Option<
4
+ "js",
5
+ "@stylistic"
6
+ > {
7
+ constructor(
8
+ plugins: JsOption["body"]["plugins"],
9
+ ...files: string[]
10
+ ) {
11
+ super(
12
+ {
13
+ name: "linted/scope:js",
14
+ files,
15
+ plugins,
16
+ linterOptions: {
17
+ noInlineConfig: true,
18
+ reportUnusedDisableDirectives: "error",
19
+ },
20
+ languageOptions: {
21
+ ecmaVersion: "latest",
22
+ sourceType: "module",
23
+ },
24
+ },
25
+ );
26
+ }
27
+ }
@@ -0,0 +1,31 @@
1
+ import Option from "./option/Option.js";
2
+
3
+ export default class JsonOption extends Option<
4
+ "json",
5
+ "jsonc",
6
+ true,
7
+ never,
8
+ never,
9
+ never,
10
+ never,
11
+ never
12
+ > {
13
+ constructor(
14
+ plugins: JsonOption["body"]["plugins"],
15
+ parser: JsonOption["body"]["languageOptions"]["parser"],
16
+ ...files: string[]
17
+ ) {
18
+ super(
19
+ {
20
+ name: "linted/scope:json",
21
+ files,
22
+ plugins,
23
+ linterOptions: {
24
+ noInlineConfig: true,
25
+ reportUnusedDisableDirectives: "error",
26
+ },
27
+ languageOptions: { parser },
28
+ },
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,31 @@
1
+ import Option from "./option/Option.js";
2
+
3
+ export default class JsoncOption extends Option<
4
+ "jsonc",
5
+ "jsonc",
6
+ true,
7
+ never,
8
+ never,
9
+ never,
10
+ never,
11
+ never
12
+ > {
13
+ constructor(
14
+ plugins: JsoncOption["body"]["plugins"],
15
+ parser: JsoncOption["body"]["languageOptions"]["parser"],
16
+ ...files: string[]
17
+ ) {
18
+ super(
19
+ {
20
+ name: "linted/scope:jsonc",
21
+ files,
22
+ plugins,
23
+ linterOptions: {
24
+ noInlineConfig: true,
25
+ reportUnusedDisableDirectives: "error",
26
+ },
27
+ languageOptions: { parser },
28
+ },
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,31 @@
1
+ import Option from "./option/Option.js";
2
+
3
+ export default class MdOption extends Option<
4
+ "md",
5
+ "yml",
6
+ true,
7
+ never,
8
+ never,
9
+ never,
10
+ never,
11
+ never
12
+ > {
13
+ constructor(
14
+ plugins: MdOption["body"]["plugins"],
15
+ parser: MdOption["body"]["languageOptions"]["parser"],
16
+ ...files: string[]
17
+ ) {
18
+ super(
19
+ {
20
+ name: "linted/scope:md",
21
+ files,
22
+ plugins,
23
+ linterOptions: {
24
+ noInlineConfig: true,
25
+ reportUnusedDisableDirectives: "error",
26
+ },
27
+ languageOptions: { parser },
28
+ },
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,47 @@
1
+ import Option from "./option/Option.js";
2
+ import type TsOption from "./TsOption.js";
3
+
4
+ export default class SvelteOption extends Option<
5
+ "svelte",
6
+ | "svelte"
7
+ | keyof TsOption["body"]["plugins"]
8
+ ,
9
+ true,
10
+ & TsOption["body"]["languageOptions"]["parserOptions"]
11
+ & { parser: unknown }
12
+ & { extraFileExtensions: [".svelte"] },
13
+ never,
14
+ "svelte/svelte"
15
+ > {
16
+ constructor(
17
+ plugins: SvelteOption["body"]["plugins"],
18
+ svelteParser: SvelteOption["body"]["languageOptions"]["parser"],
19
+ tsParser: SvelteOption["body"]["languageOptions"]["parserOptions"]["parser"],
20
+ ...files: string[]
21
+ ) {
22
+ super(
23
+ {
24
+ name: "linted/scope:svelte",
25
+ processor: "svelte/svelte",
26
+ files,
27
+ plugins,
28
+ linterOptions: {
29
+ noInlineConfig: true,
30
+ reportUnusedDisableDirectives: "error",
31
+ },
32
+ languageOptions: {
33
+ ecmaVersion: "latest",
34
+ sourceType: "module",
35
+ parser: svelteParser,
36
+ parserOptions: {
37
+ ecmaVersion: "latest",
38
+ sourceType: "module",
39
+ project: "tsconfig.json",
40
+ extraFileExtensions: [".svelte"],
41
+ parser: tsParser,
42
+ },
43
+ },
44
+ },
45
+ );
46
+ }
47
+ }
@@ -0,0 +1,40 @@
1
+ import Option from "./option/Option.js";
2
+ import type JsOption from "./JsOption.js";
3
+
4
+ export default class TsOption extends Option<
5
+ "ts",
6
+ | "@typescript-eslint"
7
+ | keyof JsOption["body"]["plugins"]
8
+ ,
9
+ true,
10
+ & JsOption["body"]["languageOptions"]
11
+ & { project: "tsconfig.json" }
12
+ > {
13
+ constructor(
14
+ plugins: TsOption["body"]["plugins"],
15
+ parser: unknown,
16
+ ...files: string[]
17
+ ) {
18
+ super(
19
+ {
20
+ name: "linted/scope:ts",
21
+ files,
22
+ plugins,
23
+ linterOptions: {
24
+ noInlineConfig: true,
25
+ reportUnusedDisableDirectives: "error",
26
+ },
27
+ languageOptions: {
28
+ ecmaVersion: "latest",
29
+ sourceType: "module",
30
+ parser,
31
+ parserOptions: {
32
+ ecmaVersion: "latest",
33
+ sourceType: "module",
34
+ project: "tsconfig.json",
35
+ },
36
+ },
37
+ },
38
+ );
39
+ }
40
+ }
@@ -0,0 +1,31 @@
1
+ import Option from "./option/Option.js";
2
+
3
+ export default class YmlOption extends Option<
4
+ "yml",
5
+ "yml",
6
+ true,
7
+ never,
8
+ never,
9
+ never,
10
+ never,
11
+ never
12
+ > {
13
+ constructor(
14
+ plugins: YmlOption["body"]["plugins"],
15
+ parser: YmlOption["body"]["languageOptions"]["parser"],
16
+ ...files: string[]
17
+ ) {
18
+ super(
19
+ {
20
+ name: "linted/scope:yml",
21
+ files,
22
+ plugins,
23
+ linterOptions: {
24
+ noInlineConfig: true,
25
+ reportUnusedDisableDirectives: "error",
26
+ },
27
+ languageOptions: { parser },
28
+ },
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,25 @@
1
+ export default class Option<
2
+ Scope extends string,
3
+ PluginId extends string,
4
+ UseParser extends boolean = never,
5
+ ParserOptions extends object = never,
6
+ GlobalTypes extends string = never,
7
+ ProcessorId extends string = never,
8
+ Source extends IOLanguageSource.Source = "module",
9
+ Ecma extends number | IOLanguageEcma.Ecma = "latest",
10
+ > {
11
+ constructor(
12
+ public readonly body: IOption<
13
+ `linted/scope:${literalful<Scope>}`,
14
+ true,
15
+ "error",
16
+ PluginId,
17
+ Ecma,
18
+ Source,
19
+ UseParser,
20
+ ParserOptions,
21
+ GlobalTypes,
22
+ ProcessorId
23
+ >,
24
+ ) {}
25
+ }
package/src/options.ts ADDED
@@ -0,0 +1,17 @@
1
+ import JsOption from "./options/JsOption.js";
2
+ import TsOption from "./options/TsOption.js";
3
+ import SvelteOption from "./options/SvelteOption.js";
4
+ import HtmlOption from "./options/HtmlOption.js";
5
+ import JsonOption from "./options/JsonOption.js";
6
+ import JsoncOption from "./options/JsoncOption.js";
7
+ import YmlOption from "./options/YmlOption.js";
8
+
9
+ export default {
10
+ js: JsOption,
11
+ ts: TsOption,
12
+ svelte: SvelteOption,
13
+ html: HtmlOption,
14
+ json: JsonOption,
15
+ jsonc: JsoncOption,
16
+ yml: YmlOption,
17
+ } satisfies Record<Scope, unknown>;
@@ -0,0 +1,24 @@
1
+ type PluginPackage = { configs: unknown };
2
+
3
+ declare interface Plugins extends Record<
4
+ Scope,
5
+ Record<
6
+ string,
7
+ { configs: unknown }
8
+ >
9
+ > {
10
+ js: { "@stylistic": PluginPackage };
11
+ ts: {
12
+ "@stylistic": PluginPackage;
13
+ "@typescript-eslint": PluginPackage;
14
+ };
15
+ svelte: {
16
+ "@stylistic": PluginPackage;
17
+ "@typescript-eslint": PluginPackage;
18
+ svelte: PluginPackage;
19
+ };
20
+ html: { "@html-eslint": PluginPackage };
21
+ json: { jsonc: PluginPackage };
22
+ jsonc: { jsonc: PluginPackage };
23
+ yml: { yml: PluginPackage };
24
+ }
@@ -0,0 +1,50 @@
1
+ import Rule from "./rule/Rule.js";
2
+
3
+ export { default as Rule } from "./rule/Rule.js";
4
+ export default class Ruleset<Language extends string> {
5
+ public readonly ruleset: readonly Rule[];
6
+ public readonly overrides: Rule[] = [];
7
+
8
+ constructor(
9
+ protected readonly language: literalful<Language>,
10
+ ...ruleset: readonly Rule[]
11
+ ) {
12
+ this.ruleset = [...ruleset];
13
+ }
14
+
15
+ public get id() {
16
+ return `ruleset:${this.language}` as const;
17
+ }
18
+
19
+ public get flat() {
20
+ return [
21
+ ...this.ruleset.map(
22
+ rules =>
23
+ rules.rules,
24
+ ),
25
+ ...this.overrides.map(
26
+ rules =>
27
+ rules.rules,
28
+ ),
29
+ ];
30
+ }
31
+
32
+ public override(...overrides: (undefined | IRule)[]) {
33
+ this.overrides.push(
34
+ ...overrides
35
+ .filter(
36
+ override =>
37
+ typeof override !== "undefined",
38
+ )
39
+ .map(
40
+ override =>
41
+ new Rule(
42
+ "override",
43
+ override,
44
+ ),
45
+ ),
46
+ );
47
+
48
+ return this;
49
+ }
50
+ }
@@ -0,0 +1,6 @@
1
+ export default class Rule {
2
+ constructor(
3
+ public readonly id: string,
4
+ public readonly rules: IRule,
5
+ ) {}
6
+ }
package/src/scopes.ts ADDED
@@ -0,0 +1,11 @@
1
+ const scopes = [
2
+ "js",
3
+ "ts",
4
+ "svelte",
5
+ "html",
6
+ "json",
7
+ "jsonc",
8
+ "yml",
9
+ ] as const satisfies Scope[];
10
+
11
+ export default scopes;
package/tsconfig.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "display": "@jimbojet/tsc",
3
- "_version": "5.5.7",
3
+ "_version": "5.5.8",
4
4
  "$schema": "https://json.schemastore.org/tsconfig",
5
5
  "include": [
6
- "src/**/*.ts",
7
6
  "*.config.ts",
7
+ "src/**/*.ts",
8
+ "interface/**/*.d.ts",
9
+ "types/**/*.d.ts",
8
10
  ],
9
11
  "compilerOptions": {
10
12
  /* Visit https://aka.ms/tsconfig to read more about this file */