@useinsider/eslint-config 3.0.0 → 3.0.2-beta.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.
- package/dist/configs/strict/index.d.ts +1 -0
- package/dist/main.cjs +195 -175
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +195 -175
- package/dist/main.js.map +1 -1
- package/dist/{strict-B2mCkeX_.js → strict-BHw_cKrv.js} +2 -1
- package/dist/strict-BHw_cKrv.js.map +1 -0
- package/dist/{strict-tmp-wKop.cjs → strict-DnJFBY_B.cjs} +2 -1
- package/dist/strict-DnJFBY_B.cjs.map +1 -0
- package/dist/utils/ensureConfigStructure.d.ts +10 -0
- package/package.json +2 -2
- package/dist/strict-B2mCkeX_.js.map +0 -1
- package/dist/strict-tmp-wKop.cjs.map +0 -1
|
@@ -4,6 +4,7 @@ declare const _default: Linter.FlatConfig<import("@eslint/core").RulesConfig> |
|
|
|
4
4
|
'sonarjs/void-use': "off";
|
|
5
5
|
'sonarjs/use-type-alias': "off";
|
|
6
6
|
'sonarjs/no-redundant-optional': "off";
|
|
7
|
+
'sonarjs/aws-restricted-ip-admin-access': "off";
|
|
7
8
|
'sonarjs/slow-regex': ["warn"];
|
|
8
9
|
'sonarjs/todo-tag': ["warn"];
|
|
9
10
|
'sonarjs/no-useless-intersection': ["error"];
|
package/dist/main.cjs
CHANGED
|
@@ -67,177 +67,6 @@ function buildJqueryBlocks(entries) {
|
|
|
67
67
|
}));
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
|
-
//#region src/builders/typescript.ts
|
|
71
|
-
function applyTypescriptOverrides(block, input) {
|
|
72
|
-
const languageOptions = block.languageOptions ?? {};
|
|
73
|
-
const parserOptions = languageOptions.parserOptions ?? {};
|
|
74
|
-
parserOptions.project = input.tsconfigPaths;
|
|
75
|
-
parserOptions.tsconfigRootDir = process.cwd();
|
|
76
|
-
languageOptions.parserOptions = parserOptions;
|
|
77
|
-
block.languageOptions = languageOptions;
|
|
78
|
-
return block;
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/builders/vue.ts
|
|
82
|
-
function escapeRegex(input) {
|
|
83
|
-
return input.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
84
|
-
}
|
|
85
|
-
function anchoredEscapeRegex(input) {
|
|
86
|
-
return `^${escapeRegex(input)}$`;
|
|
87
|
-
}
|
|
88
|
-
function applyVueOverrides(block, input) {
|
|
89
|
-
if (!input.globalComponents || input.globalComponents.length === 0) return block;
|
|
90
|
-
const rules = block.rules ?? {};
|
|
91
|
-
rules["vue/no-undef-components"] = ["error", { ignorePatterns: input.globalComponents.map(anchoredEscapeRegex) }];
|
|
92
|
-
block.rules = rules;
|
|
93
|
-
return block;
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/builders/scopeBlocks.ts
|
|
97
|
-
var scopeMap = {
|
|
98
|
-
async javascript() {
|
|
99
|
-
return Promise.resolve().then(() => require("./javascript-VBXqjVi8.cjs"));
|
|
100
|
-
},
|
|
101
|
-
async javascriptDom() {
|
|
102
|
-
return Promise.resolve().then(() => require("./javascript-dom-5jRL_yKP.cjs"));
|
|
103
|
-
},
|
|
104
|
-
async javascriptNode() {
|
|
105
|
-
return Promise.resolve().then(() => require("./javascript-node-C1AU_4X2.cjs"));
|
|
106
|
-
},
|
|
107
|
-
async typescript() {
|
|
108
|
-
return Promise.resolve().then(() => require("./typescript-C1icmOxY.cjs"));
|
|
109
|
-
},
|
|
110
|
-
async typescriptDom() {
|
|
111
|
-
return Promise.resolve().then(() => require("./typescript-dom-RUJn2WCZ.cjs"));
|
|
112
|
-
},
|
|
113
|
-
async typescriptNode() {
|
|
114
|
-
return Promise.resolve().then(() => require("./typescript-node-CBEzcc56.cjs"));
|
|
115
|
-
},
|
|
116
|
-
async vue2() {
|
|
117
|
-
return Promise.resolve().then(() => require("./vue2-azKwRgaJ.cjs"));
|
|
118
|
-
},
|
|
119
|
-
async vue3() {
|
|
120
|
-
return Promise.resolve().then(() => require("./vue3-Df5UQ1Ys.cjs"));
|
|
121
|
-
},
|
|
122
|
-
async vue2Typescript() {
|
|
123
|
-
return Promise.resolve().then(() => require("./vue2-typescript-CZSHzp7I.cjs"));
|
|
124
|
-
},
|
|
125
|
-
async vue3Typescript() {
|
|
126
|
-
return Promise.resolve().then(() => require("./vue3-typescript-C0O1JZlk.cjs"));
|
|
127
|
-
},
|
|
128
|
-
async vue2OptionsApi() {
|
|
129
|
-
return Promise.resolve().then(() => require("./vue2-options-api-ma3J-bvM.cjs"));
|
|
130
|
-
},
|
|
131
|
-
async vue3OptionsApi() {
|
|
132
|
-
return Promise.resolve().then(() => require("./vue3-options-api-Bx7yYHza.cjs"));
|
|
133
|
-
},
|
|
134
|
-
async vue2TypescriptOptionsApi() {
|
|
135
|
-
return Promise.resolve().then(() => require("./vue2-typescript-options-api-B8OzZlje.cjs"));
|
|
136
|
-
},
|
|
137
|
-
async vue3TypescriptOptionsApi() {
|
|
138
|
-
return Promise.resolve().then(() => require("./vue3-typescript-options-api-cPal4O-K.cjs"));
|
|
139
|
-
},
|
|
140
|
-
async jest() {
|
|
141
|
-
return Promise.resolve().then(() => require("./jest-CHzjzBtf.cjs"));
|
|
142
|
-
},
|
|
143
|
-
async vitest() {
|
|
144
|
-
return Promise.resolve().then(() => require("./vitest-BomI8gtu.cjs"));
|
|
145
|
-
},
|
|
146
|
-
async jsdocBasedTs() {
|
|
147
|
-
return Promise.resolve().then(() => require("./jsdoc-based-ts-Cfahz0nn.cjs"));
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var tsScopes = /* @__PURE__ */ new Set([
|
|
151
|
-
"typescript",
|
|
152
|
-
"typescriptDom",
|
|
153
|
-
"typescriptNode",
|
|
154
|
-
"vue2Typescript",
|
|
155
|
-
"vue3Typescript",
|
|
156
|
-
"vue2TypescriptOptionsApi",
|
|
157
|
-
"vue3TypescriptOptionsApi",
|
|
158
|
-
"jsdocBasedTs"
|
|
159
|
-
]);
|
|
160
|
-
var vueScopes = /* @__PURE__ */ new Set([
|
|
161
|
-
"vue2",
|
|
162
|
-
"vue3",
|
|
163
|
-
"vue2Typescript",
|
|
164
|
-
"vue3Typescript",
|
|
165
|
-
"vue2OptionsApi",
|
|
166
|
-
"vue3OptionsApi",
|
|
167
|
-
"vue2TypescriptOptionsApi",
|
|
168
|
-
"vue3TypescriptOptionsApi"
|
|
169
|
-
]);
|
|
170
|
-
function cloneLanguageOptions(languageOptions) {
|
|
171
|
-
const clone = { ...languageOptions };
|
|
172
|
-
if (languageOptions.parserOptions) clone.parserOptions = { ...languageOptions.parserOptions };
|
|
173
|
-
if (languageOptions.globals) clone.globals = { ...languageOptions.globals };
|
|
174
|
-
return clone;
|
|
175
|
-
}
|
|
176
|
-
function clonePreset(preset) {
|
|
177
|
-
const { languageOptions, rules, settings, ...rest } = preset;
|
|
178
|
-
const clone = { ...rest };
|
|
179
|
-
if (languageOptions) clone.languageOptions = cloneLanguageOptions(languageOptions);
|
|
180
|
-
if (rules) clone.rules = { ...rules };
|
|
181
|
-
if (settings) clone.settings = { ...settings };
|
|
182
|
-
return clone;
|
|
183
|
-
}
|
|
184
|
-
function isScopeName(key) {
|
|
185
|
-
return Object.keys(scopeMap).includes(key);
|
|
186
|
-
}
|
|
187
|
-
function applyCommonEntryFields(block, entry) {
|
|
188
|
-
if (entry.ignores && entry.ignores.length > 0) block.ignores = [...entry.ignores];
|
|
189
|
-
if (entry.globals) {
|
|
190
|
-
const languageOptions = block.languageOptions ?? {};
|
|
191
|
-
languageOptions.globals = {
|
|
192
|
-
...languageOptions.globals ?? {},
|
|
193
|
-
...entry.globals
|
|
194
|
-
};
|
|
195
|
-
block.languageOptions = languageOptions;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
async function buildScopeBlocks(scope, entries) {
|
|
199
|
-
const preset = (await scopeMap[scope]()).default;
|
|
200
|
-
return entries.map((entry) => {
|
|
201
|
-
const block = clonePreset(preset);
|
|
202
|
-
block.files = entry.files;
|
|
203
|
-
if (tsScopes.has(scope)) {
|
|
204
|
-
const { tsconfigPaths } = entry;
|
|
205
|
-
if (tsconfigPaths) applyTypescriptOverrides(block, { tsconfigPaths });
|
|
206
|
-
}
|
|
207
|
-
if (vueScopes.has(scope)) {
|
|
208
|
-
const { globalComponents } = entry;
|
|
209
|
-
applyVueOverrides(block, { globalComponents });
|
|
210
|
-
}
|
|
211
|
-
applyCommonEntryFields(block, entry);
|
|
212
|
-
return block;
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region src/builders/spellChecker.ts
|
|
217
|
-
function buildSpellCheckerBlocks(input) {
|
|
218
|
-
if (!input) return [];
|
|
219
|
-
const blocks = [];
|
|
220
|
-
if (input.customWordListFile) blocks.push({ rules: { "@cspell/spellchecker": ["error", { customWordListFile: input.customWordListFile }] } });
|
|
221
|
-
if (input.ignoredPaths && input.ignoredPaths.length > 0) blocks.push({
|
|
222
|
-
files: input.ignoredPaths,
|
|
223
|
-
rules: { "@cspell/spellchecker": "off" }
|
|
224
|
-
});
|
|
225
|
-
return blocks;
|
|
226
|
-
}
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/builders/strict.ts
|
|
229
|
-
async function buildStrictBlocks(value) {
|
|
230
|
-
if (!value) return [];
|
|
231
|
-
const isFileScoped = Array.isArray(value);
|
|
232
|
-
if (isFileScoped && value.length === 0) return [];
|
|
233
|
-
const { default: strictConfig } = await Promise.resolve().then(() => require("./strict-tmp-wKop.cjs"));
|
|
234
|
-
const clone = { ...strictConfig };
|
|
235
|
-
if (clone.rules) clone.rules = { ...clone.rules };
|
|
236
|
-
if (isFileScoped) clone.files = value;
|
|
237
|
-
else delete clone.files;
|
|
238
|
-
return [clone];
|
|
239
|
-
}
|
|
240
|
-
//#endregion
|
|
241
70
|
//#region src/utils/ensureConfigStructure.ts
|
|
242
71
|
var CONFIG_FILE_REGEX = /eslint\.config\.[mc]?[jt]s(?:$|\?)/;
|
|
243
72
|
var OPT_OUT_ENV = "INSIDER_SKIP_CONFIG_VALIDATION";
|
|
@@ -421,6 +250,21 @@ function getConsumerConfigPath(frames = readStackFrames(), argv = process.argv)
|
|
|
421
250
|
if (fromArgv) return fromArgv;
|
|
422
251
|
return null;
|
|
423
252
|
}
|
|
253
|
+
var consumerConfigDir = null;
|
|
254
|
+
function captureConsumerConfigDir(configPath) {
|
|
255
|
+
consumerConfigDir = configPath === null ? null : (0, node_path.dirname)((0, node_path.resolve)(configPath));
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Directory holding the consumer's `eslint.config.*`, captured by {@link ensureConfigStructure}.
|
|
259
|
+
* This is the anchor `tsconfigPaths` entries are written against; it falls back to `process.cwd()`
|
|
260
|
+
* when the config file could not be located.
|
|
261
|
+
* @example
|
|
262
|
+
* // consumer config at /repo/eslint.config.mjs, `eslint` launched from /repo/app
|
|
263
|
+
* getConsumerConfigDir(); // '/repo'
|
|
264
|
+
*/
|
|
265
|
+
function getConsumerConfigDir() {
|
|
266
|
+
return consumerConfigDir ?? process.cwd();
|
|
267
|
+
}
|
|
424
268
|
function formatReport(configPath, violations) {
|
|
425
269
|
const header = ["@useinsider/eslint-config: protected configuration structure violated in:", ` ${configPath}`].join("\n");
|
|
426
270
|
const lines = violations.map((violation) => ` - [${violation.line}:${violation.column}] ${violation.reason}`);
|
|
@@ -472,26 +316,198 @@ function parseConsumerSource(configPath, source) {
|
|
|
472
316
|
return fail(`@useinsider/eslint-config: failed to parse consumer config at ${configPath}: ${message}`);
|
|
473
317
|
}
|
|
474
318
|
}
|
|
475
|
-
function runValidation(
|
|
476
|
-
const configPath = overridePath === void 0 ? getConsumerConfigPath() : overridePath;
|
|
319
|
+
function runValidation(configPath) {
|
|
477
320
|
if (!configPath) fail(["@useinsider/eslint-config: unable to locate consumer `eslint.config.*` file for structure validation.", "If this is an unexpected environment, set INSIDER_SKIP_CONFIG_VALIDATION=true (do not commit)."].join("\n"));
|
|
478
321
|
const violations = validateProgramStructure(parseConsumerSource(configPath, readConsumerSource(configPath)), configPath);
|
|
479
322
|
if (violations.length === 0) return;
|
|
480
323
|
fail(formatReport(configPath, violations));
|
|
481
324
|
}
|
|
482
325
|
function ensureConfigStructure(overridePath) {
|
|
326
|
+
const configPath = overridePath === void 0 ? getConsumerConfigPath() : overridePath;
|
|
327
|
+
captureConsumerConfigDir(configPath);
|
|
483
328
|
if (process.env[OPT_OUT_ENV] === "true") {
|
|
484
329
|
emitBypassWarning();
|
|
485
330
|
return;
|
|
486
331
|
}
|
|
487
332
|
try {
|
|
488
|
-
runValidation(
|
|
333
|
+
runValidation(configPath);
|
|
489
334
|
} catch (error) {
|
|
490
335
|
if (error instanceof ConfigStructureExit) return;
|
|
491
336
|
throw error;
|
|
492
337
|
}
|
|
493
338
|
}
|
|
494
339
|
//#endregion
|
|
340
|
+
//#region src/builders/typescript.ts
|
|
341
|
+
function applyTypescriptOverrides(block, input) {
|
|
342
|
+
const languageOptions = block.languageOptions ?? {};
|
|
343
|
+
const parserOptions = languageOptions.parserOptions ?? {};
|
|
344
|
+
parserOptions.project = input.tsconfigPaths;
|
|
345
|
+
parserOptions.tsconfigRootDir = getConsumerConfigDir();
|
|
346
|
+
languageOptions.parserOptions = parserOptions;
|
|
347
|
+
block.languageOptions = languageOptions;
|
|
348
|
+
return block;
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/builders/vue.ts
|
|
352
|
+
function escapeRegex(input) {
|
|
353
|
+
return input.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
354
|
+
}
|
|
355
|
+
function anchoredEscapeRegex(input) {
|
|
356
|
+
return `^${escapeRegex(input)}$`;
|
|
357
|
+
}
|
|
358
|
+
function applyVueOverrides(block, input) {
|
|
359
|
+
if (!input.globalComponents || input.globalComponents.length === 0) return block;
|
|
360
|
+
const rules = block.rules ?? {};
|
|
361
|
+
rules["vue/no-undef-components"] = ["error", { ignorePatterns: input.globalComponents.map(anchoredEscapeRegex) }];
|
|
362
|
+
block.rules = rules;
|
|
363
|
+
return block;
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/builders/scopeBlocks.ts
|
|
367
|
+
var scopeMap = {
|
|
368
|
+
async javascript() {
|
|
369
|
+
return Promise.resolve().then(() => require("./javascript-VBXqjVi8.cjs"));
|
|
370
|
+
},
|
|
371
|
+
async javascriptDom() {
|
|
372
|
+
return Promise.resolve().then(() => require("./javascript-dom-5jRL_yKP.cjs"));
|
|
373
|
+
},
|
|
374
|
+
async javascriptNode() {
|
|
375
|
+
return Promise.resolve().then(() => require("./javascript-node-C1AU_4X2.cjs"));
|
|
376
|
+
},
|
|
377
|
+
async typescript() {
|
|
378
|
+
return Promise.resolve().then(() => require("./typescript-C1icmOxY.cjs"));
|
|
379
|
+
},
|
|
380
|
+
async typescriptDom() {
|
|
381
|
+
return Promise.resolve().then(() => require("./typescript-dom-RUJn2WCZ.cjs"));
|
|
382
|
+
},
|
|
383
|
+
async typescriptNode() {
|
|
384
|
+
return Promise.resolve().then(() => require("./typescript-node-CBEzcc56.cjs"));
|
|
385
|
+
},
|
|
386
|
+
async vue2() {
|
|
387
|
+
return Promise.resolve().then(() => require("./vue2-azKwRgaJ.cjs"));
|
|
388
|
+
},
|
|
389
|
+
async vue3() {
|
|
390
|
+
return Promise.resolve().then(() => require("./vue3-Df5UQ1Ys.cjs"));
|
|
391
|
+
},
|
|
392
|
+
async vue2Typescript() {
|
|
393
|
+
return Promise.resolve().then(() => require("./vue2-typescript-CZSHzp7I.cjs"));
|
|
394
|
+
},
|
|
395
|
+
async vue3Typescript() {
|
|
396
|
+
return Promise.resolve().then(() => require("./vue3-typescript-C0O1JZlk.cjs"));
|
|
397
|
+
},
|
|
398
|
+
async vue2OptionsApi() {
|
|
399
|
+
return Promise.resolve().then(() => require("./vue2-options-api-ma3J-bvM.cjs"));
|
|
400
|
+
},
|
|
401
|
+
async vue3OptionsApi() {
|
|
402
|
+
return Promise.resolve().then(() => require("./vue3-options-api-Bx7yYHza.cjs"));
|
|
403
|
+
},
|
|
404
|
+
async vue2TypescriptOptionsApi() {
|
|
405
|
+
return Promise.resolve().then(() => require("./vue2-typescript-options-api-B8OzZlje.cjs"));
|
|
406
|
+
},
|
|
407
|
+
async vue3TypescriptOptionsApi() {
|
|
408
|
+
return Promise.resolve().then(() => require("./vue3-typescript-options-api-cPal4O-K.cjs"));
|
|
409
|
+
},
|
|
410
|
+
async jest() {
|
|
411
|
+
return Promise.resolve().then(() => require("./jest-CHzjzBtf.cjs"));
|
|
412
|
+
},
|
|
413
|
+
async vitest() {
|
|
414
|
+
return Promise.resolve().then(() => require("./vitest-BomI8gtu.cjs"));
|
|
415
|
+
},
|
|
416
|
+
async jsdocBasedTs() {
|
|
417
|
+
return Promise.resolve().then(() => require("./jsdoc-based-ts-Cfahz0nn.cjs"));
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
var tsScopes = /* @__PURE__ */ new Set([
|
|
421
|
+
"typescript",
|
|
422
|
+
"typescriptDom",
|
|
423
|
+
"typescriptNode",
|
|
424
|
+
"vue2Typescript",
|
|
425
|
+
"vue3Typescript",
|
|
426
|
+
"vue2TypescriptOptionsApi",
|
|
427
|
+
"vue3TypescriptOptionsApi",
|
|
428
|
+
"jsdocBasedTs"
|
|
429
|
+
]);
|
|
430
|
+
var vueScopes = /* @__PURE__ */ new Set([
|
|
431
|
+
"vue2",
|
|
432
|
+
"vue3",
|
|
433
|
+
"vue2Typescript",
|
|
434
|
+
"vue3Typescript",
|
|
435
|
+
"vue2OptionsApi",
|
|
436
|
+
"vue3OptionsApi",
|
|
437
|
+
"vue2TypescriptOptionsApi",
|
|
438
|
+
"vue3TypescriptOptionsApi"
|
|
439
|
+
]);
|
|
440
|
+
function cloneLanguageOptions(languageOptions) {
|
|
441
|
+
const clone = { ...languageOptions };
|
|
442
|
+
if (languageOptions.parserOptions) clone.parserOptions = { ...languageOptions.parserOptions };
|
|
443
|
+
if (languageOptions.globals) clone.globals = { ...languageOptions.globals };
|
|
444
|
+
return clone;
|
|
445
|
+
}
|
|
446
|
+
function clonePreset(preset) {
|
|
447
|
+
const { languageOptions, rules, settings, ...rest } = preset;
|
|
448
|
+
const clone = { ...rest };
|
|
449
|
+
if (languageOptions) clone.languageOptions = cloneLanguageOptions(languageOptions);
|
|
450
|
+
if (rules) clone.rules = { ...rules };
|
|
451
|
+
if (settings) clone.settings = { ...settings };
|
|
452
|
+
return clone;
|
|
453
|
+
}
|
|
454
|
+
function isScopeName(key) {
|
|
455
|
+
return Object.keys(scopeMap).includes(key);
|
|
456
|
+
}
|
|
457
|
+
function applyCommonEntryFields(block, entry) {
|
|
458
|
+
if (entry.ignores && entry.ignores.length > 0) block.ignores = [...entry.ignores];
|
|
459
|
+
if (entry.globals) {
|
|
460
|
+
const languageOptions = block.languageOptions ?? {};
|
|
461
|
+
languageOptions.globals = {
|
|
462
|
+
...languageOptions.globals ?? {},
|
|
463
|
+
...entry.globals
|
|
464
|
+
};
|
|
465
|
+
block.languageOptions = languageOptions;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function buildScopeBlocks(scope, entries) {
|
|
469
|
+
const preset = (await scopeMap[scope]()).default;
|
|
470
|
+
return entries.map((entry) => {
|
|
471
|
+
const block = clonePreset(preset);
|
|
472
|
+
block.files = entry.files;
|
|
473
|
+
if (tsScopes.has(scope)) {
|
|
474
|
+
const { tsconfigPaths } = entry;
|
|
475
|
+
if (tsconfigPaths) applyTypescriptOverrides(block, { tsconfigPaths });
|
|
476
|
+
}
|
|
477
|
+
if (vueScopes.has(scope)) {
|
|
478
|
+
const { globalComponents } = entry;
|
|
479
|
+
applyVueOverrides(block, { globalComponents });
|
|
480
|
+
}
|
|
481
|
+
applyCommonEntryFields(block, entry);
|
|
482
|
+
return block;
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/builders/spellChecker.ts
|
|
487
|
+
function buildSpellCheckerBlocks(input) {
|
|
488
|
+
if (!input) return [];
|
|
489
|
+
const blocks = [];
|
|
490
|
+
if (input.customWordListFile) blocks.push({ rules: { "@cspell/spellchecker": ["error", { customWordListFile: input.customWordListFile }] } });
|
|
491
|
+
if (input.ignoredPaths && input.ignoredPaths.length > 0) blocks.push({
|
|
492
|
+
files: input.ignoredPaths,
|
|
493
|
+
rules: { "@cspell/spellchecker": "off" }
|
|
494
|
+
});
|
|
495
|
+
return blocks;
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/builders/strict.ts
|
|
499
|
+
async function buildStrictBlocks(value) {
|
|
500
|
+
if (!value) return [];
|
|
501
|
+
const isFileScoped = Array.isArray(value);
|
|
502
|
+
if (isFileScoped && value.length === 0) return [];
|
|
503
|
+
const { default: strictConfig } = await Promise.resolve().then(() => require("./strict-DnJFBY_B.cjs"));
|
|
504
|
+
const clone = { ...strictConfig };
|
|
505
|
+
if (clone.rules) clone.rules = { ...clone.rules };
|
|
506
|
+
if (isFileScoped) clone.files = value;
|
|
507
|
+
else delete clone.files;
|
|
508
|
+
return [clone];
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
495
511
|
//#region src/utils/ensureDependencies.ts
|
|
496
512
|
var turnOff = false;
|
|
497
513
|
var scanned = false;
|
|
@@ -563,6 +579,10 @@ function silenceRules(rules) {
|
|
|
563
579
|
globallySilencedRules.add(rule);
|
|
564
580
|
});
|
|
565
581
|
}
|
|
582
|
+
function isDisabled(config) {
|
|
583
|
+
const [severity] = Array.isArray(config) ? config : [config];
|
|
584
|
+
return severity === "off" || severity === 0;
|
|
585
|
+
}
|
|
566
586
|
function silenceRule(config) {
|
|
567
587
|
const [, ...restConfig] = Array.isArray(config) ? config : [];
|
|
568
588
|
return ["warn", ...restConfig];
|
|
@@ -576,7 +596,7 @@ function filterSilencedRules(rules, silencedRules) {
|
|
|
576
596
|
(0, node_console.warn)(`Unknown rule "${rule}". Please remove it from the silenced rules list.`);
|
|
577
597
|
});
|
|
578
598
|
return Object.entries(rules).reduce((newRules, [key, value]) => {
|
|
579
|
-
if (value) newRules[key] = targetSilencedRules.has(key) ? silenceRule(value) : value;
|
|
599
|
+
if (value) newRules[key] = targetSilencedRules.has(key) && !isDisabled(value) ? silenceRule(value) : value;
|
|
580
600
|
return newRules;
|
|
581
601
|
}, {});
|
|
582
602
|
}
|