@jsse/eslint-config 0.9.2 → 0.9.3
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 +11 -0
- package/dist/cli.js +1 -1
- package/dist/fixable-rules-map-Cdv6wg6P.d.ts +488 -0
- package/dist/fixable.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +417 -374
- package/dist/{fixable-rules-map-CCZ-PRHv.d.ts → rule-types-DKF8Uy8X.d.ts} +188 -621
- 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,17 @@ 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 "@eslint-react/eslint-plugin";
|
|
22
|
+
import "@eslint/markdown";
|
|
23
|
+
import "@stylistic/eslint-plugin";
|
|
24
|
+
import "@vitest/eslint-plugin";
|
|
25
|
+
import "eslint-node-test";
|
|
26
|
+
import "eslint-plugin-jsonc";
|
|
27
|
+
import "eslint-plugin-no-only-tests";
|
|
28
|
+
import "eslint-plugin-react-hooks";
|
|
29
|
+
import "eslint-plugin-react-refresh";
|
|
30
|
+
import "jsonc-eslint-parser";
|
|
31
|
+
import Debug from "debug";
|
|
21
32
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
22
33
|
import tseslint from "typescript-eslint";
|
|
23
34
|
import fs, { realpathSync, statSync } from "node:fs";
|
|
@@ -28,7 +39,7 @@ import assert from "node:assert";
|
|
|
28
39
|
import v8 from "node:v8";
|
|
29
40
|
import { format, inspect } from "node:util";
|
|
30
41
|
//#region src/_generated/version.ts
|
|
31
|
-
const VERSION = "0.9.
|
|
42
|
+
const VERSION = "0.9.3";
|
|
32
43
|
//#endregion
|
|
33
44
|
//#region src/globs.ts
|
|
34
45
|
var globs_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -139,232 +150,6 @@ const GLOB_EXCLUDE = [
|
|
|
139
150
|
"**/yarn.lock"
|
|
140
151
|
];
|
|
141
152
|
//#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
153
|
//#region src/configs/antfu.ts
|
|
369
154
|
const antfu = (options) => {
|
|
370
155
|
return [{
|
|
@@ -4763,79 +4548,295 @@ function javascriptSelectedRules() {
|
|
|
4763
4548
|
yoda: ["error", "never"]
|
|
4764
4549
|
};
|
|
4765
4550
|
}
|
|
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"
|
|
4551
|
+
const javascript = (options) => {
|
|
4552
|
+
const { overrides = {}, reportUnusedDisableDirectives = true } = options ?? {};
|
|
4553
|
+
return [{
|
|
4554
|
+
files: GLOB_CODE,
|
|
4555
|
+
languageOptions: {
|
|
4556
|
+
ecmaVersion: 2022,
|
|
4557
|
+
globals: {
|
|
4558
|
+
...import_globals.default.browser,
|
|
4559
|
+
...import_globals.default.es2021,
|
|
4560
|
+
...import_globals.default.node,
|
|
4561
|
+
document: "readonly",
|
|
4562
|
+
navigator: "readonly",
|
|
4563
|
+
window: "readonly"
|
|
4564
|
+
},
|
|
4565
|
+
parserOptions: {
|
|
4566
|
+
ecmaFeatures: { jsx: true },
|
|
4567
|
+
ecmaVersion: 2022,
|
|
4568
|
+
sourceType: "module"
|
|
4569
|
+
},
|
|
4570
|
+
sourceType: "module"
|
|
4571
|
+
},
|
|
4572
|
+
linterOptions: { reportUnusedDisableDirectives },
|
|
4573
|
+
name: "jsse/javascript",
|
|
4574
|
+
rules: {
|
|
4575
|
+
...eslintjs.configs.recommended.rules,
|
|
4576
|
+
...javascriptSelectedRules(),
|
|
4577
|
+
...overrides
|
|
4578
|
+
}
|
|
4579
|
+
}, {
|
|
4580
|
+
files: [`scripts/${GLOB_JS}`, `cli.${GLOB_JS_SRC_EXT}`],
|
|
4581
|
+
name: "jsse/scripts-overrides",
|
|
4582
|
+
rules: { "no-console": "off" }
|
|
4583
|
+
}];
|
|
4584
|
+
};
|
|
4585
|
+
//#endregion
|
|
4586
|
+
//#region src/configs/jsdoc.ts
|
|
4587
|
+
const jsdoc = (options) => {
|
|
4588
|
+
return [{
|
|
4589
|
+
files: GLOB_CODE,
|
|
4590
|
+
name: "jsse/jsdoc",
|
|
4591
|
+
plugins: { jsdoc: pluginJsdoc },
|
|
4592
|
+
rules: {
|
|
4593
|
+
"jsdoc/check-access": "warn",
|
|
4594
|
+
"jsdoc/check-alignment": "warn",
|
|
4595
|
+
"jsdoc/check-param-names": "warn",
|
|
4596
|
+
"jsdoc/check-property-names": "warn",
|
|
4597
|
+
"jsdoc/check-types": "warn",
|
|
4598
|
+
"jsdoc/empty-tags": "warn",
|
|
4599
|
+
"jsdoc/implements-on-classes": "warn",
|
|
4600
|
+
"jsdoc/multiline-blocks": "warn",
|
|
4601
|
+
"jsdoc/no-defaults": "warn",
|
|
4602
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
4603
|
+
"jsdoc/require-param-name": "warn",
|
|
4604
|
+
"jsdoc/require-property": "warn",
|
|
4605
|
+
"jsdoc/require-property-description": "warn",
|
|
4606
|
+
"jsdoc/require-property-name": "warn",
|
|
4607
|
+
"jsdoc/require-returns-check": "warn",
|
|
4608
|
+
"jsdoc/require-returns-description": "warn",
|
|
4609
|
+
"jsdoc/require-yields-check": "warn",
|
|
4610
|
+
"jsdoc/tag-lines": [
|
|
4611
|
+
"warn",
|
|
4612
|
+
"any",
|
|
4613
|
+
{
|
|
4614
|
+
endLines: 0,
|
|
4615
|
+
startLines: null
|
|
4616
|
+
}
|
|
4617
|
+
],
|
|
4618
|
+
...options?.overrides
|
|
4619
|
+
}
|
|
4620
|
+
}];
|
|
4621
|
+
};
|
|
4622
|
+
//#endregion
|
|
4623
|
+
//#region src/lager.ts
|
|
4624
|
+
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4625
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
4626
|
+
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);
|
|
4627
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
4628
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
4629
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
4630
|
+
};
|
|
4631
|
+
let replaceClose = (string, close, replace, index) => {
|
|
4632
|
+
let result = "", cursor = 0;
|
|
4633
|
+
do {
|
|
4634
|
+
result += string.substring(cursor, index) + replace;
|
|
4635
|
+
cursor = index + close.length;
|
|
4636
|
+
index = string.indexOf(close, cursor);
|
|
4637
|
+
} while (~index);
|
|
4638
|
+
return result + string.substring(cursor);
|
|
4639
|
+
};
|
|
4640
|
+
let createColors = (enabled = isColorSupported) => {
|
|
4641
|
+
let f = enabled ? formatter : () => String;
|
|
4642
|
+
return {
|
|
4643
|
+
isColorSupported: enabled,
|
|
4644
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
4645
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
4646
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
4647
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
4648
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
4649
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
4650
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
4651
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
4652
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
4653
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
4654
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
4655
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
4656
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
4657
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
4658
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
4659
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
4660
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
4661
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
4662
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
4663
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
4664
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
4665
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
4666
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
4667
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
4668
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
4669
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
4670
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
4671
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
4672
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
4673
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
4674
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
4675
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
4676
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
4677
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
4678
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
4679
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
4680
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
4681
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
4682
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
4683
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
4684
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
4685
|
+
};
|
|
4686
|
+
};
|
|
4687
|
+
module.exports = createColors();
|
|
4688
|
+
module.exports.createColors = createColors;
|
|
4689
|
+
})))(), 1);
|
|
4690
|
+
const dbg = Debug("jsse:eslint-config");
|
|
4691
|
+
const WARN_LABEL = import_picocolors.default.yellow("[[@jsse/eslint-config::WARN]]");
|
|
4692
|
+
function enableDbg() {
|
|
4693
|
+
const currentNamespaces = Debug.namespaces;
|
|
4694
|
+
const current = typeof currentNamespaces === "string" ? currentNamespaces : void 0;
|
|
4695
|
+
Debug.enable([current, "jsse:eslint-config"].filter((ns) => ns !== void 0).join(","));
|
|
4696
|
+
dbg("Debugging enabled for @jsse/eslint-config");
|
|
4697
|
+
}
|
|
4698
|
+
const warn = (...args) => {
|
|
4699
|
+
const msg = args.map((arg) => {
|
|
4700
|
+
if (typeof arg === "string") return arg;
|
|
4701
|
+
if (arg instanceof Error) return arg.message;
|
|
4702
|
+
try {
|
|
4703
|
+
return JSON.stringify(arg, void 0, 2);
|
|
4704
|
+
} catch (_e) {
|
|
4705
|
+
return String(arg);
|
|
4706
|
+
}
|
|
4707
|
+
}).join(" ");
|
|
4708
|
+
console.warn(`${WARN_LABEL} ${msg}`);
|
|
4709
|
+
};
|
|
4710
|
+
//#endregion
|
|
4711
|
+
//#region src/utils.ts
|
|
4712
|
+
function isPromiseLike(value) {
|
|
4713
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
4714
|
+
}
|
|
4715
|
+
function flattenConfigs(configs) {
|
|
4716
|
+
return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
|
|
4717
|
+
}
|
|
4718
|
+
async function resolveAndFlattenConfigs(configs) {
|
|
4719
|
+
return flattenConfigs(await Promise.all(configs.map((config) => Promise.resolve(config))));
|
|
4720
|
+
}
|
|
4721
|
+
/**
|
|
4722
|
+
* Combine array and non-array configs into a single array.
|
|
4723
|
+
* @param configs configs to combine and flatten
|
|
4724
|
+
* @returns combined configs as a flattened array
|
|
4725
|
+
*/
|
|
4726
|
+
function combineAsync(...configs) {
|
|
4727
|
+
if (configs.every((config) => !isPromiseLike(config))) return flattenConfigs(configs);
|
|
4728
|
+
return resolveAndFlattenConfigs(configs);
|
|
4729
|
+
}
|
|
4730
|
+
function renameRules(rules, from, to) {
|
|
4731
|
+
if (from === to) return rules;
|
|
4732
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
4733
|
+
if (key.startsWith(from)) return [to + key.slice(from.length), value];
|
|
4734
|
+
return [key, value];
|
|
4735
|
+
}));
|
|
4736
|
+
}
|
|
4737
|
+
async function interopDefault(m) {
|
|
4738
|
+
const resolved = await m;
|
|
4739
|
+
return resolved.default || resolved;
|
|
4740
|
+
}
|
|
4741
|
+
function isCI() {
|
|
4742
|
+
return !!process$1.env.CI;
|
|
4743
|
+
}
|
|
4744
|
+
function isInEditor() {
|
|
4745
|
+
return !!((process$1.env.VSCODE_PID || process$1.env.JETBRAINS_IDE) && !isCI());
|
|
4746
|
+
}
|
|
4747
|
+
/**
|
|
4748
|
+
* Make an array of strings unique maintaining order.
|
|
4749
|
+
* @param strings strings to make unique
|
|
4750
|
+
* @returns unique strings
|
|
4751
|
+
*/
|
|
4752
|
+
function uniqueStrings(...strings) {
|
|
4753
|
+
const set = /* @__PURE__ */ new Set();
|
|
4754
|
+
for (const item of strings) if (typeof item === "string") set.add(item);
|
|
4755
|
+
else for (const str of item) set.add(str);
|
|
4756
|
+
return [...set];
|
|
4757
|
+
}
|
|
4758
|
+
function matchesRulePrefix(ruleName, rulePrefixes) {
|
|
4759
|
+
return rulePrefixes.some((prefix) => ruleName.startsWith(`${prefix}/`));
|
|
4760
|
+
}
|
|
4761
|
+
function scopeTypeScriptRules(configs, options) {
|
|
4762
|
+
dbg("scoping rules with prefixes %O to files: %O", options.rulePrefixes, options.files);
|
|
4763
|
+
const { files, rulePrefixes } = options;
|
|
4764
|
+
const normalizedPrefixes = uniqueStrings(rulePrefixes).filter(Boolean);
|
|
4765
|
+
if (normalizedPrefixes.length === 0) return configs;
|
|
4766
|
+
const cfgs = configs.flatMap((config) => {
|
|
4767
|
+
if (config.files || config.rules === void 0) return [config];
|
|
4768
|
+
const entries = Object.entries(config.rules);
|
|
4769
|
+
const tsRuleEntries = entries.filter(([ruleName]) => matchesRulePrefix(ruleName, normalizedPrefixes));
|
|
4770
|
+
if (tsRuleEntries.length === 0) return [config];
|
|
4771
|
+
if (tsRuleEntries.length === entries.length) return [{
|
|
4772
|
+
...config,
|
|
4773
|
+
files
|
|
4774
|
+
}];
|
|
4775
|
+
const nonTsRuleEntries = entries.filter(([ruleName]) => !matchesRulePrefix(ruleName, normalizedPrefixes));
|
|
4776
|
+
return [{
|
|
4777
|
+
...config,
|
|
4778
|
+
rules: Object.fromEntries(nonTsRuleEntries)
|
|
4779
|
+
}, {
|
|
4780
|
+
...config,
|
|
4781
|
+
files,
|
|
4782
|
+
name: config.name ? `${config.name}/typescript` : void 0,
|
|
4783
|
+
rules: Object.fromEntries(tsRuleEntries)
|
|
4784
|
+
}];
|
|
4785
|
+
});
|
|
4786
|
+
dbg("scoped rules with prefixes %O to files: %O", normalizedPrefixes, files);
|
|
4787
|
+
return cfgs;
|
|
4788
|
+
}
|
|
4789
|
+
const parserPlain = {
|
|
4790
|
+
meta: { name: "parser-plain" },
|
|
4791
|
+
parseForESLint: (code) => ({
|
|
4792
|
+
ast: {
|
|
4793
|
+
body: [],
|
|
4794
|
+
comments: [],
|
|
4795
|
+
loc: {
|
|
4796
|
+
end: code.length,
|
|
4797
|
+
start: 0
|
|
4784
4798
|
},
|
|
4785
|
-
|
|
4799
|
+
range: [0, code.length],
|
|
4800
|
+
tokens: [],
|
|
4801
|
+
type: "Program"
|
|
4786
4802
|
},
|
|
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
|
-
}];
|
|
4803
|
+
scopeManager: void 0,
|
|
4804
|
+
services: { isPlain: true },
|
|
4805
|
+
visitorKeys: { Program: [] }
|
|
4806
|
+
})
|
|
4808
4807
|
};
|
|
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
|
|
4808
|
+
function turnOffRules(configs, off, debug) {
|
|
4809
|
+
if (off.length > 0) {
|
|
4810
|
+
dbg("turning off rules: %O", off);
|
|
4811
|
+
const currentlyActiveRules = /* @__PURE__ */ new Set();
|
|
4812
|
+
for (const config of configs) {
|
|
4813
|
+
const cfgRules = Object.keys(config.rules ?? {});
|
|
4814
|
+
for (const rule of cfgRules) currentlyActiveRules.add(rule);
|
|
4836
4815
|
}
|
|
4837
|
-
|
|
4838
|
-
|
|
4816
|
+
for (const rule of off) {
|
|
4817
|
+
if (currentlyActiveRules.has(rule)) continue;
|
|
4818
|
+
const msg = `Rule \`${rule}\` is not active in the current config, you can remove it from the off list`;
|
|
4819
|
+
dbg(msg);
|
|
4820
|
+
if (debug) warn(msg);
|
|
4821
|
+
}
|
|
4822
|
+
for (const config of configs) {
|
|
4823
|
+
const cfgRules = config.rules;
|
|
4824
|
+
if (cfgRules) {
|
|
4825
|
+
for (const rule of off) if (cfgRules[rule] !== void 0 && cfgRules[rule] !== "off" && cfgRules[rule] !== 0) cfgRules[rule] = "off";
|
|
4826
|
+
}
|
|
4827
|
+
}
|
|
4828
|
+
dbg("finished turning off rules");
|
|
4829
|
+
}
|
|
4830
|
+
return configs;
|
|
4831
|
+
}
|
|
4832
|
+
const TYPESCRIPT_ESLINT_PREFIX = "@typescript-eslint/";
|
|
4833
|
+
function replaceTypescriptEslintPrefixInplace(items, tsPrefix) {
|
|
4834
|
+
for (const [key, value] of Object.entries(items)) {
|
|
4835
|
+
if (!key.startsWith(TYPESCRIPT_ESLINT_PREFIX)) continue;
|
|
4836
|
+
delete items[key];
|
|
4837
|
+
items[`${tsPrefix}/${key.slice(19)}`] = value;
|
|
4838
|
+
}
|
|
4839
|
+
}
|
|
4839
4840
|
//#endregion
|
|
4840
4841
|
//#region src/configs/jsonc.ts
|
|
4841
4842
|
async function importParserJsonc() {
|
|
@@ -5010,86 +5011,57 @@ function tsPresetRules(props) {
|
|
|
5010
5011
|
function typescriptRulesTypeAware() {
|
|
5011
5012
|
return {
|
|
5012
5013
|
"@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
5013
|
-
"dot-notation": "off",
|
|
5014
5014
|
"@typescript-eslint/dot-notation": ["error", {
|
|
5015
|
-
|
|
5016
|
-
|
|
5015
|
+
allowKeywords: true,
|
|
5016
|
+
allowPattern: "^_"
|
|
5017
|
+
}],
|
|
5018
|
+
"@typescript-eslint/no-floating-promises": ["error", {
|
|
5019
|
+
ignoreIIFE: true,
|
|
5020
|
+
ignoreVoid: true
|
|
5017
5021
|
}],
|
|
5018
5022
|
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
5019
5023
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
5020
5024
|
"@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
5025
|
"@typescript-eslint/restrict-template-expressions": ["error", {
|
|
5027
5026
|
allow: [{
|
|
5027
|
+
from: "lib",
|
|
5028
5028
|
name: [
|
|
5029
5029
|
"Error",
|
|
5030
5030
|
"URL",
|
|
5031
5031
|
"URLSearchParams"
|
|
5032
|
-
]
|
|
5033
|
-
from: "lib"
|
|
5032
|
+
]
|
|
5034
5033
|
}],
|
|
5035
5034
|
allowAny: false,
|
|
5036
5035
|
allowBoolean: true,
|
|
5037
5036
|
allowNullish: true,
|
|
5038
5037
|
allowNumber: true,
|
|
5039
5038
|
allowRegExp: true
|
|
5040
|
-
}]
|
|
5039
|
+
}],
|
|
5040
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
5041
|
+
"dot-notation": "off"
|
|
5041
5042
|
};
|
|
5042
5043
|
}
|
|
5043
5044
|
function typescriptRulesTypeOblivious() {
|
|
5044
5045
|
return {
|
|
5045
|
-
eqeqeq: "error",
|
|
5046
|
-
camelcase: "off",
|
|
5047
|
-
yoda: "error",
|
|
5048
5046
|
"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
|
-
}],
|
|
5047
|
+
camelcase: "off",
|
|
5048
|
+
"comma-spacing": "off",
|
|
5049
|
+
"default-param-last": "off",
|
|
5050
|
+
"no-bitwise": "off",
|
|
5051
|
+
"no-duplicate-imports": "off",
|
|
5052
|
+
"no-empty-function": "off",
|
|
5053
|
+
"no-loop-func": "off",
|
|
5054
|
+
"no-loss-of-precision": "off",
|
|
5055
|
+
"no-restricted-imports": "off",
|
|
5078
5056
|
"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",
|
|
5057
|
+
"object-curly-spacing": "off",
|
|
5087
5058
|
"accessor-pairs": "error",
|
|
5059
|
+
eqeqeq: "error",
|
|
5088
5060
|
"for-direction": "warn",
|
|
5089
5061
|
"guard-for-in": "error",
|
|
5090
5062
|
"max-lines": ["warn", { max: 2e3 }],
|
|
5091
|
-
"no-bitwise": "off",
|
|
5092
5063
|
"no-caller": "error",
|
|
5064
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
5093
5065
|
"no-constant-condition": "warn",
|
|
5094
5066
|
"no-debugger": "warn",
|
|
5095
5067
|
"no-empty": "warn",
|
|
@@ -5106,6 +5078,14 @@ function typescriptRulesTypeOblivious() {
|
|
|
5106
5078
|
"no-new-func": "error",
|
|
5107
5079
|
"no-new-wrappers": "warn",
|
|
5108
5080
|
"no-octal-escape": "error",
|
|
5081
|
+
"no-restricted-syntax": [
|
|
5082
|
+
"error",
|
|
5083
|
+
"DebuggerStatement",
|
|
5084
|
+
"LabeledStatement",
|
|
5085
|
+
"WithStatement",
|
|
5086
|
+
"TSEnumDeclaration[const=true]",
|
|
5087
|
+
"TSExportAssignment"
|
|
5088
|
+
],
|
|
5109
5089
|
"no-return-assign": "error",
|
|
5110
5090
|
"no-script-url": "warn",
|
|
5111
5091
|
"no-self-compare": "error",
|
|
@@ -5118,17 +5098,36 @@ function typescriptRulesTypeOblivious() {
|
|
|
5118
5098
|
"require-atomic-updates": "error",
|
|
5119
5099
|
"require-yield": "warn",
|
|
5120
5100
|
strict: ["error", "never"],
|
|
5121
|
-
|
|
5122
|
-
"
|
|
5101
|
+
yoda: "error",
|
|
5102
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
5103
|
+
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
5104
|
+
assertionStyle: "as",
|
|
5105
|
+
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
5106
|
+
}],
|
|
5107
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
5108
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
5109
|
+
fixStyle: "separate-type-imports",
|
|
5110
|
+
prefer: "type-imports"
|
|
5111
|
+
}],
|
|
5123
5112
|
"@typescript-eslint/default-param-last": "error",
|
|
5113
|
+
"@typescript-eslint/member-ordering": ["warn", {
|
|
5114
|
+
classes: [
|
|
5115
|
+
"field",
|
|
5116
|
+
"constructor",
|
|
5117
|
+
"method"
|
|
5118
|
+
],
|
|
5119
|
+
default: "never"
|
|
5120
|
+
}],
|
|
5121
|
+
"@typescript-eslint/method-signature-style": ["warn", "property"],
|
|
5124
5122
|
"@typescript-eslint/no-dupe-class-members": "error",
|
|
5125
|
-
"no-empty-function": "off",
|
|
5126
5123
|
"@typescript-eslint/no-empty-function": "error",
|
|
5127
|
-
"no-
|
|
5124
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
5128
5125
|
"@typescript-eslint/no-loop-func": "error",
|
|
5129
|
-
"no-
|
|
5126
|
+
"@typescript-eslint/no-namespace": ["error", {
|
|
5127
|
+
allowDeclarations: false,
|
|
5128
|
+
allowDefinitionFiles: false
|
|
5129
|
+
}],
|
|
5130
5130
|
"@typescript-eslint/no-redeclare": "error",
|
|
5131
|
-
"no-restricted-imports": "off",
|
|
5132
5131
|
"@typescript-eslint/no-restricted-imports": ["error", { paths: [
|
|
5133
5132
|
"error",
|
|
5134
5133
|
"domain",
|
|
@@ -5139,24 +5138,34 @@ function typescriptRulesTypeOblivious() {
|
|
|
5139
5138
|
"querystring",
|
|
5140
5139
|
"colors"
|
|
5141
5140
|
] }],
|
|
5142
|
-
"no-
|
|
5143
|
-
|
|
5141
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
5142
|
+
allowShortCircuit: true,
|
|
5143
|
+
allowTaggedTemplates: true,
|
|
5144
|
+
allowTernary: true
|
|
5145
|
+
}],
|
|
5146
|
+
"@typescript-eslint/no-unused-vars": ["warn", {
|
|
5147
|
+
args: "none",
|
|
5148
|
+
argsIgnorePattern: "^_",
|
|
5149
|
+
caughtErrorsIgnorePattern: "^_",
|
|
5150
|
+
vars: "all",
|
|
5151
|
+
varsIgnorePattern: "^_"
|
|
5152
|
+
}],
|
|
5153
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
|
5154
|
+
classes: true,
|
|
5155
|
+
enums: true,
|
|
5156
|
+
functions: true,
|
|
5157
|
+
typedefs: true,
|
|
5158
|
+
variables: true
|
|
5159
|
+
}],
|
|
5144
5160
|
"@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
|
-
]
|
|
5161
|
+
"@typescript-eslint/prefer-namespace-keyword": "warn"
|
|
5153
5162
|
};
|
|
5154
5163
|
}
|
|
5155
5164
|
function typescriptRules(props) {
|
|
5156
5165
|
const normalized = {
|
|
5157
5166
|
includeTsEslintPresetRules: true,
|
|
5158
|
-
typeAware: false,
|
|
5159
5167
|
strict: false,
|
|
5168
|
+
typeAware: false,
|
|
5160
5169
|
...props
|
|
5161
5170
|
};
|
|
5162
5171
|
if (normalized.presets !== void 0 && normalized.strictProvided) throw new Error("Use either TypeScript `presets` or deprecated `strict`, not both.");
|
|
@@ -5177,7 +5186,7 @@ function typescriptRules(props) {
|
|
|
5177
5186
|
const markdown = async (options) => {
|
|
5178
5187
|
const { componentExts = [], overrides = {} } = options ?? {};
|
|
5179
5188
|
const files = [GLOB_MARKDOWN];
|
|
5180
|
-
const
|
|
5189
|
+
const pluginMarkdown = await interopDefault(import("@eslint/markdown"));
|
|
5181
5190
|
const tsRulesOff = Object.fromEntries(Object.keys(typescriptRulesTypeAware()).map((key) => [`@typescript-eslint/${key}`, "off"]));
|
|
5182
5191
|
const processor = mergeProcessors([pluginMarkdown.processors.markdown, processorPassThrough]);
|
|
5183
5192
|
return [
|
|
@@ -6244,15 +6253,23 @@ const sortTsconfig = (options) => {
|
|
|
6244
6253
|
};
|
|
6245
6254
|
//#endregion
|
|
6246
6255
|
//#region src/configs/stylistic.ts
|
|
6247
|
-
function jsxStylistic(indent) {
|
|
6256
|
+
function jsxStylistic(indent = 2) {
|
|
6248
6257
|
return {
|
|
6249
6258
|
"@stylistic/jsx-curly-brace-presence": ["error", { propElementValues: "always" }],
|
|
6250
6259
|
"@stylistic/jsx-indent-props": ["error", { indentMode: indent === "tab" ? "tab" : indent }],
|
|
6251
6260
|
"@stylistic/jsx-quotes": "error"
|
|
6252
6261
|
};
|
|
6253
6262
|
}
|
|
6263
|
+
async function importPluginStylistic() {
|
|
6264
|
+
try {
|
|
6265
|
+
return { pluginStylistic: await interopDefault(import("@stylistic/eslint-plugin")) };
|
|
6266
|
+
} catch (error) {
|
|
6267
|
+
console.error("Failed to import @stylistic/eslint-plugin; `pnpm add -D @stylistic/eslint-plugin`", error);
|
|
6268
|
+
throw error;
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6254
6271
|
const stylistic = async (options) => {
|
|
6255
|
-
const { jsx = true, quotes = "double" } = options ?? {};
|
|
6272
|
+
const { jsx = true, overrides: overridesStylistic, quotes = "double" } = options ?? {};
|
|
6256
6273
|
const hasIndent = options?.indent !== void 0;
|
|
6257
6274
|
const indent = options?.indent ?? 2;
|
|
6258
6275
|
const { pluginStylistic } = await importPluginStylistic();
|
|
@@ -6271,7 +6288,8 @@ const stylistic = async (options) => {
|
|
|
6271
6288
|
avoidEscape: true
|
|
6272
6289
|
}
|
|
6273
6290
|
],
|
|
6274
|
-
...jsx && jsxStylistic(indent)
|
|
6291
|
+
...jsx && jsxStylistic(indent),
|
|
6292
|
+
...overridesStylistic
|
|
6275
6293
|
}
|
|
6276
6294
|
}];
|
|
6277
6295
|
};
|
|
@@ -6484,6 +6502,27 @@ const unicorn = ({ overrides = {}, preset = "recommended" } = {}) => {
|
|
|
6484
6502
|
}];
|
|
6485
6503
|
};
|
|
6486
6504
|
//#endregion
|
|
6505
|
+
//#region src/configs/unused-imports.ts
|
|
6506
|
+
const unusedImports = (options) => {
|
|
6507
|
+
const { isInEditor = false, overrides = {} } = options ?? {};
|
|
6508
|
+
return [{
|
|
6509
|
+
files: GLOB_CODE,
|
|
6510
|
+
name: "jsse/unused-imports",
|
|
6511
|
+
plugins: { "unused-imports": pluginUnusedImports },
|
|
6512
|
+
rules: {
|
|
6513
|
+
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
6514
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
6515
|
+
args: "after-used",
|
|
6516
|
+
argsIgnorePattern: "^_",
|
|
6517
|
+
ignoreRestSiblings: true,
|
|
6518
|
+
vars: "all",
|
|
6519
|
+
varsIgnorePattern: "^_"
|
|
6520
|
+
}],
|
|
6521
|
+
...overrides
|
|
6522
|
+
}
|
|
6523
|
+
}];
|
|
6524
|
+
};
|
|
6525
|
+
//#endregion
|
|
6487
6526
|
//#region src/configs/vitest.ts
|
|
6488
6527
|
const vitest = async (options = {}) => {
|
|
6489
6528
|
const { overrides = {} } = options;
|
|
@@ -6520,7 +6559,6 @@ const yml = async (options) => {
|
|
|
6520
6559
|
languageOptions: { parser: parserYaml },
|
|
6521
6560
|
name: "jsse/yaml/rules",
|
|
6522
6561
|
rules: {
|
|
6523
|
-
"style/spaced-comment": "off",
|
|
6524
6562
|
"yaml/block-mapping": "error",
|
|
6525
6563
|
"yaml/block-sequence": "error",
|
|
6526
6564
|
"yaml/no-empty-key": "error",
|
|
@@ -13170,6 +13208,7 @@ function defaultOptions() {
|
|
|
13170
13208
|
typeAware: false,
|
|
13171
13209
|
typescript: typescriptExists,
|
|
13172
13210
|
unicorn: true,
|
|
13211
|
+
unusedImports: true,
|
|
13173
13212
|
vitest: vitestExists,
|
|
13174
13213
|
yaml: false
|
|
13175
13214
|
};
|
|
@@ -13214,7 +13253,8 @@ const CODE_SCOPED_CFG_NAMES = /* @__PURE__ */ new Set([
|
|
|
13214
13253
|
"jsse/perfectionist",
|
|
13215
13254
|
"jsse/prettier/config",
|
|
13216
13255
|
"jsse/stylistic",
|
|
13217
|
-
"jsse/unicorn"
|
|
13256
|
+
"jsse/unicorn",
|
|
13257
|
+
"jsse/unused-imports"
|
|
13218
13258
|
]);
|
|
13219
13259
|
function postProcessConfigs(configs, options) {
|
|
13220
13260
|
const { componentExts, debug = false, off, rootId = "jsse", tsPrefix, typescript } = options;
|
|
@@ -13271,7 +13311,7 @@ async function gitignoreConfig(options) {
|
|
|
13271
13311
|
async function jsse(options = {}, ...userConfigs) {
|
|
13272
13312
|
const startTime = process$1.hrtime.bigint();
|
|
13273
13313
|
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;
|
|
13314
|
+
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
13315
|
if (debug || process$1.argv.includes("--debug")) enableDbg();
|
|
13276
13316
|
dbg("@jsse/eslint-config debug=true");
|
|
13277
13317
|
dbg("@jsse/eslint-config isInEditor: %O", isInEditor);
|
|
@@ -13280,10 +13320,13 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
13280
13320
|
const configs = [];
|
|
13281
13321
|
if (enableGitignore) configs.push(gitignoreConfig(enableGitignore));
|
|
13282
13322
|
configs.push(ignores(), javascript({
|
|
13283
|
-
isInEditor,
|
|
13284
13323
|
...javascriptOptions,
|
|
13285
13324
|
reportUnusedDisableDirectives
|
|
13286
13325
|
}), eslintComments());
|
|
13326
|
+
if (unusedImportsOptions) configs.push(unusedImports({
|
|
13327
|
+
isInEditor,
|
|
13328
|
+
...typeof unusedImportsOptions === "object" && unusedImportsOptions
|
|
13329
|
+
}));
|
|
13287
13330
|
if (nOptions) configs.push(n(typeof nOptions === "object" ? nOptions : void 0));
|
|
13288
13331
|
if (jsdocOptions) configs.push(jsdoc(typeof jsdocOptions === "object" ? jsdocOptions : void 0));
|
|
13289
13332
|
configs.push(imports({ stylistic: stylisticOptions }));
|