@jsse/eslint-config 0.9.2 → 0.9.4
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/CHANGELOG.md +16 -0
- package/dist/cli.js +5 -5
- package/dist/fixable-rules-map-Ct5mIeIb.d.ts +487 -0
- package/dist/fixable.d.ts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +434 -379
- package/dist/{fixable-rules-map-CCZ-PRHv.d.ts → rule-types-BuPkMYJJ.d.ts} +1613 -1338
- package/dist/rule-types.d.ts +2 -0
- package/dist/rule-types.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-r
|
|
|
2
2
|
import { t as FIXABLE_RULES_MAP } from "./fixable-rules-map-dNndx2ig.js";
|
|
3
3
|
import { builtinModules, createRequire } from "node:module";
|
|
4
4
|
import process$1 from "node:process";
|
|
5
|
-
import Debug from "debug";
|
|
6
5
|
import pluginE18e from "@e18e/eslint-plugin";
|
|
7
6
|
import pluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
8
7
|
import pluginTs from "@typescript-eslint/eslint-plugin";
|
|
@@ -10,6 +9,7 @@ import * as parserTs from "@typescript-eslint/parser";
|
|
|
10
9
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
11
10
|
import pluginDeMorgan from "eslint-plugin-de-morgan";
|
|
12
11
|
import pluginImportLite from "eslint-plugin-import-lite";
|
|
12
|
+
import pluginJsdoc from "eslint-plugin-jsdoc";
|
|
13
13
|
import pluginN from "eslint-plugin-n";
|
|
14
14
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
15
15
|
import pluginPnpm from "eslint-plugin-pnpm";
|
|
@@ -18,6 +18,7 @@ import pluginUnicorn from "eslint-plugin-unicorn";
|
|
|
18
18
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
19
19
|
import createCommand from "eslint-plugin-command/config";
|
|
20
20
|
import eslintjs from "@eslint/js";
|
|
21
|
+
import Debug from "debug";
|
|
21
22
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
22
23
|
import tseslint from "typescript-eslint";
|
|
23
24
|
import fs, { realpathSync, statSync } from "node:fs";
|
|
@@ -28,7 +29,7 @@ import assert from "node:assert";
|
|
|
28
29
|
import v8 from "node:v8";
|
|
29
30
|
import { format, inspect } from "node:util";
|
|
30
31
|
//#region src/_generated/version.ts
|
|
31
|
-
const VERSION = "0.9.
|
|
32
|
+
const VERSION = "0.9.4";
|
|
32
33
|
//#endregion
|
|
33
34
|
//#region src/globs.ts
|
|
34
35
|
var globs_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -139,232 +140,6 @@ const GLOB_EXCLUDE = [
|
|
|
139
140
|
"**/yarn.lock"
|
|
140
141
|
];
|
|
141
142
|
//#endregion
|
|
142
|
-
//#region src/lager.ts
|
|
143
|
-
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
144
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
145
|
-
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
146
|
-
let formatter = (open, close, replace = open) => (input) => {
|
|
147
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
148
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
149
|
-
};
|
|
150
|
-
let replaceClose = (string, close, replace, index) => {
|
|
151
|
-
let result = "", cursor = 0;
|
|
152
|
-
do {
|
|
153
|
-
result += string.substring(cursor, index) + replace;
|
|
154
|
-
cursor = index + close.length;
|
|
155
|
-
index = string.indexOf(close, cursor);
|
|
156
|
-
} while (~index);
|
|
157
|
-
return result + string.substring(cursor);
|
|
158
|
-
};
|
|
159
|
-
let createColors = (enabled = isColorSupported) => {
|
|
160
|
-
let f = enabled ? formatter : () => String;
|
|
161
|
-
return {
|
|
162
|
-
isColorSupported: enabled,
|
|
163
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
164
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
165
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
166
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
167
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
168
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
169
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
170
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
171
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
172
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
173
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
174
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
175
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
176
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
177
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
178
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
179
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
180
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
181
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
182
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
183
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
184
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
185
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
186
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
187
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
188
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
189
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
190
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
191
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
192
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
193
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
194
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
195
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
196
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
197
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
198
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
199
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
200
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
201
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
202
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
203
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
module.exports = createColors();
|
|
207
|
-
module.exports.createColors = createColors;
|
|
208
|
-
})))(), 1);
|
|
209
|
-
const dbg = Debug("jsse:eslint-config");
|
|
210
|
-
const WARN_LABEL = import_picocolors.default.yellow("[[@jsse/eslint-config::WARN]]");
|
|
211
|
-
function enableDbg() {
|
|
212
|
-
const currentNamespaces = Debug.namespaces;
|
|
213
|
-
const current = typeof currentNamespaces === "string" ? currentNamespaces : void 0;
|
|
214
|
-
Debug.enable([current, "jsse:eslint-config"].filter((ns) => ns !== void 0).join(","));
|
|
215
|
-
dbg("Debugging enabled for @jsse/eslint-config");
|
|
216
|
-
}
|
|
217
|
-
const warn = (...args) => {
|
|
218
|
-
const msg = args.map((arg) => {
|
|
219
|
-
if (typeof arg === "string") return arg;
|
|
220
|
-
if (arg instanceof Error) return arg.message;
|
|
221
|
-
try {
|
|
222
|
-
return JSON.stringify(arg, void 0, 2);
|
|
223
|
-
} catch (_e) {
|
|
224
|
-
return String(arg);
|
|
225
|
-
}
|
|
226
|
-
}).join(" ");
|
|
227
|
-
console.warn(`${WARN_LABEL} ${msg}`);
|
|
228
|
-
};
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/utils.ts
|
|
231
|
-
function isPromiseLike(value) {
|
|
232
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
233
|
-
}
|
|
234
|
-
function flattenConfigs(configs) {
|
|
235
|
-
return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
|
|
236
|
-
}
|
|
237
|
-
async function resolveAndFlattenConfigs(configs) {
|
|
238
|
-
return flattenConfigs(await Promise.all(configs.map((config) => Promise.resolve(config))));
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Combine array and non-array configs into a single array.
|
|
242
|
-
* @param configs configs to combine and flatten
|
|
243
|
-
* @returns combined configs as a flattened array
|
|
244
|
-
*/
|
|
245
|
-
function combineAsync(...configs) {
|
|
246
|
-
if (configs.every((config) => !isPromiseLike(config))) return flattenConfigs(configs);
|
|
247
|
-
return resolveAndFlattenConfigs(configs);
|
|
248
|
-
}
|
|
249
|
-
function renameRules(rules, from, to) {
|
|
250
|
-
if (from === to) return rules;
|
|
251
|
-
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
252
|
-
if (key.startsWith(from)) return [to + key.slice(from.length), value];
|
|
253
|
-
return [key, value];
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
|
-
async function interopDefault(m) {
|
|
257
|
-
const resolved = await m;
|
|
258
|
-
return resolved.default || resolved;
|
|
259
|
-
}
|
|
260
|
-
function isCI() {
|
|
261
|
-
return !!process$1.env.CI;
|
|
262
|
-
}
|
|
263
|
-
function isInEditor() {
|
|
264
|
-
return !!((process$1.env.VSCODE_PID || process$1.env.JETBRAINS_IDE) && !isCI());
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Make an array of strings unique maintaining order.
|
|
268
|
-
* @param strings strings to make unique
|
|
269
|
-
* @returns unique strings
|
|
270
|
-
*/
|
|
271
|
-
function uniqueStrings(...strings) {
|
|
272
|
-
const set = /* @__PURE__ */ new Set();
|
|
273
|
-
for (const item of strings) if (typeof item === "string") set.add(item);
|
|
274
|
-
else for (const str of item) set.add(str);
|
|
275
|
-
return [...set];
|
|
276
|
-
}
|
|
277
|
-
function matchesRulePrefix(ruleName, rulePrefixes) {
|
|
278
|
-
return rulePrefixes.some((prefix) => ruleName.startsWith(`${prefix}/`));
|
|
279
|
-
}
|
|
280
|
-
function scopeTypeScriptRules(configs, options) {
|
|
281
|
-
dbg("scoping rules with prefixes %O to files: %O", options.rulePrefixes, options.files);
|
|
282
|
-
const { files, rulePrefixes } = options;
|
|
283
|
-
const normalizedPrefixes = uniqueStrings(rulePrefixes).filter(Boolean);
|
|
284
|
-
if (normalizedPrefixes.length === 0) return configs;
|
|
285
|
-
const cfgs = configs.flatMap((config) => {
|
|
286
|
-
if (config.files || config.rules === void 0) return [config];
|
|
287
|
-
const entries = Object.entries(config.rules);
|
|
288
|
-
const tsRuleEntries = entries.filter(([ruleName]) => matchesRulePrefix(ruleName, normalizedPrefixes));
|
|
289
|
-
if (tsRuleEntries.length === 0) return [config];
|
|
290
|
-
if (tsRuleEntries.length === entries.length) return [{
|
|
291
|
-
...config,
|
|
292
|
-
files
|
|
293
|
-
}];
|
|
294
|
-
const nonTsRuleEntries = entries.filter(([ruleName]) => !matchesRulePrefix(ruleName, normalizedPrefixes));
|
|
295
|
-
return [{
|
|
296
|
-
...config,
|
|
297
|
-
rules: Object.fromEntries(nonTsRuleEntries)
|
|
298
|
-
}, {
|
|
299
|
-
...config,
|
|
300
|
-
files,
|
|
301
|
-
name: config.name ? `${config.name}/typescript` : void 0,
|
|
302
|
-
rules: Object.fromEntries(tsRuleEntries)
|
|
303
|
-
}];
|
|
304
|
-
});
|
|
305
|
-
dbg("scoped rules with prefixes %O to files: %O", normalizedPrefixes, files);
|
|
306
|
-
return cfgs;
|
|
307
|
-
}
|
|
308
|
-
const parserPlain = {
|
|
309
|
-
meta: { name: "parser-plain" },
|
|
310
|
-
parseForESLint: (code) => ({
|
|
311
|
-
ast: {
|
|
312
|
-
body: [],
|
|
313
|
-
comments: [],
|
|
314
|
-
loc: {
|
|
315
|
-
end: code.length,
|
|
316
|
-
start: 0
|
|
317
|
-
},
|
|
318
|
-
range: [0, code.length],
|
|
319
|
-
tokens: [],
|
|
320
|
-
type: "Program"
|
|
321
|
-
},
|
|
322
|
-
scopeManager: void 0,
|
|
323
|
-
services: { isPlain: true },
|
|
324
|
-
visitorKeys: { Program: [] }
|
|
325
|
-
})
|
|
326
|
-
};
|
|
327
|
-
function turnOffRules(configs, off, debug) {
|
|
328
|
-
if (off.length > 0) {
|
|
329
|
-
dbg("turning off rules: %O", off);
|
|
330
|
-
const currentlyActiveRules = /* @__PURE__ */ new Set();
|
|
331
|
-
for (const config of configs) {
|
|
332
|
-
const cfgRules = Object.keys(config.rules ?? {});
|
|
333
|
-
for (const rule of cfgRules) currentlyActiveRules.add(rule);
|
|
334
|
-
}
|
|
335
|
-
for (const rule of off) {
|
|
336
|
-
if (currentlyActiveRules.has(rule)) continue;
|
|
337
|
-
const msg = `Rule \`${rule}\` is not active in the current config, you can remove it from the off list`;
|
|
338
|
-
dbg(msg);
|
|
339
|
-
if (debug) warn(msg);
|
|
340
|
-
}
|
|
341
|
-
for (const config of configs) {
|
|
342
|
-
const cfgRules = config.rules;
|
|
343
|
-
if (cfgRules) {
|
|
344
|
-
for (const rule of off) if (cfgRules[rule] !== void 0 && cfgRules[rule] !== "off" && cfgRules[rule] !== 0) cfgRules[rule] = "off";
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
dbg("finished turning off rules");
|
|
348
|
-
}
|
|
349
|
-
return configs;
|
|
350
|
-
}
|
|
351
|
-
const TYPESCRIPT_ESLINT_PREFIX = "@typescript-eslint/";
|
|
352
|
-
function replaceTypescriptEslintPrefixInplace(items, tsPrefix) {
|
|
353
|
-
for (const [key, value] of Object.entries(items)) {
|
|
354
|
-
if (!key.startsWith(TYPESCRIPT_ESLINT_PREFIX)) continue;
|
|
355
|
-
delete items[key];
|
|
356
|
-
items[`${tsPrefix}/${key.slice(19)}`] = value;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region src/plugins.ts
|
|
361
|
-
async function importPluginMarkdown() {
|
|
362
|
-
return { pluginMarkdown: await interopDefault(import("@eslint/markdown")) };
|
|
363
|
-
}
|
|
364
|
-
async function importPluginStylistic() {
|
|
365
|
-
return { pluginStylistic: await interopDefault(import("@stylistic/eslint-plugin")) };
|
|
366
|
-
}
|
|
367
|
-
//#endregion
|
|
368
143
|
//#region src/configs/antfu.ts
|
|
369
144
|
const antfu = (options) => {
|
|
370
145
|
return [{
|
|
@@ -4763,79 +4538,297 @@ function javascriptSelectedRules() {
|
|
|
4763
4538
|
yoda: ["error", "never"]
|
|
4764
4539
|
};
|
|
4765
4540
|
}
|
|
4766
|
-
const javascript = (options) => {
|
|
4767
|
-
const {
|
|
4768
|
-
return [{
|
|
4769
|
-
files: GLOB_CODE,
|
|
4770
|
-
languageOptions: {
|
|
4771
|
-
ecmaVersion: 2022,
|
|
4772
|
-
globals: {
|
|
4773
|
-
...import_globals.default.browser,
|
|
4774
|
-
...import_globals.default.es2021,
|
|
4775
|
-
...import_globals.default.node,
|
|
4776
|
-
document: "readonly",
|
|
4777
|
-
navigator: "readonly",
|
|
4778
|
-
window: "readonly"
|
|
4779
|
-
},
|
|
4780
|
-
parserOptions: {
|
|
4781
|
-
ecmaFeatures: { jsx: true },
|
|
4782
|
-
ecmaVersion: 2022,
|
|
4783
|
-
sourceType: "module"
|
|
4541
|
+
const javascript = (options) => {
|
|
4542
|
+
const { overrides = {}, reportUnusedDisableDirectives = true } = options ?? {};
|
|
4543
|
+
return [{
|
|
4544
|
+
files: GLOB_CODE,
|
|
4545
|
+
languageOptions: {
|
|
4546
|
+
ecmaVersion: 2022,
|
|
4547
|
+
globals: {
|
|
4548
|
+
...import_globals.default.browser,
|
|
4549
|
+
...import_globals.default.es2021,
|
|
4550
|
+
...import_globals.default.node,
|
|
4551
|
+
document: "readonly",
|
|
4552
|
+
navigator: "readonly",
|
|
4553
|
+
window: "readonly"
|
|
4554
|
+
},
|
|
4555
|
+
parserOptions: {
|
|
4556
|
+
ecmaFeatures: { jsx: true },
|
|
4557
|
+
ecmaVersion: 2022,
|
|
4558
|
+
sourceType: "module"
|
|
4559
|
+
},
|
|
4560
|
+
sourceType: "module"
|
|
4561
|
+
},
|
|
4562
|
+
linterOptions: { reportUnusedDisableDirectives },
|
|
4563
|
+
name: "jsse/javascript",
|
|
4564
|
+
rules: {
|
|
4565
|
+
...eslintjs.configs.recommended.rules,
|
|
4566
|
+
...javascriptSelectedRules(),
|
|
4567
|
+
...overrides
|
|
4568
|
+
}
|
|
4569
|
+
}, {
|
|
4570
|
+
files: [`scripts/${GLOB_JS}`, `cli.${GLOB_JS_SRC_EXT}`],
|
|
4571
|
+
name: "jsse/scripts-overrides",
|
|
4572
|
+
rules: { "no-console": "off" }
|
|
4573
|
+
}];
|
|
4574
|
+
};
|
|
4575
|
+
//#endregion
|
|
4576
|
+
//#region src/configs/jsdoc.ts
|
|
4577
|
+
const jsdoc = (options) => {
|
|
4578
|
+
return [{
|
|
4579
|
+
files: GLOB_CODE,
|
|
4580
|
+
name: "jsse/jsdoc",
|
|
4581
|
+
plugins: { jsdoc: pluginJsdoc },
|
|
4582
|
+
rules: {
|
|
4583
|
+
"jsdoc/check-access": "warn",
|
|
4584
|
+
"jsdoc/check-alignment": "warn",
|
|
4585
|
+
"jsdoc/check-param-names": "warn",
|
|
4586
|
+
"jsdoc/check-property-names": "warn",
|
|
4587
|
+
"jsdoc/check-types": "warn",
|
|
4588
|
+
"jsdoc/empty-tags": "warn",
|
|
4589
|
+
"jsdoc/implements-on-classes": "warn",
|
|
4590
|
+
"jsdoc/multiline-blocks": "warn",
|
|
4591
|
+
"jsdoc/no-defaults": "warn",
|
|
4592
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
4593
|
+
"jsdoc/require-param-name": "warn",
|
|
4594
|
+
"jsdoc/require-property": "warn",
|
|
4595
|
+
"jsdoc/require-property-description": "warn",
|
|
4596
|
+
"jsdoc/require-property-name": "warn",
|
|
4597
|
+
"jsdoc/require-returns-check": "warn",
|
|
4598
|
+
"jsdoc/require-returns-description": "warn",
|
|
4599
|
+
"jsdoc/require-yields-check": "warn",
|
|
4600
|
+
"jsdoc/tag-lines": [
|
|
4601
|
+
"warn",
|
|
4602
|
+
"any",
|
|
4603
|
+
{
|
|
4604
|
+
endLines: 0,
|
|
4605
|
+
startLines: null
|
|
4606
|
+
}
|
|
4607
|
+
],
|
|
4608
|
+
...options?.overrides
|
|
4609
|
+
}
|
|
4610
|
+
}];
|
|
4611
|
+
};
|
|
4612
|
+
//#endregion
|
|
4613
|
+
//#region src/lager.ts
|
|
4614
|
+
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4615
|
+
let p = process || {};
|
|
4616
|
+
let argv = p.argv || [];
|
|
4617
|
+
let env = p.env || {};
|
|
4618
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
4619
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
4620
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
4621
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
4622
|
+
};
|
|
4623
|
+
let replaceClose = (string, close, replace, index) => {
|
|
4624
|
+
let result = "", cursor = 0;
|
|
4625
|
+
do {
|
|
4626
|
+
result += string.substring(cursor, index) + replace;
|
|
4627
|
+
cursor = index + close.length;
|
|
4628
|
+
index = string.indexOf(close, cursor);
|
|
4629
|
+
} while (~index);
|
|
4630
|
+
return result + string.substring(cursor);
|
|
4631
|
+
};
|
|
4632
|
+
let createColors = (enabled = isColorSupported) => {
|
|
4633
|
+
let f = enabled ? formatter : () => String;
|
|
4634
|
+
return {
|
|
4635
|
+
isColorSupported: enabled,
|
|
4636
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
4637
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
4638
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
4639
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
4640
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
4641
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
4642
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
4643
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
4644
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
4645
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
4646
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
4647
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
4648
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
4649
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
4650
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
4651
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
4652
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
4653
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
4654
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
4655
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
4656
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
4657
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
4658
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
4659
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
4660
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
4661
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
4662
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
4663
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
4664
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
4665
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
4666
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
4667
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
4668
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
4669
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
4670
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
4671
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
4672
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
4673
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
4674
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
4675
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
4676
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
4677
|
+
};
|
|
4678
|
+
};
|
|
4679
|
+
module.exports = createColors();
|
|
4680
|
+
module.exports.createColors = createColors;
|
|
4681
|
+
})))(), 1);
|
|
4682
|
+
const dbg = Debug("jsse:eslint-config");
|
|
4683
|
+
const WARN_LABEL = import_picocolors.default.yellow("[[@jsse/eslint-config::WARN]]");
|
|
4684
|
+
function enableDbg() {
|
|
4685
|
+
const currentNamespaces = Debug.namespaces;
|
|
4686
|
+
const current = typeof currentNamespaces === "string" ? currentNamespaces : void 0;
|
|
4687
|
+
Debug.enable([current, "jsse:eslint-config"].filter((ns) => ns !== void 0).join(","));
|
|
4688
|
+
dbg("Debugging enabled for @jsse/eslint-config");
|
|
4689
|
+
}
|
|
4690
|
+
const warn = (...args) => {
|
|
4691
|
+
const msg = args.map((arg) => {
|
|
4692
|
+
if (typeof arg === "string") return arg;
|
|
4693
|
+
if (arg instanceof Error) return arg.message;
|
|
4694
|
+
try {
|
|
4695
|
+
return JSON.stringify(arg, void 0, 2);
|
|
4696
|
+
} catch (_e) {
|
|
4697
|
+
return String(arg);
|
|
4698
|
+
}
|
|
4699
|
+
}).join(" ");
|
|
4700
|
+
console.warn(`${WARN_LABEL} ${msg}`);
|
|
4701
|
+
};
|
|
4702
|
+
//#endregion
|
|
4703
|
+
//#region src/utils.ts
|
|
4704
|
+
function isPromiseLike(value) {
|
|
4705
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
4706
|
+
}
|
|
4707
|
+
function flattenConfigs(configs) {
|
|
4708
|
+
return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
|
|
4709
|
+
}
|
|
4710
|
+
async function resolveAndFlattenConfigs(configs) {
|
|
4711
|
+
return flattenConfigs(await Promise.all(configs.map((config) => Promise.resolve(config))));
|
|
4712
|
+
}
|
|
4713
|
+
/**
|
|
4714
|
+
* Combine array and non-array configs into a single array.
|
|
4715
|
+
* @param configs configs to combine and flatten
|
|
4716
|
+
* @returns combined configs as a flattened array
|
|
4717
|
+
*/
|
|
4718
|
+
function combineAsync(...configs) {
|
|
4719
|
+
if (configs.every((config) => !isPromiseLike(config))) return flattenConfigs(configs);
|
|
4720
|
+
return resolveAndFlattenConfigs(configs);
|
|
4721
|
+
}
|
|
4722
|
+
function renameRules(rules, from, to) {
|
|
4723
|
+
if (from === to) return rules;
|
|
4724
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
4725
|
+
if (key.startsWith(from)) return [to + key.slice(from.length), value];
|
|
4726
|
+
return [key, value];
|
|
4727
|
+
}));
|
|
4728
|
+
}
|
|
4729
|
+
async function interopDefault(m) {
|
|
4730
|
+
const resolved = await m;
|
|
4731
|
+
return resolved.default || resolved;
|
|
4732
|
+
}
|
|
4733
|
+
function isCI() {
|
|
4734
|
+
return !!process$1.env.CI;
|
|
4735
|
+
}
|
|
4736
|
+
function isInEditor() {
|
|
4737
|
+
return !!((process$1.env.VSCODE_PID || process$1.env.JETBRAINS_IDE) && !isCI());
|
|
4738
|
+
}
|
|
4739
|
+
/**
|
|
4740
|
+
* Make an array of strings unique maintaining order.
|
|
4741
|
+
* @param strings strings to make unique
|
|
4742
|
+
* @returns unique strings
|
|
4743
|
+
*/
|
|
4744
|
+
function uniqueStrings(...strings) {
|
|
4745
|
+
const set = /* @__PURE__ */ new Set();
|
|
4746
|
+
for (const item of strings) if (typeof item === "string") set.add(item);
|
|
4747
|
+
else for (const str of item) set.add(str);
|
|
4748
|
+
return [...set];
|
|
4749
|
+
}
|
|
4750
|
+
function matchesRulePrefix(ruleName, rulePrefixes) {
|
|
4751
|
+
return rulePrefixes.some((prefix) => ruleName.startsWith(`${prefix}/`));
|
|
4752
|
+
}
|
|
4753
|
+
function scopeTypeScriptRules(configs, options) {
|
|
4754
|
+
dbg("scoping rules with prefixes %O to files: %O", options.rulePrefixes, options.files);
|
|
4755
|
+
const { files, rulePrefixes } = options;
|
|
4756
|
+
const normalizedPrefixes = uniqueStrings(rulePrefixes).filter(Boolean);
|
|
4757
|
+
if (normalizedPrefixes.length === 0) return configs;
|
|
4758
|
+
const cfgs = configs.flatMap((config) => {
|
|
4759
|
+
if (config.files || config.rules === void 0) return [config];
|
|
4760
|
+
const entries = Object.entries(config.rules);
|
|
4761
|
+
const tsRuleEntries = entries.filter(([ruleName]) => matchesRulePrefix(ruleName, normalizedPrefixes));
|
|
4762
|
+
if (tsRuleEntries.length === 0) return [config];
|
|
4763
|
+
if (tsRuleEntries.length === entries.length) return [{
|
|
4764
|
+
...config,
|
|
4765
|
+
files
|
|
4766
|
+
}];
|
|
4767
|
+
const nonTsRuleEntries = entries.filter(([ruleName]) => !matchesRulePrefix(ruleName, normalizedPrefixes));
|
|
4768
|
+
return [{
|
|
4769
|
+
...config,
|
|
4770
|
+
rules: Object.fromEntries(nonTsRuleEntries)
|
|
4771
|
+
}, {
|
|
4772
|
+
...config,
|
|
4773
|
+
files,
|
|
4774
|
+
name: config.name ? `${config.name}/typescript` : void 0,
|
|
4775
|
+
rules: Object.fromEntries(tsRuleEntries)
|
|
4776
|
+
}];
|
|
4777
|
+
});
|
|
4778
|
+
dbg("scoped rules with prefixes %O to files: %O", normalizedPrefixes, files);
|
|
4779
|
+
return cfgs;
|
|
4780
|
+
}
|
|
4781
|
+
const parserPlain = {
|
|
4782
|
+
meta: { name: "parser-plain" },
|
|
4783
|
+
parseForESLint: (code) => ({
|
|
4784
|
+
ast: {
|
|
4785
|
+
body: [],
|
|
4786
|
+
comments: [],
|
|
4787
|
+
loc: {
|
|
4788
|
+
end: code.length,
|
|
4789
|
+
start: 0
|
|
4784
4790
|
},
|
|
4785
|
-
|
|
4791
|
+
range: [0, code.length],
|
|
4792
|
+
tokens: [],
|
|
4793
|
+
type: "Program"
|
|
4786
4794
|
},
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
...eslintjs.configs.recommended.rules,
|
|
4792
|
-
...javascriptSelectedRules(),
|
|
4793
|
-
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
4794
|
-
"unused-imports/no-unused-vars": ["error", {
|
|
4795
|
-
args: "after-used",
|
|
4796
|
-
argsIgnorePattern: "^_",
|
|
4797
|
-
ignoreRestSiblings: true,
|
|
4798
|
-
vars: "all",
|
|
4799
|
-
varsIgnorePattern: "^_"
|
|
4800
|
-
}],
|
|
4801
|
-
...overrides
|
|
4802
|
-
}
|
|
4803
|
-
}, {
|
|
4804
|
-
files: [`scripts/${GLOB_JS}`, `cli.${GLOB_JS_SRC_EXT}`],
|
|
4805
|
-
name: "jsse/scripts-overrides",
|
|
4806
|
-
rules: { "no-console": "off" }
|
|
4807
|
-
}];
|
|
4795
|
+
scopeManager: void 0,
|
|
4796
|
+
services: { isPlain: true },
|
|
4797
|
+
visitorKeys: { Program: [] }
|
|
4798
|
+
})
|
|
4808
4799
|
};
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
rules: {
|
|
4817
|
-
"jsdoc/check-access": "warn",
|
|
4818
|
-
"jsdoc/check-alignment": "warn",
|
|
4819
|
-
"jsdoc/check-param-names": "warn",
|
|
4820
|
-
"jsdoc/check-property-names": "warn",
|
|
4821
|
-
"jsdoc/check-types": "warn",
|
|
4822
|
-
"jsdoc/empty-tags": "warn",
|
|
4823
|
-
"jsdoc/implements-on-classes": "warn",
|
|
4824
|
-
"jsdoc/multiline-blocks": "warn",
|
|
4825
|
-
"jsdoc/no-defaults": "warn",
|
|
4826
|
-
"jsdoc/no-multi-asterisks": "warn",
|
|
4827
|
-
"jsdoc/require-param-name": "warn",
|
|
4828
|
-
"jsdoc/require-property": "warn",
|
|
4829
|
-
"jsdoc/require-property-description": "warn",
|
|
4830
|
-
"jsdoc/require-property-name": "warn",
|
|
4831
|
-
"jsdoc/require-returns-check": "warn",
|
|
4832
|
-
"jsdoc/require-returns-description": "warn",
|
|
4833
|
-
"jsdoc/require-yields-check": "warn",
|
|
4834
|
-
"jsdoc/tag-lines": "warn",
|
|
4835
|
-
...options?.overrides
|
|
4800
|
+
function turnOffRules(configs, off, debug) {
|
|
4801
|
+
if (off.length > 0) {
|
|
4802
|
+
dbg("turning off rules: %O", off);
|
|
4803
|
+
const currentlyActiveRules = /* @__PURE__ */ new Set();
|
|
4804
|
+
for (const config of configs) {
|
|
4805
|
+
const cfgRules = Object.keys(config.rules ?? {});
|
|
4806
|
+
for (const rule of cfgRules) currentlyActiveRules.add(rule);
|
|
4836
4807
|
}
|
|
4837
|
-
|
|
4838
|
-
|
|
4808
|
+
for (const rule of off) {
|
|
4809
|
+
if (currentlyActiveRules.has(rule)) continue;
|
|
4810
|
+
const msg = `Rule \`${rule}\` is not active in the current config, you can remove it from the off list`;
|
|
4811
|
+
dbg(msg);
|
|
4812
|
+
if (debug) warn(msg);
|
|
4813
|
+
}
|
|
4814
|
+
for (const config of configs) {
|
|
4815
|
+
const cfgRules = config.rules;
|
|
4816
|
+
if (cfgRules) {
|
|
4817
|
+
for (const rule of off) if (cfgRules[rule] !== void 0 && cfgRules[rule] !== "off" && cfgRules[rule] !== 0) cfgRules[rule] = "off";
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
dbg("finished turning off rules");
|
|
4821
|
+
}
|
|
4822
|
+
return configs;
|
|
4823
|
+
}
|
|
4824
|
+
const TYPESCRIPT_ESLINT_PREFIX = "@typescript-eslint/";
|
|
4825
|
+
function replaceTypescriptEslintPrefixInplace(items, tsPrefix) {
|
|
4826
|
+
for (const [key, value] of Object.entries(items)) {
|
|
4827
|
+
if (!key.startsWith(TYPESCRIPT_ESLINT_PREFIX)) continue;
|
|
4828
|
+
delete items[key];
|
|
4829
|
+
items[`${tsPrefix}/${key.slice(19)}`] = value;
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4839
4832
|
//#endregion
|
|
4840
4833
|
//#region src/configs/jsonc.ts
|
|
4841
4834
|
async function importParserJsonc() {
|
|
@@ -5010,86 +5003,57 @@ function tsPresetRules(props) {
|
|
|
5010
5003
|
function typescriptRulesTypeAware() {
|
|
5011
5004
|
return {
|
|
5012
5005
|
"@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
5013
|
-
"dot-notation": "off",
|
|
5014
5006
|
"@typescript-eslint/dot-notation": ["error", {
|
|
5015
|
-
|
|
5016
|
-
|
|
5007
|
+
allowKeywords: true,
|
|
5008
|
+
allowPattern: "^_"
|
|
5009
|
+
}],
|
|
5010
|
+
"@typescript-eslint/no-floating-promises": ["error", {
|
|
5011
|
+
ignoreIIFE: true,
|
|
5012
|
+
ignoreVoid: true
|
|
5017
5013
|
}],
|
|
5018
5014
|
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
5019
5015
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
5020
5016
|
"@typescript-eslint/require-array-sort-compare": ["error", { ignoreStringArrays: true }],
|
|
5021
|
-
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
5022
|
-
"@typescript-eslint/no-floating-promises": ["error", {
|
|
5023
|
-
ignoreVoid: true,
|
|
5024
|
-
ignoreIIFE: true
|
|
5025
|
-
}],
|
|
5026
5017
|
"@typescript-eslint/restrict-template-expressions": ["error", {
|
|
5027
5018
|
allow: [{
|
|
5019
|
+
from: "lib",
|
|
5028
5020
|
name: [
|
|
5029
5021
|
"Error",
|
|
5030
5022
|
"URL",
|
|
5031
5023
|
"URLSearchParams"
|
|
5032
|
-
]
|
|
5033
|
-
from: "lib"
|
|
5024
|
+
]
|
|
5034
5025
|
}],
|
|
5035
5026
|
allowAny: false,
|
|
5036
5027
|
allowBoolean: true,
|
|
5037
5028
|
allowNullish: true,
|
|
5038
5029
|
allowNumber: true,
|
|
5039
5030
|
allowRegExp: true
|
|
5040
|
-
}]
|
|
5031
|
+
}],
|
|
5032
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
5033
|
+
"dot-notation": "off"
|
|
5041
5034
|
};
|
|
5042
5035
|
}
|
|
5043
5036
|
function typescriptRulesTypeOblivious() {
|
|
5044
5037
|
return {
|
|
5045
|
-
eqeqeq: "error",
|
|
5046
|
-
camelcase: "off",
|
|
5047
|
-
yoda: "error",
|
|
5048
5038
|
"arrow-parens": "off",
|
|
5049
|
-
|
|
5050
|
-
"
|
|
5051
|
-
"
|
|
5052
|
-
"
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
"
|
|
5057
|
-
"
|
|
5058
|
-
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
5059
|
-
"@typescript-eslint/member-ordering": ["warn", {
|
|
5060
|
-
default: "never",
|
|
5061
|
-
classes: [
|
|
5062
|
-
"field",
|
|
5063
|
-
"constructor",
|
|
5064
|
-
"method"
|
|
5065
|
-
]
|
|
5066
|
-
}],
|
|
5067
|
-
"@typescript-eslint/no-namespace": ["error", {
|
|
5068
|
-
allowDeclarations: false,
|
|
5069
|
-
allowDefinitionFiles: false
|
|
5070
|
-
}],
|
|
5071
|
-
"@typescript-eslint/no-unused-vars": ["warn", {
|
|
5072
|
-
vars: "all",
|
|
5073
|
-
args: "none",
|
|
5074
|
-
argsIgnorePattern: "^_",
|
|
5075
|
-
varsIgnorePattern: "^_",
|
|
5076
|
-
caughtErrorsIgnorePattern: "^_"
|
|
5077
|
-
}],
|
|
5039
|
+
camelcase: "off",
|
|
5040
|
+
"comma-spacing": "off",
|
|
5041
|
+
"default-param-last": "off",
|
|
5042
|
+
"no-bitwise": "off",
|
|
5043
|
+
"no-duplicate-imports": "off",
|
|
5044
|
+
"no-empty-function": "off",
|
|
5045
|
+
"no-loop-func": "off",
|
|
5046
|
+
"no-loss-of-precision": "off",
|
|
5047
|
+
"no-restricted-imports": "off",
|
|
5078
5048
|
"no-use-before-define": "off",
|
|
5079
|
-
"
|
|
5080
|
-
functions: true,
|
|
5081
|
-
classes: true,
|
|
5082
|
-
variables: true,
|
|
5083
|
-
enums: true,
|
|
5084
|
-
typedefs: true
|
|
5085
|
-
}],
|
|
5086
|
-
"@typescript-eslint/prefer-namespace-keyword": "warn",
|
|
5049
|
+
"object-curly-spacing": "off",
|
|
5087
5050
|
"accessor-pairs": "error",
|
|
5051
|
+
eqeqeq: "error",
|
|
5088
5052
|
"for-direction": "warn",
|
|
5089
5053
|
"guard-for-in": "error",
|
|
5090
5054
|
"max-lines": ["warn", { max: 2e3 }],
|
|
5091
|
-
"no-bitwise": "off",
|
|
5092
5055
|
"no-caller": "error",
|
|
5056
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
5093
5057
|
"no-constant-condition": "warn",
|
|
5094
5058
|
"no-debugger": "warn",
|
|
5095
5059
|
"no-empty": "warn",
|
|
@@ -5106,6 +5070,14 @@ function typescriptRulesTypeOblivious() {
|
|
|
5106
5070
|
"no-new-func": "error",
|
|
5107
5071
|
"no-new-wrappers": "warn",
|
|
5108
5072
|
"no-octal-escape": "error",
|
|
5073
|
+
"no-restricted-syntax": [
|
|
5074
|
+
"error",
|
|
5075
|
+
"DebuggerStatement",
|
|
5076
|
+
"LabeledStatement",
|
|
5077
|
+
"WithStatement",
|
|
5078
|
+
"TSEnumDeclaration[const=true]",
|
|
5079
|
+
"TSExportAssignment"
|
|
5080
|
+
],
|
|
5109
5081
|
"no-return-assign": "error",
|
|
5110
5082
|
"no-script-url": "warn",
|
|
5111
5083
|
"no-self-compare": "error",
|
|
@@ -5118,17 +5090,36 @@ function typescriptRulesTypeOblivious() {
|
|
|
5118
5090
|
"require-atomic-updates": "error",
|
|
5119
5091
|
"require-yield": "warn",
|
|
5120
5092
|
strict: ["error", "never"],
|
|
5121
|
-
|
|
5122
|
-
"
|
|
5093
|
+
yoda: "error",
|
|
5094
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
5095
|
+
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
5096
|
+
assertionStyle: "as",
|
|
5097
|
+
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
5098
|
+
}],
|
|
5099
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
5100
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
5101
|
+
fixStyle: "separate-type-imports",
|
|
5102
|
+
prefer: "type-imports"
|
|
5103
|
+
}],
|
|
5123
5104
|
"@typescript-eslint/default-param-last": "error",
|
|
5105
|
+
"@typescript-eslint/member-ordering": ["warn", {
|
|
5106
|
+
classes: [
|
|
5107
|
+
"field",
|
|
5108
|
+
"constructor",
|
|
5109
|
+
"method"
|
|
5110
|
+
],
|
|
5111
|
+
default: "never"
|
|
5112
|
+
}],
|
|
5113
|
+
"@typescript-eslint/method-signature-style": ["warn", "property"],
|
|
5124
5114
|
"@typescript-eslint/no-dupe-class-members": "error",
|
|
5125
|
-
"no-empty-function": "off",
|
|
5126
5115
|
"@typescript-eslint/no-empty-function": "error",
|
|
5127
|
-
"no-
|
|
5116
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
5128
5117
|
"@typescript-eslint/no-loop-func": "error",
|
|
5129
|
-
"no-
|
|
5118
|
+
"@typescript-eslint/no-namespace": ["error", {
|
|
5119
|
+
allowDeclarations: false,
|
|
5120
|
+
allowDefinitionFiles: false
|
|
5121
|
+
}],
|
|
5130
5122
|
"@typescript-eslint/no-redeclare": "error",
|
|
5131
|
-
"no-restricted-imports": "off",
|
|
5132
5123
|
"@typescript-eslint/no-restricted-imports": ["error", { paths: [
|
|
5133
5124
|
"error",
|
|
5134
5125
|
"domain",
|
|
@@ -5139,24 +5130,34 @@ function typescriptRulesTypeOblivious() {
|
|
|
5139
5130
|
"querystring",
|
|
5140
5131
|
"colors"
|
|
5141
5132
|
] }],
|
|
5142
|
-
"no-
|
|
5143
|
-
|
|
5133
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
5134
|
+
allowShortCircuit: true,
|
|
5135
|
+
allowTaggedTemplates: true,
|
|
5136
|
+
allowTernary: true
|
|
5137
|
+
}],
|
|
5138
|
+
"@typescript-eslint/no-unused-vars": ["warn", {
|
|
5139
|
+
args: "none",
|
|
5140
|
+
argsIgnorePattern: "^_",
|
|
5141
|
+
caughtErrorsIgnorePattern: "^_",
|
|
5142
|
+
vars: "all",
|
|
5143
|
+
varsIgnorePattern: "^_"
|
|
5144
|
+
}],
|
|
5145
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
|
5146
|
+
classes: true,
|
|
5147
|
+
enums: true,
|
|
5148
|
+
functions: true,
|
|
5149
|
+
typedefs: true,
|
|
5150
|
+
variables: true
|
|
5151
|
+
}],
|
|
5144
5152
|
"@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
|
|
5145
|
-
"
|
|
5146
|
-
"error",
|
|
5147
|
-
"DebuggerStatement",
|
|
5148
|
-
"LabeledStatement",
|
|
5149
|
-
"WithStatement",
|
|
5150
|
-
"TSEnumDeclaration[const=true]",
|
|
5151
|
-
"TSExportAssignment"
|
|
5152
|
-
]
|
|
5153
|
+
"@typescript-eslint/prefer-namespace-keyword": "warn"
|
|
5153
5154
|
};
|
|
5154
5155
|
}
|
|
5155
5156
|
function typescriptRules(props) {
|
|
5156
5157
|
const normalized = {
|
|
5157
5158
|
includeTsEslintPresetRules: true,
|
|
5158
|
-
typeAware: false,
|
|
5159
5159
|
strict: false,
|
|
5160
|
+
typeAware: false,
|
|
5160
5161
|
...props
|
|
5161
5162
|
};
|
|
5162
5163
|
if (normalized.presets !== void 0 && normalized.strictProvided) throw new Error("Use either TypeScript `presets` or deprecated `strict`, not both.");
|
|
@@ -5177,7 +5178,7 @@ function typescriptRules(props) {
|
|
|
5177
5178
|
const markdown = async (options) => {
|
|
5178
5179
|
const { componentExts = [], overrides = {} } = options ?? {};
|
|
5179
5180
|
const files = [GLOB_MARKDOWN];
|
|
5180
|
-
const
|
|
5181
|
+
const pluginMarkdown = await interopDefault(import("@eslint/markdown"));
|
|
5181
5182
|
const tsRulesOff = Object.fromEntries(Object.keys(typescriptRulesTypeAware()).map((key) => [`@typescript-eslint/${key}`, "off"]));
|
|
5182
5183
|
const processor = mergeProcessors([pluginMarkdown.processors.markdown, processorPassThrough]);
|
|
5183
5184
|
return [
|
|
@@ -6244,15 +6245,23 @@ const sortTsconfig = (options) => {
|
|
|
6244
6245
|
};
|
|
6245
6246
|
//#endregion
|
|
6246
6247
|
//#region src/configs/stylistic.ts
|
|
6247
|
-
function jsxStylistic(indent) {
|
|
6248
|
+
function jsxStylistic(indent = 2) {
|
|
6248
6249
|
return {
|
|
6249
6250
|
"@stylistic/jsx-curly-brace-presence": ["error", { propElementValues: "always" }],
|
|
6250
6251
|
"@stylistic/jsx-indent-props": ["error", { indentMode: indent === "tab" ? "tab" : indent }],
|
|
6251
6252
|
"@stylistic/jsx-quotes": "error"
|
|
6252
6253
|
};
|
|
6253
6254
|
}
|
|
6255
|
+
async function importPluginStylistic() {
|
|
6256
|
+
try {
|
|
6257
|
+
return { pluginStylistic: await interopDefault(import("@stylistic/eslint-plugin")) };
|
|
6258
|
+
} catch (error) {
|
|
6259
|
+
console.error("Failed to import @stylistic/eslint-plugin; `pnpm add -D @stylistic/eslint-plugin`", error);
|
|
6260
|
+
throw error;
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6254
6263
|
const stylistic = async (options) => {
|
|
6255
|
-
const { jsx = true, quotes = "double" } = options ?? {};
|
|
6264
|
+
const { jsx = true, overrides: overridesStylistic, quotes = "double" } = options ?? {};
|
|
6256
6265
|
const hasIndent = options?.indent !== void 0;
|
|
6257
6266
|
const indent = options?.indent ?? 2;
|
|
6258
6267
|
const { pluginStylistic } = await importPluginStylistic();
|
|
@@ -6271,7 +6280,8 @@ const stylistic = async (options) => {
|
|
|
6271
6280
|
avoidEscape: true
|
|
6272
6281
|
}
|
|
6273
6282
|
],
|
|
6274
|
-
...jsx && jsxStylistic(indent)
|
|
6283
|
+
...jsx && jsxStylistic(indent),
|
|
6284
|
+
...overridesStylistic
|
|
6275
6285
|
}
|
|
6276
6286
|
}];
|
|
6277
6287
|
};
|
|
@@ -6484,6 +6494,27 @@ const unicorn = ({ overrides = {}, preset = "recommended" } = {}) => {
|
|
|
6484
6494
|
}];
|
|
6485
6495
|
};
|
|
6486
6496
|
//#endregion
|
|
6497
|
+
//#region src/configs/unused-imports.ts
|
|
6498
|
+
const unusedImports = (options) => {
|
|
6499
|
+
const { isInEditor = false, overrides = {} } = options ?? {};
|
|
6500
|
+
return [{
|
|
6501
|
+
files: GLOB_CODE,
|
|
6502
|
+
name: "jsse/unused-imports",
|
|
6503
|
+
plugins: { "unused-imports": pluginUnusedImports },
|
|
6504
|
+
rules: {
|
|
6505
|
+
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
6506
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
6507
|
+
args: "after-used",
|
|
6508
|
+
argsIgnorePattern: "^_",
|
|
6509
|
+
ignoreRestSiblings: true,
|
|
6510
|
+
vars: "all",
|
|
6511
|
+
varsIgnorePattern: "^_"
|
|
6512
|
+
}],
|
|
6513
|
+
...overrides
|
|
6514
|
+
}
|
|
6515
|
+
}];
|
|
6516
|
+
};
|
|
6517
|
+
//#endregion
|
|
6487
6518
|
//#region src/configs/vitest.ts
|
|
6488
6519
|
const vitest = async (options = {}) => {
|
|
6489
6520
|
const { overrides = {} } = options;
|
|
@@ -6520,7 +6551,6 @@ const yml = async (options) => {
|
|
|
6520
6551
|
languageOptions: { parser: parserYaml },
|
|
6521
6552
|
name: "jsse/yaml/rules",
|
|
6522
6553
|
rules: {
|
|
6523
|
-
"style/spaced-comment": "off",
|
|
6524
6554
|
"yaml/block-mapping": "error",
|
|
6525
6555
|
"yaml/block-sequence": "error",
|
|
6526
6556
|
"yaml/no-empty-key": "error",
|
|
@@ -7594,7 +7624,8 @@ function binop(name, prec) {
|
|
|
7594
7624
|
binop: prec
|
|
7595
7625
|
});
|
|
7596
7626
|
}
|
|
7597
|
-
var beforeExpr = { beforeExpr: true }
|
|
7627
|
+
var beforeExpr = { beforeExpr: true };
|
|
7628
|
+
var startsExpr = { startsExpr: true };
|
|
7598
7629
|
var keywords = {};
|
|
7599
7630
|
function kw(name, options) {
|
|
7600
7631
|
if (options === void 0) options = {};
|
|
@@ -7848,11 +7879,27 @@ function pushComment(options, array) {
|
|
|
7848
7879
|
array.push(comment);
|
|
7849
7880
|
};
|
|
7850
7881
|
}
|
|
7851
|
-
var SCOPE_TOP = 1
|
|
7882
|
+
var SCOPE_TOP = 1;
|
|
7883
|
+
var SCOPE_FUNCTION = 2;
|
|
7884
|
+
var SCOPE_ASYNC = 4;
|
|
7885
|
+
var SCOPE_GENERATOR = 8;
|
|
7886
|
+
var SCOPE_ARROW = 16;
|
|
7887
|
+
var SCOPE_SIMPLE_CATCH = 32;
|
|
7888
|
+
var SCOPE_SUPER = 64;
|
|
7889
|
+
var SCOPE_DIRECT_SUPER = 128;
|
|
7890
|
+
var SCOPE_CLASS_STATIC_BLOCK = 256;
|
|
7891
|
+
var SCOPE_CLASS_FIELD_INIT = 512;
|
|
7892
|
+
var SCOPE_SWITCH = 1024;
|
|
7893
|
+
var SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
|
|
7852
7894
|
function functionFlags(async, generator) {
|
|
7853
7895
|
return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
|
|
7854
7896
|
}
|
|
7855
|
-
var BIND_NONE = 0
|
|
7897
|
+
var BIND_NONE = 0;
|
|
7898
|
+
var BIND_VAR = 1;
|
|
7899
|
+
var BIND_LEXICAL = 2;
|
|
7900
|
+
var BIND_FUNCTION = 3;
|
|
7901
|
+
var BIND_SIMPLE_CATCH = 4;
|
|
7902
|
+
var BIND_OUTSIDE = 5;
|
|
7856
7903
|
var Parser = function Parser(options, input, startPos) {
|
|
7857
7904
|
this.options = options = getOptions(options);
|
|
7858
7905
|
this.sourceFile = options.sourceFile;
|
|
@@ -8097,7 +8144,8 @@ pp$8.parseTopLevel = function(node) {
|
|
|
8097
8144
|
node.sourceType = this.options.sourceType === "commonjs" ? "script" : this.options.sourceType;
|
|
8098
8145
|
return this.finishNode(node, "Program");
|
|
8099
8146
|
};
|
|
8100
|
-
var loopLabel = { kind: "loop" }
|
|
8147
|
+
var loopLabel = { kind: "loop" };
|
|
8148
|
+
var switchLabel = { kind: "switch" };
|
|
8101
8149
|
pp$8.isLet = function(context) {
|
|
8102
8150
|
if (this.options.ecmaVersion < 6 || !this.isContextual("let")) return false;
|
|
8103
8151
|
skipWhiteSpace.lastIndex = this.pos;
|
|
@@ -8526,7 +8574,9 @@ pp$8.parseVarId = function(decl, kind) {
|
|
|
8526
8574
|
decl.id = kind === "using" || kind === "await using" ? this.parseIdent() : this.parseBindingAtom();
|
|
8527
8575
|
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
|
|
8528
8576
|
};
|
|
8529
|
-
var FUNC_STATEMENT = 1
|
|
8577
|
+
var FUNC_STATEMENT = 1;
|
|
8578
|
+
var FUNC_HANGING_STATEMENT = 2;
|
|
8579
|
+
var FUNC_NULLABLE_ID = 4;
|
|
8530
8580
|
pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
|
|
8531
8581
|
this.initFunction(node);
|
|
8532
8582
|
if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
|
|
@@ -13170,6 +13220,7 @@ function defaultOptions() {
|
|
|
13170
13220
|
typeAware: false,
|
|
13171
13221
|
typescript: typescriptExists,
|
|
13172
13222
|
unicorn: true,
|
|
13223
|
+
unusedImports: true,
|
|
13173
13224
|
vitest: vitestExists,
|
|
13174
13225
|
yaml: false
|
|
13175
13226
|
};
|
|
@@ -13214,7 +13265,8 @@ const CODE_SCOPED_CFG_NAMES = /* @__PURE__ */ new Set([
|
|
|
13214
13265
|
"jsse/perfectionist",
|
|
13215
13266
|
"jsse/prettier/config",
|
|
13216
13267
|
"jsse/stylistic",
|
|
13217
|
-
"jsse/unicorn"
|
|
13268
|
+
"jsse/unicorn",
|
|
13269
|
+
"jsse/unused-imports"
|
|
13218
13270
|
]);
|
|
13219
13271
|
function postProcessConfigs(configs, options) {
|
|
13220
13272
|
const { componentExts, debug = false, off, rootId = "jsse", tsPrefix, typescript } = options;
|
|
@@ -13271,7 +13323,7 @@ async function gitignoreConfig(options) {
|
|
|
13271
13323
|
async function jsse(options = {}, ...userConfigs) {
|
|
13272
13324
|
const startTime = process$1.hrtime.bigint();
|
|
13273
13325
|
const normalizedOptions = normalizeOptions(options);
|
|
13274
|
-
const { antfu: antfuOptions, command: commandOptions, componentExts, debug = false, demorgan: deMorganOptions, e18e: e18eOptions, gitignore: enableGitignore, isInEditor, javascript: javascriptOptions, jsdoc: jsdocOptions, jsonc: enableJsonc, markdown: enableMarkdown, n: nOptions, nodeTest: nodeTestOptions, off, pnpm: pnpmOptions, prettier: enablePrettier, react: enableReact, regexp: enableRegexp, reportUnusedDisableDirectives, rootId, sortGeojson: enableSortGeojson, sortImports: enableSortImports, sortPackageJson: enableSortPackageJson, sortTsconfig: enableSortTsconfig, stylistic: stylisticOptions, tailwind: tailwindOptions, tsPrefix, typescript: typescriptOptions, unicorn: unicornOptions, vitest: enableVitest, yaml: enableYaml } = normalizedOptions;
|
|
13326
|
+
const { antfu: antfuOptions, command: commandOptions, componentExts, debug = false, demorgan: deMorganOptions, e18e: e18eOptions, gitignore: enableGitignore, isInEditor, javascript: javascriptOptions, jsdoc: jsdocOptions, jsonc: enableJsonc, markdown: enableMarkdown, n: nOptions, nodeTest: nodeTestOptions, off, pnpm: pnpmOptions, prettier: enablePrettier, react: enableReact, regexp: enableRegexp, reportUnusedDisableDirectives, rootId, sortGeojson: enableSortGeojson, sortImports: enableSortImports, sortPackageJson: enableSortPackageJson, sortTsconfig: enableSortTsconfig, stylistic: stylisticOptions, tailwind: tailwindOptions, tsPrefix, typescript: typescriptOptions, unicorn: unicornOptions, unusedImports: unusedImportsOptions, vitest: enableVitest, yaml: enableYaml } = normalizedOptions;
|
|
13275
13327
|
if (debug || process$1.argv.includes("--debug")) enableDbg();
|
|
13276
13328
|
dbg("@jsse/eslint-config debug=true");
|
|
13277
13329
|
dbg("@jsse/eslint-config isInEditor: %O", isInEditor);
|
|
@@ -13280,10 +13332,13 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
13280
13332
|
const configs = [];
|
|
13281
13333
|
if (enableGitignore) configs.push(gitignoreConfig(enableGitignore));
|
|
13282
13334
|
configs.push(ignores(), javascript({
|
|
13283
|
-
isInEditor,
|
|
13284
13335
|
...javascriptOptions,
|
|
13285
13336
|
reportUnusedDisableDirectives
|
|
13286
13337
|
}), eslintComments());
|
|
13338
|
+
if (unusedImportsOptions) configs.push(unusedImports({
|
|
13339
|
+
isInEditor,
|
|
13340
|
+
...typeof unusedImportsOptions === "object" && unusedImportsOptions
|
|
13341
|
+
}));
|
|
13287
13342
|
if (nOptions) configs.push(n(typeof nOptions === "object" ? nOptions : void 0));
|
|
13288
13343
|
if (jsdocOptions) configs.push(jsdoc(typeof jsdocOptions === "object" ? jsdocOptions : void 0));
|
|
13289
13344
|
configs.push(imports({ stylistic: stylisticOptions }));
|