@brnshkr/config 0.0.1-alpha.9 → 0.0.1-beta.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.
- package/README.md +92 -36
- package/conf/tsconfig.json +4 -7
- package/dist/eslint/index.d.mts +1351 -1643
- package/dist/eslint/index.mjs +255 -176
- package/dist/scripts/eslint.mjs +2 -4
- package/dist/scripts/stylelint.mjs +2 -4
- package/dist/shared.mjs +79 -240
- package/dist/stylelint/index.d.mts +3 -3
- package/dist/stylelint/index.mjs +103 -67
- package/package.json +80 -96
package/dist/eslint/index.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as objectAssign, d as objectFromEntries, f as objectKeys, h as version, i as resolvePackagesSharedAsynchronously, l as objectEntries, m as packageOrganizationUpper, n as GLOB_IGNORES, o as ESLINT_PACKAGES, p as packageOrganization, r as isModuleEnabledByDefault, t as QUOTES, u as objectFreeze } from "../shared.mjs";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import jsEslint from "@eslint/js";
|
|
4
4
|
import confusingBrowserGlobals from "confusing-browser-globals";
|
|
5
5
|
import globals from "globals";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
|
-
|
|
9
|
-
//#region src/js/eslint/types/scopes.ts
|
|
8
|
+
//#region ../src/js/eslint/types/scopes.ts
|
|
10
9
|
const MAIN_SCOPES = {
|
|
11
10
|
[packageOrganizationUpper]: "builtin",
|
|
12
11
|
COMMENTS: "comments",
|
|
@@ -42,9 +41,8 @@ const SUB_SCOPES = {
|
|
|
42
41
|
SETUP: "setup",
|
|
43
42
|
UNNAMED: "unnamed"
|
|
44
43
|
};
|
|
45
|
-
|
|
46
44
|
//#endregion
|
|
47
|
-
//#region src/js/eslint/utils/config.ts
|
|
45
|
+
//#region ../src/js/eslint/utils/config.ts
|
|
48
46
|
const buildConfigName = (mainScope, subScope) => [
|
|
49
47
|
packageOrganization,
|
|
50
48
|
mainScope,
|
|
@@ -85,9 +83,8 @@ const ensureNamesForSyncAdditionalConfigs = (additionalConfigs) => {
|
|
|
85
83
|
return validConfigs;
|
|
86
84
|
};
|
|
87
85
|
const getUserConfigs = (resolvedOptions, additionalConfigs) => [getGlobalAdditionalConfig(resolvedOptions), ...ensureNamesForSyncAdditionalConfigs(additionalConfigs)];
|
|
88
|
-
|
|
89
86
|
//#endregion
|
|
90
|
-
//#region src/js/eslint/utils/globs.ts
|
|
87
|
+
//#region ../src/js/eslint/utils/globs.ts
|
|
91
88
|
const GLOB_CJS = "**/*.cjs";
|
|
92
89
|
const GLOB_TS = "**/*.?(c|m)ts?(x)";
|
|
93
90
|
const GLOB_DTS = "**/*.d.?(c|m)ts";
|
|
@@ -120,9 +117,8 @@ const GLOB_TEST_FILES = [
|
|
|
120
117
|
"**/*.bench.?(c|m)[jt]s",
|
|
121
118
|
"**/*.benchmark.?(c|m)[jt]s"
|
|
122
119
|
];
|
|
123
|
-
|
|
124
120
|
//#endregion
|
|
125
|
-
//#region src/js/eslint/configs/builtin.ts
|
|
121
|
+
//#region ../src/js/eslint/configs/builtin.ts
|
|
126
122
|
const FILE_TYPE_MAP = {
|
|
127
123
|
".json": "json",
|
|
128
124
|
".css": "css",
|
|
@@ -137,7 +133,7 @@ const FILE_TYPE_MAP = {
|
|
|
137
133
|
const MESSAGE_ID_MISSING_WITH_KEYWORD = "missingWithKeyword";
|
|
138
134
|
const MESSAGE_ID_MISSING_TYPE_PROPERTY = "missingTypeProperty";
|
|
139
135
|
const MESSAGE_ID_WRONG_TYPE_VALUE = "wrongTypeValue";
|
|
140
|
-
const
|
|
136
|
+
const RULE_DEFINITIONS = { "require-import-attributes": {
|
|
141
137
|
meta: {
|
|
142
138
|
type: "problem",
|
|
143
139
|
docs: { description: "Require non-JavaScript imports (e.g. .json and .css) to include import attributes." },
|
|
@@ -147,17 +143,17 @@ const requireImportAttributesRule = {
|
|
|
147
143
|
[MESSAGE_ID_WRONG_TYPE_VALUE]: "Import attribute 'type' for '{{ file }}' must be '{{ expectedValue }}'."
|
|
148
144
|
}
|
|
149
145
|
},
|
|
150
|
-
create: (context) => ({ ImportDeclaration: (node
|
|
151
|
-
const sourceValue = node
|
|
146
|
+
create: (context) => ({ ImportDeclaration: (node) => {
|
|
147
|
+
const sourceValue = node.source.value;
|
|
152
148
|
const extensionIndex = sourceValue.lastIndexOf(".");
|
|
153
149
|
if (extensionIndex === -1) return;
|
|
154
150
|
const extension = sourceValue.slice(extensionIndex).toLowerCase();
|
|
155
151
|
const expectedValue = FILE_TYPE_MAP[extension];
|
|
156
152
|
if (expectedValue === void 0) return;
|
|
157
|
-
const { attributes } = node
|
|
153
|
+
const { attributes } = node;
|
|
158
154
|
if (attributes.length === 0) {
|
|
159
155
|
context.report({
|
|
160
|
-
node
|
|
156
|
+
node,
|
|
161
157
|
messageId: MESSAGE_ID_MISSING_WITH_KEYWORD,
|
|
162
158
|
data: {
|
|
163
159
|
extension,
|
|
@@ -169,13 +165,13 @@ const requireImportAttributesRule = {
|
|
|
169
165
|
const typeProperty = attributes.find((attribute) => attribute.key.type === "Identifier" && "name" in attribute.key && attribute.key.name === "type" || attribute.key.type === "Literal" && "value" in attribute.key && attribute.key.value === "type");
|
|
170
166
|
if (!typeProperty) {
|
|
171
167
|
context.report({
|
|
172
|
-
node
|
|
168
|
+
node,
|
|
173
169
|
messageId: MESSAGE_ID_MISSING_TYPE_PROPERTY
|
|
174
170
|
});
|
|
175
171
|
return;
|
|
176
172
|
}
|
|
177
173
|
if (typeProperty.value.value !== expectedValue) context.report({
|
|
178
|
-
node
|
|
174
|
+
node,
|
|
179
175
|
messageId: MESSAGE_ID_WRONG_TYPE_VALUE,
|
|
180
176
|
data: {
|
|
181
177
|
expectedValue,
|
|
@@ -183,8 +179,7 @@ const requireImportAttributesRule = {
|
|
|
183
179
|
}
|
|
184
180
|
});
|
|
185
181
|
} })
|
|
186
|
-
};
|
|
187
|
-
const RULE_DEFINITIONS = { "require-import-attributes": requireImportAttributesRule };
|
|
182
|
+
} };
|
|
188
183
|
const RULES = objectFreeze(objectFromEntries(objectKeys(RULE_DEFINITIONS).map((ruleName) => [`${packageOrganization}/${ruleName}`, "error"])));
|
|
189
184
|
const builtin = () => [{
|
|
190
185
|
name: buildConfigName(MAIN_SCOPES[packageOrganizationUpper], SUB_SCOPES.SETUP),
|
|
@@ -201,9 +196,100 @@ const builtin = () => [{
|
|
|
201
196
|
rules: RULES
|
|
202
197
|
}];
|
|
203
198
|
const builtinConfig = { [packageOrganization]: builtin };
|
|
204
|
-
|
|
205
199
|
//#endregion
|
|
206
|
-
//#region src/js/eslint/
|
|
200
|
+
//#region ../src/js/eslint/utils/module.ts
|
|
201
|
+
const MODULES = {
|
|
202
|
+
[packageOrganization]: { name: packageOrganization },
|
|
203
|
+
comments: {
|
|
204
|
+
name: "comments",
|
|
205
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_ESLINT_COMMENTS] }
|
|
206
|
+
},
|
|
207
|
+
css: {
|
|
208
|
+
name: "css",
|
|
209
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_CSS] }
|
|
210
|
+
},
|
|
211
|
+
gitignore: {
|
|
212
|
+
name: "gitignore",
|
|
213
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_FLAT_CONFIG_GITIGNORE] }
|
|
214
|
+
},
|
|
215
|
+
import: {
|
|
216
|
+
name: "import",
|
|
217
|
+
packages: {
|
|
218
|
+
requiredAny: [ESLINT_PACKAGES.ESLINT_PLUGIN_IMPORT_X, ESLINT_PACKAGES.ESLINT_PLUGIN_ANTFU],
|
|
219
|
+
optional: [ESLINT_PACKAGES.ESLINT_IMPORT_RESOVLER_TYPESCRIPT]
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
javascript: {
|
|
223
|
+
name: "javascript",
|
|
224
|
+
packages: { optional: [ESLINT_PACKAGES.ESLINT_PLUGIN_ANTFU, ESLINT_PACKAGES.ESLINT_PLUGIN_UNUSED_IMPORTS] }
|
|
225
|
+
},
|
|
226
|
+
jsdoc: {
|
|
227
|
+
name: "jsdoc",
|
|
228
|
+
packages: {
|
|
229
|
+
requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_JSDOC],
|
|
230
|
+
optional: [ESLINT_PACKAGES.ESLINT_PLUGIN_JSDOC_PROCESSOR]
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
json: {
|
|
234
|
+
name: "json",
|
|
235
|
+
packages: {
|
|
236
|
+
requiredAll: [ESLINT_PACKAGES.ESLINT_JSON],
|
|
237
|
+
optional: [ESLINT_PACKAGES.ESLINT_PLUGIN_JSONC]
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
markdown: {
|
|
241
|
+
name: "markdown",
|
|
242
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_MARKDOWN, ESLINT_PACKAGES.ESLINT_MERGE_PROCESSORS] }
|
|
243
|
+
},
|
|
244
|
+
node: {
|
|
245
|
+
name: "node",
|
|
246
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_N] }
|
|
247
|
+
},
|
|
248
|
+
perfectionist: {
|
|
249
|
+
name: "perfectionist",
|
|
250
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_PERFECTIONIST] }
|
|
251
|
+
},
|
|
252
|
+
regexp: {
|
|
253
|
+
name: "regexp",
|
|
254
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_REGEXP] }
|
|
255
|
+
},
|
|
256
|
+
style: {
|
|
257
|
+
name: "style",
|
|
258
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_STYLISTIC] }
|
|
259
|
+
},
|
|
260
|
+
svelte: {
|
|
261
|
+
name: "svelte",
|
|
262
|
+
packages: { requiredAll: [ESLINT_PACKAGES.SVELTE, ESLINT_PACKAGES.ESLINT_PLUGIN_SVELTE] }
|
|
263
|
+
},
|
|
264
|
+
test: {
|
|
265
|
+
name: "test",
|
|
266
|
+
packages: { requiredAll: [ESLINT_PACKAGES.VITEST_ESLINT_PLUGIN] }
|
|
267
|
+
},
|
|
268
|
+
toml: {
|
|
269
|
+
name: "toml",
|
|
270
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_TOML] }
|
|
271
|
+
},
|
|
272
|
+
typescript: {
|
|
273
|
+
name: "typescript",
|
|
274
|
+
packages: { requiredAll: [ESLINT_PACKAGES.TYPESCRIPT, ESLINT_PACKAGES.TYPESCRIPT_ESLINT] }
|
|
275
|
+
},
|
|
276
|
+
unicorn: {
|
|
277
|
+
name: "unicorn",
|
|
278
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_UNICORN] }
|
|
279
|
+
},
|
|
280
|
+
yaml: {
|
|
281
|
+
name: "yaml",
|
|
282
|
+
packages: { requiredAll: [ESLINT_PACKAGES.ESLINT_PLUGIN_YML] }
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const resolvePackages = async (moduleInfo, type) => resolvePackagesSharedAsynchronously(moduleInfo, type);
|
|
286
|
+
const enabledStates = {};
|
|
287
|
+
const isModuleEnabled = (moduleInfo) => enabledStates[moduleInfo.name] ?? isModuleEnabledByDefault(moduleInfo);
|
|
288
|
+
const setModuleEnabled = (moduleInfo, state) => {
|
|
289
|
+
enabledStates[moduleInfo.name] = state;
|
|
290
|
+
};
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region ../src/js/eslint/configs/comments.ts
|
|
207
293
|
const comments = async () => {
|
|
208
294
|
const { requiredAll: [pluginComments] } = await resolvePackages(MODULES.comments);
|
|
209
295
|
if (!pluginComments) return [];
|
|
@@ -217,14 +303,12 @@ const comments = async () => {
|
|
|
217
303
|
files: GLOB_SCRIPT_FILES,
|
|
218
304
|
rules: {
|
|
219
305
|
...renameRules(recommendedRules, { "@eslint-community/eslint-comments": "comments" }),
|
|
220
|
-
"comments/no-unused-disable": "error",
|
|
221
306
|
"comments/require-description": "error"
|
|
222
307
|
}
|
|
223
308
|
}];
|
|
224
309
|
};
|
|
225
|
-
|
|
226
310
|
//#endregion
|
|
227
|
-
//#region src/js/eslint/configs/css.ts
|
|
311
|
+
//#region ../src/js/eslint/configs/css.ts
|
|
228
312
|
const css = async () => {
|
|
229
313
|
const { requiredAll: [pluginCss] } = await resolvePackages(MODULES.css);
|
|
230
314
|
if (!pluginCss) return [];
|
|
@@ -243,9 +327,8 @@ const css = async () => {
|
|
|
243
327
|
}
|
|
244
328
|
}];
|
|
245
329
|
};
|
|
246
|
-
|
|
247
330
|
//#endregion
|
|
248
|
-
//#region src/js/eslint/configs/gitignore.ts
|
|
331
|
+
//#region ../src/js/eslint/configs/gitignore.ts
|
|
249
332
|
const gitignore = async (options) => {
|
|
250
333
|
const { requiredAll: [pluginGitignore] } = await resolvePackages(MODULES.gitignore);
|
|
251
334
|
if (!pluginGitignore) return [];
|
|
@@ -254,16 +337,14 @@ const gitignore = async (options) => {
|
|
|
254
337
|
...options
|
|
255
338
|
})];
|
|
256
339
|
};
|
|
257
|
-
|
|
258
340
|
//#endregion
|
|
259
|
-
//#region src/js/eslint/configs/ignores.ts
|
|
341
|
+
//#region ../src/js/eslint/configs/ignores.ts
|
|
260
342
|
const ignores = (customIgnores = []) => [{
|
|
261
343
|
name: buildConfigName(MAIN_SCOPES.IGNORES, SUB_SCOPES.BASE),
|
|
262
344
|
ignores: [...GLOB_IGNORES, ...customIgnores]
|
|
263
345
|
}];
|
|
264
|
-
|
|
265
346
|
//#endregion
|
|
266
|
-
//#region src/js/eslint/configs/import.ts
|
|
347
|
+
//#region ../src/js/eslint/configs/import.ts
|
|
267
348
|
const imports = async () => {
|
|
268
349
|
const { requiredAny: [pluginImport, pluginAntfu], optional: [importResovlerTypescript] } = await resolvePackages(MODULES.import);
|
|
269
350
|
const plugins = {};
|
|
@@ -273,6 +354,14 @@ const imports = async () => {
|
|
|
273
354
|
if (pluginImport) {
|
|
274
355
|
plugins["import"] = pluginImport;
|
|
275
356
|
settings["import-x/resolver-next"] = [pluginImport.createNodeResolver(), importResovlerTypescript === void 0 ? void 0 : importResovlerTypescript.createTypeScriptImportResolver({ bun: true })].filter(Boolean);
|
|
357
|
+
settings["import-x/core-modules"] = [
|
|
358
|
+
"bun",
|
|
359
|
+
"bun:bundle",
|
|
360
|
+
"bun:ffi",
|
|
361
|
+
"bun:jsc",
|
|
362
|
+
"bun:sqlite",
|
|
363
|
+
"bun:test"
|
|
364
|
+
];
|
|
276
365
|
const pluginImportTsRules = isModuleEnabled(MODULES.typescript) ? renameRules(pluginImport.flatConfigs.typescript.rules, { "import-x": "import" }) : {};
|
|
277
366
|
pluginImportRules = {
|
|
278
367
|
...renameRules(pluginImport.flatConfigs.recommended.rules, { "import-x": "import" }),
|
|
@@ -372,9 +461,8 @@ const imports = async () => {
|
|
|
372
461
|
}
|
|
373
462
|
}];
|
|
374
463
|
};
|
|
375
|
-
|
|
376
464
|
//#endregion
|
|
377
|
-
//#region src/js/eslint/configs/javascript.ts
|
|
465
|
+
//#region ../src/js/eslint/configs/javascript.ts
|
|
378
466
|
const javascript = async () => {
|
|
379
467
|
const { optional: [pluginAntfu, pluginUnusedImports] } = await resolvePackages(MODULES.javascript);
|
|
380
468
|
const plugins = {};
|
|
@@ -387,7 +475,7 @@ const javascript = async () => {
|
|
|
387
475
|
if (pluginUnusedImports) {
|
|
388
476
|
plugins["unused"] = pluginUnusedImports;
|
|
389
477
|
pluginRules["unused/no-unused-imports"] = "error";
|
|
390
|
-
pluginRules["unused/no-unused-vars"] =
|
|
478
|
+
pluginRules["unused/no-unused-vars"] = "error";
|
|
391
479
|
}
|
|
392
480
|
return [{
|
|
393
481
|
name: buildConfigName(MAIN_SCOPES.JAVASCRIPT, SUB_SCOPES.SETUP),
|
|
@@ -565,14 +653,12 @@ const javascript = async () => {
|
|
|
565
653
|
"no-shadow": "error",
|
|
566
654
|
"no-template-curly-in-string": "error",
|
|
567
655
|
"no-throw-literal": "error",
|
|
568
|
-
"no-unassigned-vars": "error",
|
|
569
656
|
"no-underscore-dangle": "error",
|
|
570
657
|
"no-unmodified-loop-condition": "error",
|
|
571
658
|
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
572
659
|
"no-unreachable-loop": "error",
|
|
573
660
|
"no-unused-expressions": "error",
|
|
574
661
|
"no-use-before-define": "error",
|
|
575
|
-
"no-useless-assignment": "error",
|
|
576
662
|
"no-useless-call": "error",
|
|
577
663
|
"no-useless-computed-key": "error",
|
|
578
664
|
"no-useless-concat": "error",
|
|
@@ -604,7 +690,6 @@ const javascript = async () => {
|
|
|
604
690
|
"prefer-rest-params": "error",
|
|
605
691
|
"prefer-spread": "error",
|
|
606
692
|
"prefer-template": "error",
|
|
607
|
-
"preserve-caught-error": "error",
|
|
608
693
|
radix: "error",
|
|
609
694
|
"require-atomic-updates": "error",
|
|
610
695
|
"require-await": "error",
|
|
@@ -619,9 +704,8 @@ const javascript = async () => {
|
|
|
619
704
|
}
|
|
620
705
|
}];
|
|
621
706
|
};
|
|
622
|
-
|
|
623
707
|
//#endregion
|
|
624
|
-
//#region src/js/eslint/configs/typescript.ts
|
|
708
|
+
//#region ../src/js/eslint/configs/typescript.ts
|
|
625
709
|
const DEFAULT_TYPE_AWARE_IGNORES = [`${GLOB_MD}/**`];
|
|
626
710
|
const getTsEslintParserIfExists = async () => {
|
|
627
711
|
const isTypescriptModuleEnabled = isModuleEnabled(MODULES.typescript);
|
|
@@ -632,17 +716,17 @@ const getTsEslintParserIfExists = async () => {
|
|
|
632
716
|
}
|
|
633
717
|
return parser;
|
|
634
718
|
};
|
|
635
|
-
const resolveTypeAwareOptions = (resolvedOptions, files, ignores
|
|
719
|
+
const resolveTypeAwareOptions = (resolvedOptions, files, ignores) => {
|
|
636
720
|
const typeAwareOptions = typeof resolvedOptions.typeAware === "object" ? resolvedOptions.typeAware : {
|
|
637
721
|
ignores: DEFAULT_TYPE_AWARE_IGNORES,
|
|
638
722
|
tsconfig: typeof resolvedOptions.typeAware === "string" ? resolvedOptions.typeAware : void 0
|
|
639
723
|
};
|
|
640
724
|
typeAwareOptions.files = [...new Set([...typeAwareOptions.files ?? [], ...files])];
|
|
641
|
-
typeAwareOptions.ignores = [...new Set([...typeAwareOptions.ignores ?? [], ...ignores
|
|
725
|
+
typeAwareOptions.ignores = [...new Set([...typeAwareOptions.ignores ?? [], ...ignores])];
|
|
642
726
|
return typeAwareOptions;
|
|
643
727
|
};
|
|
644
|
-
const extractRelevantRules = (configs
|
|
645
|
-
for (const config of configs
|
|
728
|
+
const extractRelevantRules = (configs, key) => {
|
|
729
|
+
for (const config of configs) if (config.name === `typescript-eslint/${key}` && config.rules) return renameRules(config.rules, { "@typescript-eslint": "ts" });
|
|
646
730
|
throw new Error(`Expected key "${key}" to be contained in given config.`);
|
|
647
731
|
};
|
|
648
732
|
const getNamingConvention = (isTypeAware) => {
|
|
@@ -716,6 +800,7 @@ const getNamingConvention = (isTypeAware) => {
|
|
|
716
800
|
types: ["boolean"],
|
|
717
801
|
format: ["StrictPascalCase"],
|
|
718
802
|
prefix: [
|
|
803
|
+
"as",
|
|
719
804
|
"is",
|
|
720
805
|
"does",
|
|
721
806
|
"do",
|
|
@@ -730,6 +815,7 @@ const getNamingConvention = (isTypeAware) => {
|
|
|
730
815
|
const typescript = async (options) => {
|
|
731
816
|
const { requiredAll: [isTypescriptInstalled, tsEslint] } = await resolvePackages(MODULES.typescript);
|
|
732
817
|
if (!isTypescriptInstalled || !tsEslint) return [];
|
|
818
|
+
const { optional: [, pluginUnusedImports] } = await resolvePackages(MODULES.javascript);
|
|
733
819
|
const cwd = process.cwd();
|
|
734
820
|
let hasTsConfig = false;
|
|
735
821
|
try {
|
|
@@ -742,14 +828,14 @@ const typescript = async (options) => {
|
|
|
742
828
|
typeAware: hasTsConfig,
|
|
743
829
|
...options
|
|
744
830
|
};
|
|
745
|
-
const ignores
|
|
831
|
+
const ignores = resolvedOptions.ignores ?? [];
|
|
746
832
|
const files = [...new Set([...resolvedOptions.extraFileExtensions.map((extension) => `**/*.${extension}`), ...resolvedOptions.files ?? GLOB_SCRIPT_FILES])];
|
|
747
833
|
const hasEnabledTypeAwareness = resolvedOptions.typeAware !== false;
|
|
748
|
-
const typeAwareOptions = hasEnabledTypeAwareness ? resolveTypeAwareOptions(resolvedOptions, files, ignores
|
|
834
|
+
const typeAwareOptions = hasEnabledTypeAwareness ? resolveTypeAwareOptions(resolvedOptions, files, ignores) : {};
|
|
749
835
|
const createParserConfig = (isTypeAware) => ({
|
|
750
836
|
name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, `${SUB_SCOPES.PARSER}${isTypeAware ? "-type-aware" : ""}`),
|
|
751
837
|
files: isTypeAware ? typeAwareOptions.files : files,
|
|
752
|
-
ignores: isTypeAware ? typeAwareOptions.ignores : ignores
|
|
838
|
+
ignores: isTypeAware ? typeAwareOptions.ignores : ignores,
|
|
753
839
|
languageOptions: {
|
|
754
840
|
parser: tsEslint.parser,
|
|
755
841
|
parserOptions: {
|
|
@@ -765,7 +851,7 @@ const typescript = async (options) => {
|
|
|
765
851
|
const createRulesConfig = (isTypeAware) => ({
|
|
766
852
|
name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, `${SUB_SCOPES.RULES}${isTypeAware ? "-type-aware" : ""}`),
|
|
767
853
|
files: isTypeAware ? typeAwareOptions.files : files,
|
|
768
|
-
ignores: isTypeAware ? typeAwareOptions.ignores : ignores
|
|
854
|
+
ignores: isTypeAware ? typeAwareOptions.ignores : ignores,
|
|
769
855
|
rules: {
|
|
770
856
|
"ts/naming-convention": getNamingConvention(isTypeAware),
|
|
771
857
|
...isTypeAware ? {
|
|
@@ -789,6 +875,7 @@ const typescript = async (options) => {
|
|
|
789
875
|
...extractRelevantRules(tsEslint.configs.recommended, "recommended"),
|
|
790
876
|
...extractRelevantRules(tsEslint.configs.strict, "strict"),
|
|
791
877
|
...extractRelevantRules(tsEslint.configs.stylistic, "stylistic"),
|
|
878
|
+
...pluginUnusedImports ? { "ts/no-unused-vars": "off" } : void 0,
|
|
792
879
|
"ts/consistent-type-assertions": ["error", { assertionStyle: "angle-bracket" }],
|
|
793
880
|
"ts/consistent-type-imports": "error",
|
|
794
881
|
"ts/member-ordering": "error",
|
|
@@ -816,7 +903,7 @@ const typescript = async (options) => {
|
|
|
816
903
|
{
|
|
817
904
|
name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, `${SUB_SCOPES.RULES}-typescript`),
|
|
818
905
|
files: [GLOB_TS],
|
|
819
|
-
ignores: typeAwareOptions.ignores ?? ignores
|
|
906
|
+
ignores: typeAwareOptions.ignores ?? ignores,
|
|
820
907
|
rules: {
|
|
821
908
|
"ts/explicit-function-return-type": "error",
|
|
822
909
|
"ts/explicit-member-accessibility": "error"
|
|
@@ -824,9 +911,8 @@ const typescript = async (options) => {
|
|
|
824
911
|
}
|
|
825
912
|
].filter(Boolean);
|
|
826
913
|
};
|
|
827
|
-
|
|
828
914
|
//#endregion
|
|
829
|
-
//#region src/js/eslint/configs/jsdoc.ts
|
|
915
|
+
//#region ../src/js/eslint/configs/jsdoc.ts
|
|
830
916
|
const jsdoc = async () => {
|
|
831
917
|
const { requiredAll: [pluginJsdoc], optional: [getJsdocProcessorPlugin] } = await resolvePackages(MODULES.jsdoc);
|
|
832
918
|
if (!pluginJsdoc) return [];
|
|
@@ -844,13 +930,13 @@ const jsdoc = async () => {
|
|
|
844
930
|
"jsdoc/require-returns": "off"
|
|
845
931
|
} : {
|
|
846
932
|
...pluginJsdoc.configs["flat/recommended-error"].rules,
|
|
847
|
-
"jsdoc/check-indentation": "error",
|
|
933
|
+
"jsdoc/check-indentation": ["error", { allowIndentedSections: true }],
|
|
848
934
|
"jsdoc/check-line-alignment": "error",
|
|
849
935
|
"jsdoc/check-syntax": "error",
|
|
850
936
|
"jsdoc/check-template-names": "error",
|
|
851
937
|
"jsdoc/convert-to-jsdoc-comments": ["error", { lineOrBlockStyle: "block" }],
|
|
852
938
|
"jsdoc/imports-as-dependencies": "error",
|
|
853
|
-
"jsdoc/informative-docs": "error",
|
|
939
|
+
"jsdoc/informative-docs": ["error", { excludedTags: ["default"] }],
|
|
854
940
|
"jsdoc/match-description": "error",
|
|
855
941
|
"jsdoc/multiline-blocks": ["error", {
|
|
856
942
|
noSingleLineBlocks: true,
|
|
@@ -978,20 +1064,14 @@ const jsdoc = async () => {
|
|
|
978
1064
|
"any",
|
|
979
1065
|
{
|
|
980
1066
|
maxBlockLines: 1,
|
|
981
|
-
startLines: 1
|
|
1067
|
+
startLines: 1,
|
|
1068
|
+
startLinesWithNoTags: 0
|
|
982
1069
|
}
|
|
983
1070
|
],
|
|
984
1071
|
"jsdoc/text-escaping": ["error", { escapeHTML: true }],
|
|
985
1072
|
"jsdoc/ts-method-signature-style": "error",
|
|
986
1073
|
"jsdoc/ts-no-unnecessary-template-expression": "error",
|
|
987
|
-
"jsdoc/ts-prefer-function-type": "error"
|
|
988
|
-
"jsdoc/type-formatting": ["error", {
|
|
989
|
-
objectFieldSeparatorOptionalLinebreak: false,
|
|
990
|
-
objectTypeBracketSpacing: " ",
|
|
991
|
-
separatorForSingleObjectField: true,
|
|
992
|
-
stringQuotes: "single",
|
|
993
|
-
trailingPunctuationMultilineOnly: true
|
|
994
|
-
}]
|
|
1074
|
+
"jsdoc/ts-prefer-function-type": "error"
|
|
995
1075
|
} }
|
|
996
1076
|
});
|
|
997
1077
|
const parser = await getTsEslintParserIfExists();
|
|
@@ -1017,9 +1097,8 @@ const jsdoc = async () => {
|
|
|
1017
1097
|
}] : []
|
|
1018
1098
|
].filter(Boolean);
|
|
1019
1099
|
};
|
|
1020
|
-
|
|
1021
1100
|
//#endregion
|
|
1022
|
-
//#region src/js/eslint/configs/json.ts
|
|
1101
|
+
//#region ../src/js/eslint/configs/json.ts
|
|
1023
1102
|
const TSCONFIG_FILES = ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
1024
1103
|
const JSON_FILES_TO_TREAT_AS_JSONC = [...TSCONFIG_FILES, ".vscode/**/*.json"];
|
|
1025
1104
|
const LANGUAGE_TO_GLOB_MAP = {
|
|
@@ -1027,9 +1106,9 @@ const LANGUAGE_TO_GLOB_MAP = {
|
|
|
1027
1106
|
jsonc: [GLOB_JSONC, ...JSON_FILES_TO_TREAT_AS_JSONC],
|
|
1028
1107
|
json5: [GLOB_JSON5]
|
|
1029
1108
|
};
|
|
1030
|
-
const extractAllRules = (configs
|
|
1109
|
+
const extractAllRules = (configs) => {
|
|
1031
1110
|
const rules = {};
|
|
1032
|
-
for (const config of configs
|
|
1111
|
+
for (const config of configs) if (config.rules) objectAssign(rules, config.rules);
|
|
1033
1112
|
return rules;
|
|
1034
1113
|
};
|
|
1035
1114
|
const getJsoncSortConfigs = () => [
|
|
@@ -1069,6 +1148,7 @@ const getJsoncSortConfigs = () => [
|
|
|
1069
1148
|
"libc",
|
|
1070
1149
|
"engines",
|
|
1071
1150
|
"devEngines",
|
|
1151
|
+
"browserslist",
|
|
1072
1152
|
"scripts",
|
|
1073
1153
|
"esnext",
|
|
1074
1154
|
"module",
|
|
@@ -1455,7 +1535,7 @@ const getJsoncSortConfigs = () => [
|
|
|
1455
1535
|
}
|
|
1456
1536
|
];
|
|
1457
1537
|
const json = async () => {
|
|
1458
|
-
const { requiredAll: [pluginJson], optional: [pluginJsonc
|
|
1538
|
+
const { requiredAll: [pluginJson], optional: [pluginJsonc] } = await resolvePackages(MODULES.json);
|
|
1459
1539
|
if (!pluginJson) return [];
|
|
1460
1540
|
const createRulesConfig = (language) => ({
|
|
1461
1541
|
name: buildConfigName(MAIN_SCOPES.JSON, `${SUB_SCOPES.RULES}-${language}`),
|
|
@@ -1464,17 +1544,20 @@ const json = async () => {
|
|
|
1464
1544
|
...language === "json" ? { ignores: JSON_FILES_TO_TREAT_AS_JSONC } : void 0,
|
|
1465
1545
|
rules: {
|
|
1466
1546
|
...pluginJson.configs.recommended.rules,
|
|
1467
|
-
...pluginJsonc ? extractAllRules(pluginJsonc.configs[`
|
|
1547
|
+
...pluginJsonc ? extractAllRules(pluginJsonc.configs[`recommended-with-${language}`]) : void 0,
|
|
1468
1548
|
...pluginJsonc ? {
|
|
1469
1549
|
"jsonc/array-bracket-newline": ["error", "consistent"],
|
|
1470
1550
|
"jsonc/array-bracket-spacing": "error",
|
|
1471
1551
|
"jsonc/comma-style": "error",
|
|
1472
|
-
"jsonc/indent": ["error",
|
|
1552
|
+
"jsonc/indent": ["error", 2],
|
|
1473
1553
|
"jsonc/key-spacing": "error",
|
|
1474
|
-
"jsonc/no-irregular-whitespace": "error",
|
|
1475
1554
|
"jsonc/no-octal-escape": "error",
|
|
1476
1555
|
"jsonc/object-curly-newline": "error",
|
|
1477
|
-
"jsonc/object-curly-spacing": [
|
|
1556
|
+
"jsonc/object-curly-spacing": [
|
|
1557
|
+
"error",
|
|
1558
|
+
"always",
|
|
1559
|
+
{ emptyObjects: "never" }
|
|
1560
|
+
],
|
|
1478
1561
|
"jsonc/object-property-newline": "error",
|
|
1479
1562
|
"jsonc/quotes": ["error", "double"]
|
|
1480
1563
|
} : void 0
|
|
@@ -1491,26 +1574,16 @@ const json = async () => {
|
|
|
1491
1574
|
name: buildConfigName(MAIN_SCOPES.JSON, SUB_SCOPES.SETUP),
|
|
1492
1575
|
plugins
|
|
1493
1576
|
},
|
|
1494
|
-
parserJsonc ? {
|
|
1495
|
-
name: buildConfigName(MAIN_SCOPES.JSON, SUB_SCOPES.PARSER),
|
|
1496
|
-
files: [
|
|
1497
|
-
GLOB_JSON,
|
|
1498
|
-
GLOB_JSONC,
|
|
1499
|
-
GLOB_JSON5
|
|
1500
|
-
],
|
|
1501
|
-
languageOptions: { parser: parserJsonc }
|
|
1502
|
-
} : void 0,
|
|
1503
1577
|
createRulesConfig("json"),
|
|
1504
1578
|
createRulesConfig("jsonc"),
|
|
1505
|
-
|
|
1506
|
-
|
|
1579
|
+
createRulesConfig("json5"),
|
|
1580
|
+
...jsoncSortConfigs
|
|
1507
1581
|
].filter(Boolean);
|
|
1508
1582
|
};
|
|
1509
|
-
|
|
1510
1583
|
//#endregion
|
|
1511
|
-
//#region src/js/eslint/configs/markdown.ts
|
|
1512
|
-
const extractRelevantValues = (identifier, configs
|
|
1513
|
-
for (const config of configs
|
|
1584
|
+
//#region ../src/js/eslint/configs/markdown.ts
|
|
1585
|
+
const extractRelevantValues = (identifier, configs, key) => {
|
|
1586
|
+
for (const config of configs) if (config.name === `markdown/${key}` && config[identifier] !== void 0 && config[identifier] !== null) return config[identifier];
|
|
1514
1587
|
throw new Error(`Expected key "${key}" to be contained in given config.`);
|
|
1515
1588
|
};
|
|
1516
1589
|
const markdown = async (options) => {
|
|
@@ -1573,6 +1646,7 @@ const markdown = async (options) => {
|
|
|
1573
1646
|
"no-alert": "off",
|
|
1574
1647
|
"no-console": "off",
|
|
1575
1648
|
"no-inline-comments": "off",
|
|
1649
|
+
"no-magic-numbers": "off",
|
|
1576
1650
|
"import/no-default-export": "off",
|
|
1577
1651
|
"import/unambiguous": "off",
|
|
1578
1652
|
"node/no-missing-import": "off",
|
|
@@ -1584,9 +1658,8 @@ const markdown = async (options) => {
|
|
|
1584
1658
|
}
|
|
1585
1659
|
];
|
|
1586
1660
|
};
|
|
1587
|
-
|
|
1588
1661
|
//#endregion
|
|
1589
|
-
//#region src/js/eslint/configs/node.ts
|
|
1662
|
+
//#region ../src/js/eslint/configs/node.ts
|
|
1590
1663
|
const node = async (options) => {
|
|
1591
1664
|
const { requiredAll: [pluginNode] } = await resolvePackages(MODULES.node);
|
|
1592
1665
|
if (!pluginNode) return [];
|
|
@@ -1610,9 +1683,11 @@ const node = async (options) => {
|
|
|
1610
1683
|
"node/no-sync": "error",
|
|
1611
1684
|
"node/prefer-global/buffer": "error",
|
|
1612
1685
|
"node/prefer-global/console": "error",
|
|
1686
|
+
"node/prefer-global/crypto": "error",
|
|
1613
1687
|
"node/prefer-global/process": "error",
|
|
1614
1688
|
"node/prefer-global/text-decoder": "error",
|
|
1615
1689
|
"node/prefer-global/text-encoder": "error",
|
|
1690
|
+
"node/prefer-global/timers": "error",
|
|
1616
1691
|
"node/prefer-global/url-search-params": "error",
|
|
1617
1692
|
"node/prefer-global/url": "error",
|
|
1618
1693
|
"node/prefer-node-protocol": "error",
|
|
@@ -1621,9 +1696,8 @@ const node = async (options) => {
|
|
|
1621
1696
|
}
|
|
1622
1697
|
}];
|
|
1623
1698
|
};
|
|
1624
|
-
|
|
1625
1699
|
//#endregion
|
|
1626
|
-
//#region src/js/eslint/configs/unicorn.ts
|
|
1700
|
+
//#region ../src/js/eslint/configs/unicorn.ts
|
|
1627
1701
|
const FILE_NAMES_TO_IGNORE = [
|
|
1628
1702
|
"ACKNOWLEDGMENTS.md",
|
|
1629
1703
|
"ADOPTERS.md",
|
|
@@ -1633,6 +1707,7 @@ const FILE_NAMES_TO_IGNORE = [
|
|
|
1633
1707
|
"AUTHORS.md",
|
|
1634
1708
|
"BUILD.md",
|
|
1635
1709
|
"CHANGELOG.md",
|
|
1710
|
+
"CLAUDE.md",
|
|
1636
1711
|
"CODE_OF_CONDUCT.md",
|
|
1637
1712
|
"CODEOWNERS.md",
|
|
1638
1713
|
"CODING_STANDARDS.md",
|
|
@@ -1674,6 +1749,7 @@ const FILE_NAMES_TO_IGNORE = [
|
|
|
1674
1749
|
"RELEASING.md",
|
|
1675
1750
|
"RESEARCH.md",
|
|
1676
1751
|
"ROADMAP.md",
|
|
1752
|
+
"SKILL.md",
|
|
1677
1753
|
"SPEC.md",
|
|
1678
1754
|
"SECURITY_POLICY.md",
|
|
1679
1755
|
"SECURITY.md",
|
|
@@ -1714,13 +1790,13 @@ const unicorn = async () => {
|
|
|
1714
1790
|
"unicorn/string-content": ["error", { patterns: {
|
|
1715
1791
|
"\\.\\.\\.": "…",
|
|
1716
1792
|
"^http:\\/\\/": String.raw`^https:\/\/`
|
|
1717
|
-
} }]
|
|
1793
|
+
} }],
|
|
1794
|
+
"unicorn/text-encoding-identifier-case": ["error", { withDash: true }]
|
|
1718
1795
|
}
|
|
1719
1796
|
}];
|
|
1720
1797
|
};
|
|
1721
|
-
|
|
1722
1798
|
//#endregion
|
|
1723
|
-
//#region src/js/eslint/configs/overrides.ts
|
|
1799
|
+
//#region ../src/js/eslint/configs/overrides.ts
|
|
1724
1800
|
const jsOverrides = [{
|
|
1725
1801
|
name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.JAVASCRIPT}/scripts`),
|
|
1726
1802
|
files: ["scripts/**/*.?(c)js"],
|
|
@@ -1797,7 +1873,9 @@ const jsdocOverrides = isModuleEnabled(MODULES.jsdoc) ? [{
|
|
|
1797
1873
|
"style/eol-last": "off",
|
|
1798
1874
|
"style/no-multiple-empty-lines": "off",
|
|
1799
1875
|
"ts/no-unused-expressions": "off",
|
|
1800
|
-
"ts/no-unused-vars": "off"
|
|
1876
|
+
"ts/no-unused-vars": "off",
|
|
1877
|
+
"unused/no-unused-imports": "off",
|
|
1878
|
+
"unused/no-unused-vars": "off"
|
|
1801
1879
|
}
|
|
1802
1880
|
}, {
|
|
1803
1881
|
name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.JSDOC}/default-expressions`),
|
|
@@ -1870,9 +1948,8 @@ const overrides = () => [
|
|
|
1870
1948
|
}
|
|
1871
1949
|
}
|
|
1872
1950
|
];
|
|
1873
|
-
|
|
1874
1951
|
//#endregion
|
|
1875
|
-
//#region src/js/eslint/configs/perfectionist.ts
|
|
1952
|
+
//#region ../src/js/eslint/configs/perfectionist.ts
|
|
1876
1953
|
const perfectionist = async () => {
|
|
1877
1954
|
const { requiredAll: [pluginPerfectionist] } = await resolvePackages(MODULES.perfectionist);
|
|
1878
1955
|
if (!pluginPerfectionist) return [];
|
|
@@ -1892,9 +1969,8 @@ const perfectionist = async () => {
|
|
|
1892
1969
|
}
|
|
1893
1970
|
}];
|
|
1894
1971
|
};
|
|
1895
|
-
|
|
1896
1972
|
//#endregion
|
|
1897
|
-
//#region src/js/eslint/configs/regexp.ts
|
|
1973
|
+
//#region ../src/js/eslint/configs/regexp.ts
|
|
1898
1974
|
const regexp = async () => {
|
|
1899
1975
|
const { requiredAll: [pluginRegExp] } = await resolvePackages(MODULES.regexp);
|
|
1900
1976
|
if (!pluginRegExp) return [];
|
|
@@ -1944,17 +2020,16 @@ const regexp = async () => {
|
|
|
1944
2020
|
}
|
|
1945
2021
|
}];
|
|
1946
2022
|
};
|
|
1947
|
-
|
|
1948
2023
|
//#endregion
|
|
1949
|
-
//#region src/js/eslint/configs/style.ts
|
|
2024
|
+
//#region ../src/js/eslint/configs/style.ts
|
|
1950
2025
|
const style = async () => {
|
|
1951
2026
|
const { requiredAll: [pluginStyle] } = await resolvePackages(MODULES.style);
|
|
1952
2027
|
if (!pluginStyle) return [];
|
|
1953
2028
|
const styleConfig = pluginStyle.configs.customize({
|
|
1954
2029
|
jsx: true,
|
|
1955
2030
|
semi: true,
|
|
1956
|
-
indent:
|
|
1957
|
-
quotes:
|
|
2031
|
+
indent: 2,
|
|
2032
|
+
quotes: QUOTES,
|
|
1958
2033
|
quoteProps: "as-needed",
|
|
1959
2034
|
arrowParens: true,
|
|
1960
2035
|
blockSpacing: true,
|
|
@@ -1972,6 +2047,20 @@ const style = async () => {
|
|
|
1972
2047
|
...renameRules(styleConfig.rules, { "@stylistic": "style" }),
|
|
1973
2048
|
"style/array-bracket-newline": ["error", "consistent"],
|
|
1974
2049
|
"style/array-element-newline": ["error", "consistent"],
|
|
2050
|
+
"style/exp-jsx-props-style": ["error", {
|
|
2051
|
+
singleLine: { maxItems: 3 },
|
|
2052
|
+
multiLine: {
|
|
2053
|
+
minItems: 2,
|
|
2054
|
+
maxItemsPerLine: 1
|
|
2055
|
+
}
|
|
2056
|
+
}],
|
|
2057
|
+
"style/exp-list-style": ["error", {
|
|
2058
|
+
singleLine: {
|
|
2059
|
+
spacing: "never",
|
|
2060
|
+
maxItems: 3
|
|
2061
|
+
},
|
|
2062
|
+
multiLine: { minItems: 1 }
|
|
2063
|
+
}],
|
|
1975
2064
|
"style/function-call-argument-newline": ["error", "consistent"],
|
|
1976
2065
|
"style/function-call-spacing": "error",
|
|
1977
2066
|
"style/function-paren-newline": ["error", "multiline-arguments"],
|
|
@@ -1984,7 +2073,7 @@ const style = async () => {
|
|
|
1984
2073
|
"style/implicit-arrow-linebreak": "error",
|
|
1985
2074
|
"style/indent": [
|
|
1986
2075
|
"error",
|
|
1987
|
-
|
|
2076
|
+
2,
|
|
1988
2077
|
{
|
|
1989
2078
|
...indentRuleConfig,
|
|
1990
2079
|
offsetTernaryExpressions: false
|
|
@@ -1993,10 +2082,14 @@ const style = async () => {
|
|
|
1993
2082
|
"style/jsx-child-element-spacing": "error",
|
|
1994
2083
|
"style/jsx-pascal-case": "error",
|
|
1995
2084
|
"style/jsx-self-closing-comp": "error",
|
|
2085
|
+
"style/jsx-newline": ["error", {
|
|
2086
|
+
prevent: true,
|
|
2087
|
+
allowMultilines: true
|
|
2088
|
+
}],
|
|
1996
2089
|
"style/line-comment-position": "error",
|
|
1997
2090
|
"style/linebreak-style": "error",
|
|
1998
2091
|
"style/lines-around-comment": ["error", {
|
|
1999
|
-
beforeBlockComment:
|
|
2092
|
+
beforeBlockComment: false,
|
|
2000
2093
|
afterHashbangComment: true,
|
|
2001
2094
|
allowBlockStart: true,
|
|
2002
2095
|
allowObjectStart: true,
|
|
@@ -2008,8 +2101,8 @@ const style = async () => {
|
|
|
2008
2101
|
allowTypeStart: true
|
|
2009
2102
|
}],
|
|
2010
2103
|
"style/max-len": ["error", {
|
|
2011
|
-
code:
|
|
2012
|
-
tabWidth:
|
|
2104
|
+
code: 120,
|
|
2105
|
+
tabWidth: 2,
|
|
2013
2106
|
ignoreUrls: true,
|
|
2014
2107
|
ignoreStrings: true,
|
|
2015
2108
|
ignoreComments: true
|
|
@@ -2248,11 +2341,10 @@ const style = async () => {
|
|
|
2248
2341
|
}
|
|
2249
2342
|
}];
|
|
2250
2343
|
};
|
|
2251
|
-
|
|
2252
2344
|
//#endregion
|
|
2253
|
-
//#region src/js/eslint/configs/svelte.ts
|
|
2254
|
-
const extractRelevantConfig = (configs
|
|
2255
|
-
for (const config of configs
|
|
2345
|
+
//#region ../src/js/eslint/configs/svelte.ts
|
|
2346
|
+
const extractRelevantConfig = (configs, key) => {
|
|
2347
|
+
for (const config of configs) if (config.name === `svelte:${key}` && config.rules) return config;
|
|
2256
2348
|
throw new Error(`Expected key "${key}" to be contained in given config.`);
|
|
2257
2349
|
};
|
|
2258
2350
|
const svelte = async () => {
|
|
@@ -2267,7 +2359,7 @@ const svelte = async () => {
|
|
|
2267
2359
|
name: buildConfigName(MAIN_SCOPES.SVELTE, SUB_SCOPES.PARSER),
|
|
2268
2360
|
files: [GLOB_SVELTE, GLOB_SVELTE_SCRIPT],
|
|
2269
2361
|
languageOptions: {
|
|
2270
|
-
parser: extractRelevantConfig(pluginSvelte.configs
|
|
2362
|
+
parser: extractRelevantConfig(pluginSvelte.configs.base, "base:setup-for-svelte").languageOptions?.["parser"],
|
|
2271
2363
|
parserOptions: {
|
|
2272
2364
|
extraFileExtensions: [".svelte"],
|
|
2273
2365
|
parser: await getTsEslintParserIfExists()
|
|
@@ -2283,7 +2375,7 @@ const svelte = async () => {
|
|
|
2283
2375
|
name: buildConfigName(MAIN_SCOPES.SVELTE, SUB_SCOPES.RULES),
|
|
2284
2376
|
files: [GLOB_SVELTE, GLOB_SVELTE_SCRIPT],
|
|
2285
2377
|
rules: {
|
|
2286
|
-
...extractRelevantConfig(pluginSvelte.configs
|
|
2378
|
+
...extractRelevantConfig(pluginSvelte.configs.recommended, "recommended:rules").rules,
|
|
2287
2379
|
"svelte/block-lang": ["error", {
|
|
2288
2380
|
enforceScriptPresent: false,
|
|
2289
2381
|
enforceStylePresent: false,
|
|
@@ -2311,7 +2403,7 @@ const svelte = async () => {
|
|
|
2311
2403
|
void: "never"
|
|
2312
2404
|
}],
|
|
2313
2405
|
"style/indent": "off",
|
|
2314
|
-
"svelte/indent": ["error", { indent:
|
|
2406
|
+
"svelte/indent": ["error", { indent: 2 }],
|
|
2315
2407
|
"svelte/max-attributes-per-line": ["error", {
|
|
2316
2408
|
multiline: 1,
|
|
2317
2409
|
singleline: 3
|
|
@@ -2347,9 +2439,8 @@ const svelte = async () => {
|
|
|
2347
2439
|
}
|
|
2348
2440
|
];
|
|
2349
2441
|
};
|
|
2350
|
-
|
|
2351
2442
|
//#endregion
|
|
2352
|
-
//#region src/js/eslint/configs/test.ts
|
|
2443
|
+
//#region ../src/js/eslint/configs/test.ts
|
|
2353
2444
|
const test = async () => {
|
|
2354
2445
|
const { requiredAll: [pluginVitest] } = await resolvePackages(MODULES.test);
|
|
2355
2446
|
if (!pluginVitest) return [];
|
|
@@ -2408,75 +2499,65 @@ const test = async () => {
|
|
|
2408
2499
|
}
|
|
2409
2500
|
}];
|
|
2410
2501
|
};
|
|
2411
|
-
|
|
2412
2502
|
//#endregion
|
|
2413
|
-
//#region src/js/eslint/configs/toml.ts
|
|
2503
|
+
//#region ../src/js/eslint/configs/toml.ts
|
|
2414
2504
|
const toml = async () => {
|
|
2415
|
-
const { requiredAll: [pluginToml
|
|
2416
|
-
if (!pluginToml
|
|
2417
|
-
return [
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
"toml/indent": ["error", INDENT],
|
|
2435
|
-
"toml/no-mixed-type-in-array": "error"
|
|
2436
|
-
}
|
|
2505
|
+
const { requiredAll: [pluginToml] } = await resolvePackages(MODULES.toml);
|
|
2506
|
+
if (!pluginToml) return [];
|
|
2507
|
+
return [{
|
|
2508
|
+
name: buildConfigName(MAIN_SCOPES.TOML, SUB_SCOPES.SETUP),
|
|
2509
|
+
plugins: { toml: pluginToml }
|
|
2510
|
+
}, {
|
|
2511
|
+
name: buildConfigName(MAIN_SCOPES.TOML, SUB_SCOPES.RULES),
|
|
2512
|
+
files: [GLOB_TOML],
|
|
2513
|
+
language: "toml/toml",
|
|
2514
|
+
rules: {
|
|
2515
|
+
...pluginToml.configs.standard[2]?.rules,
|
|
2516
|
+
"toml/array-bracket-spacing": ["error", "never"],
|
|
2517
|
+
"toml/indent": ["error", 2],
|
|
2518
|
+
"toml/inline-table-curly-spacing": [
|
|
2519
|
+
"error",
|
|
2520
|
+
"always",
|
|
2521
|
+
{ emptyObjects: "never" }
|
|
2522
|
+
],
|
|
2523
|
+
"toml/no-mixed-type-in-array": "error"
|
|
2437
2524
|
}
|
|
2438
|
-
];
|
|
2525
|
+
}];
|
|
2439
2526
|
};
|
|
2440
|
-
|
|
2441
2527
|
//#endregion
|
|
2442
|
-
//#region src/js/eslint/configs/yaml.ts
|
|
2528
|
+
//#region ../src/js/eslint/configs/yaml.ts
|
|
2443
2529
|
const yaml = async () => {
|
|
2444
|
-
const { requiredAll: [pluginYaml
|
|
2445
|
-
if (!pluginYaml
|
|
2446
|
-
return [
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
prefer: "single"
|
|
2471
|
-
}],
|
|
2472
|
-
"yaml/require-string-key": "error"
|
|
2473
|
-
}
|
|
2530
|
+
const { requiredAll: [pluginYaml] } = await resolvePackages(MODULES.yaml);
|
|
2531
|
+
if (!pluginYaml) return [];
|
|
2532
|
+
return [{
|
|
2533
|
+
name: buildConfigName(MAIN_SCOPES.YAML, SUB_SCOPES.SETUP),
|
|
2534
|
+
plugins: { yaml: pluginYaml }
|
|
2535
|
+
}, {
|
|
2536
|
+
name: buildConfigName(MAIN_SCOPES.YAML, SUB_SCOPES.RULES),
|
|
2537
|
+
files: [GLOB_YAML],
|
|
2538
|
+
language: "yaml/yaml",
|
|
2539
|
+
rules: {
|
|
2540
|
+
...renameRules(pluginYaml.configs.standard[2]?.rules, { yml: "yaml" }),
|
|
2541
|
+
"yaml/block-mapping-colon-indicator-newline": ["error", "never"],
|
|
2542
|
+
"yaml/file-extension": "error",
|
|
2543
|
+
"yaml/flow-mapping-curly-spacing": [
|
|
2544
|
+
"error",
|
|
2545
|
+
"always",
|
|
2546
|
+
{ emptyObjects: "never" }
|
|
2547
|
+
],
|
|
2548
|
+
"yaml/indent": ["error", 2],
|
|
2549
|
+
"yaml/no-multiple-empty-lines": "error",
|
|
2550
|
+
"yaml/no-trailing-zeros": "error",
|
|
2551
|
+
"yaml/quotes": ["error", {
|
|
2552
|
+
avoidEscape: true,
|
|
2553
|
+
prefer: QUOTES
|
|
2554
|
+
}],
|
|
2555
|
+
"yaml/require-string-key": "error"
|
|
2474
2556
|
}
|
|
2475
|
-
];
|
|
2557
|
+
}];
|
|
2476
2558
|
};
|
|
2477
|
-
|
|
2478
2559
|
//#endregion
|
|
2479
|
-
//#region src/js/eslint/configs/index.ts
|
|
2560
|
+
//#region ../src/js/eslint/configs/index.ts
|
|
2480
2561
|
const configs = {
|
|
2481
2562
|
[packageOrganization]: builtinConfig[packageOrganization],
|
|
2482
2563
|
comments,
|
|
@@ -2500,9 +2581,8 @@ const configs = {
|
|
|
2500
2581
|
unicorn,
|
|
2501
2582
|
yaml
|
|
2502
2583
|
};
|
|
2503
|
-
|
|
2504
2584
|
//#endregion
|
|
2505
|
-
//#region src/js/eslint/index.ts
|
|
2585
|
+
//#region ../src/js/eslint/index.ts
|
|
2506
2586
|
const getConfig = (optionsAndGlobalConfig, ...additionalConfigs) => {
|
|
2507
2587
|
const resolvedOptions = {
|
|
2508
2588
|
[packageOrganization]: isModuleEnabledByDefault(MODULES[packageOrganization]),
|
|
@@ -2572,6 +2652,5 @@ const getConfig = (optionsAndGlobalConfig, ...additionalConfigs) => {
|
|
|
2572
2652
|
return composer;
|
|
2573
2653
|
};
|
|
2574
2654
|
var eslint_default = getConfig();
|
|
2575
|
-
|
|
2576
2655
|
//#endregion
|
|
2577
|
-
export { eslint_default as default, getConfig };
|
|
2656
|
+
export { eslint_default as default, getConfig };
|