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

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 (43) hide show
  1. package/.github/workflows/RELEASE.yml +36 -36
  2. package/.github/workflows/rc.yml +36 -36
  3. package/.markdownlint.jsonc +128 -128
  4. package/.mocharc.yml +15 -15
  5. package/LICENSE +20 -20
  6. package/README.md +4 -4
  7. package/eslint.config.js +3 -3
  8. package/package.json +56 -56
  9. package/src/_test/index.ts +266 -266
  10. package/src/factory.ts +306 -306
  11. package/src/index.spec.ts +106 -106
  12. package/src/index.ts +87 -87
  13. package/src/interface/config/index.ts +42 -42
  14. package/src/interface/config/rule.ts +12 -12
  15. package/src/interface/index.ts +3 -3
  16. package/src/interface/input/configuration/attachment.ts +13 -13
  17. package/src/interface/input/configuration/defaults.ts +24 -24
  18. package/src/interface/input/configuration/extensions.ts +25 -25
  19. package/src/interface/input/configuration/index.ts +17 -17
  20. package/src/interface/input/configuration/manifest/index.ts +15 -15
  21. package/src/interface/input/configuration/settings.ts +18 -18
  22. package/src/interface/input/imports/index.ts +16 -16
  23. package/src/interface/input/imports/optional.ts +11 -11
  24. package/src/interface/input/imports/required.ts +13 -13
  25. package/src/interface/input/index.ts +22 -22
  26. package/src/interface/output/configs/attachment.ts +13 -13
  27. package/src/interface/output/configs/global/ignores.d.ts +6 -6
  28. package/src/interface/output/configs/global/index.d.ts +3 -3
  29. package/src/interface/output/configs/global/plugins.d.ts +6 -6
  30. package/src/interface/output/configs/global/settings.d.ts +11 -11
  31. package/src/interface/output/configs/index.d.ts +3 -3
  32. package/src/interface/output/configs/scoped/index.d.ts +2 -2
  33. package/src/interface/output/configs/scoped/rules.d.ts +12 -12
  34. package/src/interface/output/configs/scoped/settings.d.ts +15 -15
  35. package/src/interface/output/index.d.ts +12 -12
  36. package/src/scope/dependencies/index.ts +2 -2
  37. package/src/scope/dependencies/parsers.ts +5 -5
  38. package/src/scope/dependencies/plugins.ts +12 -12
  39. package/src/scope/index.spec.ts +136 -136
  40. package/src/scope/index.ts +18 -18
  41. package/src/scope/tree/index.spec.ts +124 -124
  42. package/src/scope/tree/index.ts +22 -22
  43. package/tsconfig.json +156 -156
package/src/factory.ts CHANGED
@@ -1,306 +1,306 @@
1
- import globals from "globals";
2
- import type { Input } from "./interface";
3
-
4
- export class Factory<
5
- RequiredPlugin extends string,
6
- RequiredParser extends string,
7
- OptionalImport extends string,
8
- Scope extends string,
9
- > {
10
- public global;
11
- public scopes;
12
-
13
- constructor(
14
- optionalScopes: readonly Scope[],
15
- tree: Array<
16
- readonly [
17
- Scope,
18
- readonly Scope[],
19
- ]
20
- >,
21
- private readonly settings: Input<
22
- RequiredPlugin,
23
- RequiredParser,
24
- OptionalImport,
25
- Scope
26
- >["configuration"]["settings"],
27
- public parsers: Record<
28
- RequiredParser,
29
- unknown
30
- > & Partial<
31
- Record<
32
- OptionalImport,
33
- unknown
34
- >
35
- >,
36
- defaults: Input<
37
- RequiredPlugin,
38
- RequiredParser,
39
- OptionalImport,
40
- Scope
41
- >["configuration"]["defaults"],
42
- {
43
- "*": globalExtension = {},
44
- ...scopeExtensions
45
- }: Input<
46
- RequiredPlugin,
47
- RequiredParser,
48
- OptionalImport,
49
- Scope
50
- >["configuration"]["extensions"] = {},
51
- public readonly attachments: Input<
52
- RequiredPlugin,
53
- RequiredParser,
54
- OptionalImport,
55
- Scope
56
- >["configuration"]["attachments"] = [],
57
- ) {
58
- const {
59
- noInlineConfig = settings
60
- .global
61
- .noInlineConfig,
62
- reportUnusedDisableDirectives = settings
63
- .global
64
- .reportUnusedDisableDirectives,
65
- sourceType = settings
66
- .global
67
- .sourceType,
68
- ecmaVersion = settings
69
- .global
70
- .ecmaVersion,
71
- } = globalExtension,
72
- {
73
- ignores = [],
74
- override = false,
75
- } = globalExtension;
76
-
77
- this.global = {
78
- settings: {
79
- name: "linted/*/settings/" as const,
80
- linterOptions: {
81
- noInlineConfig,
82
- reportUnusedDisableDirectives,
83
- },
84
- languageOptions: {
85
- sourceType,
86
- ecmaVersion,
87
- },
88
- },
89
- ignores: {
90
- name: "linted/*/ignores/" as const,
91
- ignores: [
92
- ...override
93
- ? []
94
- : defaults
95
- .ignores["*"],
96
- ...ignores,
97
- ],
98
- },
99
- };
100
- this.scopes = {
101
- files: defaults
102
- .files,
103
- ignores: defaults
104
- .ignores,
105
- rules: defaults
106
- .rules,
107
- };
108
-
109
- for (const scope in scopeExtensions) {
110
- const {
111
- [scope as keyof typeof scopeExtensions]: {
112
- files: userFiles = [],
113
- ignores: userIgnores = [],
114
- rules: userRules = null,
115
- } = {},
116
- } = scopeExtensions;
117
-
118
- this
119
- .scopes
120
- .files[scope as keyof typeof scopeExtensions]
121
- .push(...userFiles);
122
- this
123
- .scopes
124
- .ignores[scope as keyof typeof scopeExtensions]
125
- .push(...userIgnores);
126
-
127
- if (userRules !== null)
128
- this
129
- .scopes
130
- .rules[scope as keyof typeof scopeExtensions]
131
- .push(
132
- {
133
- id: scope + "/override",
134
- rules: userRules,
135
- },
136
- );
137
- }
138
-
139
- const OptionalScopes = new Set<Scope>(
140
- optionalScopes,
141
- );
142
-
143
- for (const [scope, parents] of tree)
144
- if (
145
- !OptionalScopes.has(scope)
146
- || scope in parsers
147
- )
148
- for (const parent of parents) {
149
- this
150
- .scopes
151
- .files[parent]
152
- .push(
153
- ...this
154
- .scopes
155
- .files[scope],
156
- );
157
- this
158
- .scopes
159
- .ignores[parent]
160
- .push(
161
- ...this
162
- .scopes
163
- .ignores[scope],
164
- );
165
- }
166
- }
167
-
168
- public get globals() {
169
- return [
170
- this.global.settings,
171
- this.global.ignores,
172
- ] as const;
173
- }
174
-
175
- public scope(scope: Scope) {
176
- const {
177
- files: {
178
- [scope]: files,
179
- },
180
- ignores: {
181
- [scope]: ignores,
182
- },
183
- rules: {
184
- [scope]: rules,
185
- },
186
- } = this.scopes,
187
- ruleset = rules
188
- .map(
189
- (
190
- {
191
- id,
192
- rules,
193
- },
194
- ) => {
195
- return {
196
- id: [
197
- scope,
198
- id,
199
- ]
200
- .join("/"),
201
- rules,
202
- };
203
- },
204
- ),
205
- {
206
- languageOptions: {
207
- parser = null,
208
- globals: global = null,
209
- ...extraLanguageOptions
210
- },
211
- parserOptions: {
212
- parser: subparser = null,
213
- ...extraParserOptions
214
- },
215
- processor = null,
216
- language = null,
217
- } = this.settings.registry[scope];
218
-
219
- function isGlobal(
220
- global: string,
221
- ): global is keyof typeof globals {
222
- return global in globals;
223
- }
224
-
225
- if (
226
- global !== null
227
- && !isGlobal(global)
228
- )
229
- throw new ReferenceError(
230
- "Global does not exist",
231
- { cause: { global } },
232
- );
233
-
234
- return files.length === 0
235
- ? []
236
- : ruleset.length === 0
237
- ? []
238
- : parser !== null
239
- && !(parser in this.parsers)
240
- || subparser !== null
241
- && !(subparser in this.parsers)
242
- ? []
243
- : [
244
- {
245
- name: `linted/${scope as string}/` as const,
246
- files,
247
- ignores,
248
- ...parser === null
249
- && global === null
250
- && subparser === null
251
- && [...Object.keys(extraLanguageOptions)].length === 0
252
- && [...Object.keys(extraParserOptions)].length === 0
253
- ? {}
254
- : {
255
- languageOptions: {
256
- ...extraLanguageOptions,
257
- ...global === null
258
- ? {}
259
- : {
260
- globals: globals[global],
261
- },
262
- ...parser === null
263
- ? {}
264
- : {
265
- parser: this.parsers[parser],
266
- },
267
- ...subparser === null
268
- && [...Object.keys(extraParserOptions)].length === 0
269
- ? {}
270
- : {
271
- parserOptions: {
272
- ...extraParserOptions,
273
- ...subparser === null
274
- ? {}
275
- : {
276
- parser: this.parsers[subparser],
277
- },
278
- },
279
- },
280
- },
281
- },
282
- ...processor === null
283
- ? {}
284
- : { processor },
285
- ...language === null
286
- ? {}
287
- : { language },
288
- },
289
- ...ruleset.map(
290
- (
291
- {
292
- id,
293
- rules,
294
- },
295
- ) => {
296
- return {
297
- name: `linted/${id}/` as const,
298
- files,
299
- ignores,
300
- rules,
301
- };
302
- },
303
- ),
304
- ];
305
- }
306
- }
1
+ import globals from "globals";
2
+ import type { Input } from "./interface";
3
+
4
+ export class Factory<
5
+ RequiredPlugin extends string,
6
+ RequiredParser extends string,
7
+ OptionalImport extends string,
8
+ Scope extends string,
9
+ > {
10
+ public global;
11
+ public scopes;
12
+
13
+ constructor(
14
+ optionalScopes: readonly Scope[],
15
+ tree: Array<
16
+ readonly [
17
+ Scope,
18
+ readonly Scope[],
19
+ ]
20
+ >,
21
+ private readonly settings: Input<
22
+ RequiredPlugin,
23
+ RequiredParser,
24
+ OptionalImport,
25
+ Scope
26
+ >["configuration"]["settings"],
27
+ public parsers: Record<
28
+ RequiredParser,
29
+ unknown
30
+ > & Partial<
31
+ Record<
32
+ OptionalImport,
33
+ unknown
34
+ >
35
+ >,
36
+ defaults: Input<
37
+ RequiredPlugin,
38
+ RequiredParser,
39
+ OptionalImport,
40
+ Scope
41
+ >["configuration"]["defaults"],
42
+ {
43
+ "*": globalExtension = {},
44
+ ...scopeExtensions
45
+ }: Input<
46
+ RequiredPlugin,
47
+ RequiredParser,
48
+ OptionalImport,
49
+ Scope
50
+ >["configuration"]["extensions"] = {},
51
+ public readonly attachments: Input<
52
+ RequiredPlugin,
53
+ RequiredParser,
54
+ OptionalImport,
55
+ Scope
56
+ >["configuration"]["attachments"] = [],
57
+ ) {
58
+ const {
59
+ noInlineConfig = settings
60
+ .global
61
+ .noInlineConfig,
62
+ reportUnusedDisableDirectives = settings
63
+ .global
64
+ .reportUnusedDisableDirectives,
65
+ sourceType = settings
66
+ .global
67
+ .sourceType,
68
+ ecmaVersion = settings
69
+ .global
70
+ .ecmaVersion,
71
+ } = globalExtension,
72
+ {
73
+ ignores = [],
74
+ override = false,
75
+ } = globalExtension;
76
+
77
+ this.global = {
78
+ settings: {
79
+ name: "linted/*/settings/" as const,
80
+ linterOptions: {
81
+ noInlineConfig,
82
+ reportUnusedDisableDirectives,
83
+ },
84
+ languageOptions: {
85
+ sourceType,
86
+ ecmaVersion,
87
+ },
88
+ },
89
+ ignores: {
90
+ name: "linted/*/ignores/" as const,
91
+ ignores: [
92
+ ...override
93
+ ? []
94
+ : defaults
95
+ .ignores["*"],
96
+ ...ignores,
97
+ ],
98
+ },
99
+ };
100
+ this.scopes = {
101
+ files: defaults
102
+ .files,
103
+ ignores: defaults
104
+ .ignores,
105
+ rules: defaults
106
+ .rules,
107
+ };
108
+
109
+ for (const scope in scopeExtensions) {
110
+ const {
111
+ [scope as keyof typeof scopeExtensions]: {
112
+ files: userFiles = [],
113
+ ignores: userIgnores = [],
114
+ rules: userRules = null,
115
+ } = {},
116
+ } = scopeExtensions;
117
+
118
+ this
119
+ .scopes
120
+ .files[scope as keyof typeof scopeExtensions]
121
+ .push(...userFiles);
122
+ this
123
+ .scopes
124
+ .ignores[scope as keyof typeof scopeExtensions]
125
+ .push(...userIgnores);
126
+
127
+ if (userRules !== null)
128
+ this
129
+ .scopes
130
+ .rules[scope as keyof typeof scopeExtensions]
131
+ .push(
132
+ {
133
+ id: scope + "/override",
134
+ rules: userRules,
135
+ },
136
+ );
137
+ }
138
+
139
+ const OptionalScopes = new Set<Scope>(
140
+ optionalScopes,
141
+ );
142
+
143
+ for (const [scope, parents] of tree)
144
+ if (
145
+ !OptionalScopes.has(scope)
146
+ || scope in parsers
147
+ )
148
+ for (const parent of parents) {
149
+ this
150
+ .scopes
151
+ .files[parent]
152
+ .push(
153
+ ...this
154
+ .scopes
155
+ .files[scope],
156
+ );
157
+ this
158
+ .scopes
159
+ .ignores[parent]
160
+ .push(
161
+ ...this
162
+ .scopes
163
+ .ignores[scope],
164
+ );
165
+ }
166
+ }
167
+
168
+ public get globals() {
169
+ return [
170
+ this.global.settings,
171
+ this.global.ignores,
172
+ ] as const;
173
+ }
174
+
175
+ public scope(scope: Scope) {
176
+ const {
177
+ files: {
178
+ [scope]: files,
179
+ },
180
+ ignores: {
181
+ [scope]: ignores,
182
+ },
183
+ rules: {
184
+ [scope]: rules,
185
+ },
186
+ } = this.scopes,
187
+ ruleset = rules
188
+ .map(
189
+ (
190
+ {
191
+ id,
192
+ rules,
193
+ },
194
+ ) => {
195
+ return {
196
+ id: [
197
+ scope,
198
+ id,
199
+ ]
200
+ .join("/"),
201
+ rules,
202
+ };
203
+ },
204
+ ),
205
+ {
206
+ languageOptions: {
207
+ parser = null,
208
+ globals: global = null,
209
+ ...extraLanguageOptions
210
+ },
211
+ parserOptions: {
212
+ parser: subparser = null,
213
+ ...extraParserOptions
214
+ },
215
+ processor = null,
216
+ language = null,
217
+ } = this.settings.registry[scope];
218
+
219
+ function isGlobal(
220
+ global: string,
221
+ ): global is keyof typeof globals {
222
+ return global in globals;
223
+ }
224
+
225
+ if (
226
+ global !== null
227
+ && !isGlobal(global)
228
+ )
229
+ throw new ReferenceError(
230
+ "Global does not exist",
231
+ { cause: { global } },
232
+ );
233
+
234
+ return files.length === 0
235
+ ? []
236
+ : ruleset.length === 0
237
+ ? []
238
+ : parser !== null
239
+ && !(parser in this.parsers)
240
+ || subparser !== null
241
+ && !(subparser in this.parsers)
242
+ ? []
243
+ : [
244
+ {
245
+ name: `linted/${scope as string}/` as const,
246
+ files,
247
+ ignores,
248
+ ...parser === null
249
+ && global === null
250
+ && subparser === null
251
+ && [...Object.keys(extraLanguageOptions)].length === 0
252
+ && [...Object.keys(extraParserOptions)].length === 0
253
+ ? {}
254
+ : {
255
+ languageOptions: {
256
+ ...extraLanguageOptions,
257
+ ...global === null
258
+ ? {}
259
+ : {
260
+ globals: globals[global],
261
+ },
262
+ ...parser === null
263
+ ? {}
264
+ : {
265
+ parser: this.parsers[parser],
266
+ },
267
+ ...subparser === null
268
+ && [...Object.keys(extraParserOptions)].length === 0
269
+ ? {}
270
+ : {
271
+ parserOptions: {
272
+ ...extraParserOptions,
273
+ ...subparser === null
274
+ ? {}
275
+ : {
276
+ parser: this.parsers[subparser],
277
+ },
278
+ },
279
+ },
280
+ },
281
+ },
282
+ ...processor === null
283
+ ? {}
284
+ : { processor },
285
+ ...language === null
286
+ ? {}
287
+ : { language },
288
+ },
289
+ ...ruleset.map(
290
+ (
291
+ {
292
+ id,
293
+ rules,
294
+ },
295
+ ) => {
296
+ return {
297
+ name: `linted/${id}/` as const,
298
+ files,
299
+ ignores,
300
+ rules,
301
+ };
302
+ },
303
+ ),
304
+ ];
305
+ }
306
+ }