@jsse/eslint-config 0.8.6 → 0.9.0
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 +12 -0
- package/README.md +19 -2
- package/dist/cli.js +78 -11884
- package/dist/fixable-rules-map-B2-5HybI.js +661 -0
- package/dist/fixable-rules-map-CvRdO-mG.d.ts +16614 -0
- package/dist/fixable.d.ts +6 -0
- package/dist/fixable.js +5 -0
- package/dist/index.d.ts +3 -16885
- package/dist/index.js +143 -126
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +28 -15
- package/dist/const-xMi9KGIh.js +0 -49
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DJK8HYOj.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as FIXABLE_RULES_MAP } from "./fixable-rules-map-B2-5HybI.js";
|
|
3
3
|
import { builtinModules, createRequire } from "node:module";
|
|
4
|
-
import process$1 from "node:process";
|
|
5
4
|
import fs, { realpathSync, statSync } from "node:fs";
|
|
5
|
+
import process$1 from "node:process";
|
|
6
6
|
import Debug from "debug";
|
|
7
7
|
import pluginE18e from "@e18e/eslint-plugin";
|
|
8
8
|
import pluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
@@ -14,7 +14,7 @@ import pluginImportLite from "eslint-plugin-import-lite";
|
|
|
14
14
|
import pluginN from "eslint-plugin-n";
|
|
15
15
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
16
16
|
import pluginPnpm from "eslint-plugin-pnpm";
|
|
17
|
-
import
|
|
17
|
+
import { configs } from "eslint-plugin-regexp";
|
|
18
18
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
19
19
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
20
20
|
import createCommand from "eslint-plugin-command/config";
|
|
@@ -27,6 +27,9 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
27
27
|
import assert from "node:assert";
|
|
28
28
|
import v8 from "node:v8";
|
|
29
29
|
import { format, inspect } from "node:util";
|
|
30
|
+
//#region src/_generated/version.ts
|
|
31
|
+
const VERSION = "0.9.0";
|
|
32
|
+
//#endregion
|
|
30
33
|
//#region src/globs.ts
|
|
31
34
|
var globs_exports = /* @__PURE__ */ __exportAll({
|
|
32
35
|
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
@@ -232,14 +235,6 @@ const warn = (...args) => {
|
|
|
232
235
|
async function combineAsync(...configs) {
|
|
233
236
|
return (await Promise.all(configs)).flatMap((config) => Array.isArray(config) ? config : [config]);
|
|
234
237
|
}
|
|
235
|
-
/**
|
|
236
|
-
* Combine array and non-array configs into a single array.
|
|
237
|
-
* @param configs configs to combine
|
|
238
|
-
* @returns combined configs as an array
|
|
239
|
-
*/
|
|
240
|
-
async function combine(...configs) {
|
|
241
|
-
return combineAsync(...configs);
|
|
242
|
-
}
|
|
243
238
|
function renameRules(rules, from, to) {
|
|
244
239
|
if (from === to) return rules;
|
|
245
240
|
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
@@ -341,29 +336,6 @@ function turnOffRules(configs, off, debug) {
|
|
|
341
336
|
}
|
|
342
337
|
return configs;
|
|
343
338
|
}
|
|
344
|
-
function changeRuleEntrySeverity(ruleConfig, level) {
|
|
345
|
-
if (Array.isArray(ruleConfig)) {
|
|
346
|
-
if (ruleConfig[0] !== level) ruleConfig[0] = level;
|
|
347
|
-
return ruleConfig;
|
|
348
|
-
}
|
|
349
|
-
return level;
|
|
350
|
-
}
|
|
351
|
-
function error2warn(configs) {
|
|
352
|
-
for (const config of configs) if (config.rules) config.rules = Object.fromEntries(Object.entries(config.rules).map(([key, value]) => {
|
|
353
|
-
if (value === "error" || value === 2) return [key, changeRuleEntrySeverity(value, "warn")];
|
|
354
|
-
if (Array.isArray(value) && (value[0] === "error" || value[0] === 2)) return [key, changeRuleEntrySeverity(value, "warn")];
|
|
355
|
-
return [key, value];
|
|
356
|
-
}));
|
|
357
|
-
return configs;
|
|
358
|
-
}
|
|
359
|
-
function warn2error(configs) {
|
|
360
|
-
for (const config of configs) if (config.rules) config.rules = Object.fromEntries(Object.entries(config.rules).map(([key, value]) => {
|
|
361
|
-
if (value === "warn" || value === 1) return [key, changeRuleEntrySeverity(value, "error")];
|
|
362
|
-
if (Array.isArray(value) && (value[0] === "warn" || value[0] === 1)) return [key, changeRuleEntrySeverity(value, "error")];
|
|
363
|
-
return [key, value];
|
|
364
|
-
}));
|
|
365
|
-
return configs;
|
|
366
|
-
}
|
|
367
339
|
const TYPESCRIPT_ESLINT_PREFIX = "@typescript-eslint/";
|
|
368
340
|
function replaceTypescriptEslintPrefixInplace(items, tsPrefix) {
|
|
369
341
|
for (const [key, value] of Object.entries(items)) {
|
|
@@ -374,12 +346,6 @@ function replaceTypescriptEslintPrefixInplace(items, tsPrefix) {
|
|
|
374
346
|
}
|
|
375
347
|
//#endregion
|
|
376
348
|
//#region src/plugins.ts
|
|
377
|
-
async function importPluginReact() {
|
|
378
|
-
return { pluginReact: await interopDefault(import("eslint-plugin-react")) };
|
|
379
|
-
}
|
|
380
|
-
async function importPluginReactRefresh() {
|
|
381
|
-
return { pluginReactRefresh: await interopDefault(import("eslint-plugin-react-refresh")) };
|
|
382
|
-
}
|
|
383
349
|
async function importPluginMarkdown() {
|
|
384
350
|
return { pluginMarkdown: await interopDefault(import("@eslint/markdown")) };
|
|
385
351
|
}
|
|
@@ -393,7 +359,10 @@ const antfu = async (options) => {
|
|
|
393
359
|
files: GLOB_CODE,
|
|
394
360
|
name: "jsse/antfu",
|
|
395
361
|
plugins: { antfu: pluginAntfu },
|
|
396
|
-
rules: {
|
|
362
|
+
rules: {
|
|
363
|
+
"antfu/top-level-function": options?.topLevelFunction ?? "off",
|
|
364
|
+
...options?.overrides
|
|
365
|
+
}
|
|
397
366
|
}];
|
|
398
367
|
};
|
|
399
368
|
//#endregion
|
|
@@ -405,20 +374,29 @@ const antfu = async (options) => {
|
|
|
405
374
|
* Docs: https://eslint-plugin-command.antfu.me/guide/
|
|
406
375
|
* @returns Typed config arr
|
|
407
376
|
*/
|
|
408
|
-
const command = async () => {
|
|
377
|
+
const command = async (options) => {
|
|
378
|
+
const config = createCommand();
|
|
409
379
|
return [{
|
|
410
|
-
...
|
|
380
|
+
...config,
|
|
411
381
|
files: GLOB_CODE,
|
|
412
|
-
name: "jsse/command/rules"
|
|
382
|
+
name: "jsse/command/rules",
|
|
383
|
+
rules: {
|
|
384
|
+
...config.rules,
|
|
385
|
+
...options?.overrides
|
|
386
|
+
}
|
|
413
387
|
}];
|
|
414
388
|
};
|
|
415
389
|
//#endregion
|
|
416
390
|
//#region src/configs/de-morgan.ts
|
|
417
|
-
const deMorgan = async () => {
|
|
391
|
+
const deMorgan = async (options) => {
|
|
418
392
|
return [{
|
|
419
393
|
...pluginDeMorgan.configs.recommended,
|
|
420
394
|
files: GLOB_CODE,
|
|
421
|
-
name: "jsse/de-morgan"
|
|
395
|
+
name: "jsse/de-morgan",
|
|
396
|
+
rules: {
|
|
397
|
+
...pluginDeMorgan.configs.recommended.rules,
|
|
398
|
+
...options?.overrides
|
|
399
|
+
}
|
|
422
400
|
}];
|
|
423
401
|
};
|
|
424
402
|
//#endregion
|
|
@@ -474,28 +452,6 @@ const reactHooks = async () => {
|
|
|
474
452
|
}];
|
|
475
453
|
};
|
|
476
454
|
//#endregion
|
|
477
|
-
//#region src/configs/ts/typescript-language-options.ts
|
|
478
|
-
function typescriptLanguageOptions(options) {
|
|
479
|
-
const { componentExts = [], react, tsconfig } = options;
|
|
480
|
-
const tsOptions = tsconfig ? {
|
|
481
|
-
project: Array.isArray(tsconfig) ? tsconfig : [tsconfig],
|
|
482
|
-
tsconfigRootDir: process$1.cwd()
|
|
483
|
-
} : {};
|
|
484
|
-
return {
|
|
485
|
-
parser: parserTs,
|
|
486
|
-
parserOptions: {
|
|
487
|
-
ecmaFeatures: react ? {
|
|
488
|
-
jsx: true,
|
|
489
|
-
modules: true
|
|
490
|
-
} : void 0,
|
|
491
|
-
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
492
|
-
sourceType: "module",
|
|
493
|
-
...tsOptions,
|
|
494
|
-
jsxPragma: react ? "React" : void 0
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
//#endregion
|
|
499
455
|
//#region src/configs/eslint-react.ts
|
|
500
456
|
async function importReactPlugins() {
|
|
501
457
|
const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
|
|
@@ -505,7 +461,7 @@ async function importReactPlugins() {
|
|
|
505
461
|
};
|
|
506
462
|
}
|
|
507
463
|
const eslintReact = async (options) => {
|
|
508
|
-
const {
|
|
464
|
+
const { overrides = {}, reactRefresh } = options ?? {};
|
|
509
465
|
const { pluginReact, pluginReactRefresh } = await importReactPlugins();
|
|
510
466
|
const coreReactPlugins = pluginReact.configs.all.plugins?.["@eslint-react"];
|
|
511
467
|
if (!coreReactPlugins) throw new Error("coreReactPlugins is undefined");
|
|
@@ -513,12 +469,6 @@ const eslintReact = async (options) => {
|
|
|
513
469
|
const config = [
|
|
514
470
|
{
|
|
515
471
|
files: [GLOB_SRC],
|
|
516
|
-
languageOptions: typescriptLanguageOptions({
|
|
517
|
-
componentExts,
|
|
518
|
-
parserOptions,
|
|
519
|
-
react,
|
|
520
|
-
tsconfig
|
|
521
|
-
}),
|
|
522
472
|
name: "jsse/react/setup",
|
|
523
473
|
plugins: {
|
|
524
474
|
"@eslint-react": coreReactPlugins,
|
|
@@ -531,7 +481,8 @@ const eslintReact = async (options) => {
|
|
|
531
481
|
rules: {
|
|
532
482
|
...pluginReact.configs.recommended.rules,
|
|
533
483
|
"react/dom-no-string-style-prop": "off",
|
|
534
|
-
"react/dom-no-unknown-property": "off"
|
|
484
|
+
"react/dom-no-unknown-property": "off",
|
|
485
|
+
...overrides
|
|
535
486
|
},
|
|
536
487
|
settings: { react: { version: "detect" } }
|
|
537
488
|
},
|
|
@@ -4914,7 +4865,7 @@ const javascript = async (options) => {
|
|
|
4914
4865
|
};
|
|
4915
4866
|
//#endregion
|
|
4916
4867
|
//#region src/configs/jsdoc.ts
|
|
4917
|
-
const jsdoc = async () => {
|
|
4868
|
+
const jsdoc = async (options) => {
|
|
4918
4869
|
return [{
|
|
4919
4870
|
files: GLOB_CODE,
|
|
4920
4871
|
name: "jsse/jsdoc",
|
|
@@ -4937,7 +4888,8 @@ const jsdoc = async () => {
|
|
|
4937
4888
|
"jsdoc/require-returns-check": "warn",
|
|
4938
4889
|
"jsdoc/require-returns-description": "warn",
|
|
4939
4890
|
"jsdoc/require-yields-check": "warn",
|
|
4940
|
-
"jsdoc/tag-lines": "warn"
|
|
4891
|
+
"jsdoc/tag-lines": "warn",
|
|
4892
|
+
...options?.overrides
|
|
4941
4893
|
}
|
|
4942
4894
|
}];
|
|
4943
4895
|
};
|
|
@@ -5261,7 +5213,7 @@ const markdown = async (options) => {
|
|
|
5261
5213
|
};
|
|
5262
5214
|
//#endregion
|
|
5263
5215
|
//#region src/configs/n.ts
|
|
5264
|
-
const n = async () => {
|
|
5216
|
+
const n = async (options) => {
|
|
5265
5217
|
return [{
|
|
5266
5218
|
files: GLOB_CODE,
|
|
5267
5219
|
name: "jsse/n",
|
|
@@ -5274,7 +5226,8 @@ const n = async () => {
|
|
|
5274
5226
|
"n/no-path-concat": "error",
|
|
5275
5227
|
"n/prefer-global/buffer": ["error", "never"],
|
|
5276
5228
|
"n/prefer-global/process": ["error", "never"],
|
|
5277
|
-
"n/process-exit-as-throw": "error"
|
|
5229
|
+
"n/process-exit-as-throw": "error",
|
|
5230
|
+
...options?.overrides
|
|
5278
5231
|
}
|
|
5279
5232
|
}];
|
|
5280
5233
|
};
|
|
@@ -5355,7 +5308,9 @@ const perfectionist = async () => {
|
|
|
5355
5308
|
};
|
|
5356
5309
|
//#endregion
|
|
5357
5310
|
//#region src/configs/pnpm.ts
|
|
5358
|
-
const pnpm = async () => {
|
|
5311
|
+
const pnpm = async (options) => {
|
|
5312
|
+
const jsonOverrides = Object.fromEntries(Object.entries(options?.overrides ?? {}).filter(([rule]) => rule.startsWith("pnpm/json-")));
|
|
5313
|
+
const yamlOverrides = Object.fromEntries(Object.entries(options?.overrides ?? {}).filter(([rule]) => rule.startsWith("pnpm/yaml-")));
|
|
5359
5314
|
return [{
|
|
5360
5315
|
files: ["package.json", "**/package.json"],
|
|
5361
5316
|
languageOptions: { parser: await import("jsonc-eslint-parser") },
|
|
@@ -5364,7 +5319,8 @@ const pnpm = async () => {
|
|
|
5364
5319
|
rules: {
|
|
5365
5320
|
"pnpm/json-enforce-catalog": "error",
|
|
5366
5321
|
"pnpm/json-prefer-workspace-settings": "error",
|
|
5367
|
-
"pnpm/json-valid-catalog": "error"
|
|
5322
|
+
"pnpm/json-valid-catalog": "error",
|
|
5323
|
+
...jsonOverrides
|
|
5368
5324
|
}
|
|
5369
5325
|
}, {
|
|
5370
5326
|
files: ["pnpm-workspace.yaml"],
|
|
@@ -5373,7 +5329,8 @@ const pnpm = async () => {
|
|
|
5373
5329
|
plugins: { pnpm: pluginPnpm },
|
|
5374
5330
|
rules: {
|
|
5375
5331
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
5376
|
-
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
5332
|
+
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
5333
|
+
...yamlOverrides
|
|
5377
5334
|
}
|
|
5378
5335
|
}];
|
|
5379
5336
|
};
|
|
@@ -5620,6 +5577,11 @@ const sortPackageJson = async () => {
|
|
|
5620
5577
|
};
|
|
5621
5578
|
//#endregion
|
|
5622
5579
|
//#region src/configs/sort-tsconfig.ts
|
|
5580
|
+
/**
|
|
5581
|
+
* Sort tsconfig.json
|
|
5582
|
+
*
|
|
5583
|
+
* Requires `jsonc` config
|
|
5584
|
+
*/
|
|
5623
5585
|
const tsconfigGlobs = (extendGlobs) => {
|
|
5624
5586
|
return extendGlobs === void 0 || extendGlobs.length === 0 ? GLOB_TSCONFIG : uniqueStrings(GLOB_TSCONFIG, extendGlobs);
|
|
5625
5587
|
};
|
|
@@ -5779,7 +5741,7 @@ function autoUseParserService(options) {
|
|
|
5779
5741
|
return !!(options.tsconfig && (typeof options.tsconfig === "string" && options.tsconfig === "tsconfig.json" || Array.isArray(options.tsconfig) && options.tsconfig.length === 1 && options.tsconfig[0] === "tsconfig.json"));
|
|
5780
5742
|
}
|
|
5781
5743
|
function typescriptParser(options) {
|
|
5782
|
-
const { componentExts = [], filesTypeAware: files = [GLOB_TS, GLOB_TSX], ignoresTypeAware: ignores = [GLOB_MARKDOWN], name, parserOptions: parserOptionsOverride = {},
|
|
5744
|
+
const { componentExts = [], filesTypeAware: files = [GLOB_TS, GLOB_TSX], ignoresTypeAware: ignores = [GLOB_MARKDOWN], name, parserOptions: parserOptionsOverride = {}, tsconfig, typeAware: typeAwareOpt, useProjectService = autoUseParserService(options) } = options;
|
|
5783
5745
|
const typeAware = typeAwareOpt === void 0 ? !!tsconfig : typeAwareOpt;
|
|
5784
5746
|
if (useProjectService) {
|
|
5785
5747
|
dbg("ts parser-options using `projectService`project service");
|
|
@@ -5790,14 +5752,13 @@ function typescriptParser(options) {
|
|
|
5790
5752
|
parser: parserTs,
|
|
5791
5753
|
parserOptions: {
|
|
5792
5754
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
5793
|
-
jsxPragma: react ? "React" : void 0,
|
|
5794
5755
|
sourceType: "module",
|
|
5795
5756
|
...typeAware && {
|
|
5796
5757
|
projectService: {
|
|
5797
5758
|
allowDefaultProject: ["./*.js"],
|
|
5798
5759
|
defaultProject: (typeof tsconfig === "string" ? tsconfig : tsconfig?.[0]) ?? "tsconfig.json"
|
|
5799
5760
|
},
|
|
5800
|
-
tsconfigRootDir: process$1.cwd()
|
|
5761
|
+
tsconfigRootDir: process$1.cwd().replaceAll("\\", "/")
|
|
5801
5762
|
},
|
|
5802
5763
|
...parserOptionsOverride
|
|
5803
5764
|
}
|
|
@@ -5813,7 +5774,6 @@ function typescriptParser(options) {
|
|
|
5813
5774
|
parser: parserTs,
|
|
5814
5775
|
parserOptions: {
|
|
5815
5776
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
5816
|
-
jsxPragma: react ? "React" : void 0,
|
|
5817
5777
|
sourceType: "module",
|
|
5818
5778
|
...typeAware && {
|
|
5819
5779
|
project: Array.isArray(tsconfig) ? tsconfig : [tsconfig],
|
|
@@ -5829,26 +5789,24 @@ function typescriptParser(options) {
|
|
|
5829
5789
|
//#region src/configs/ts/typescript.ts
|
|
5830
5790
|
const typescript = async (options) => {
|
|
5831
5791
|
dbg("typescript-options: %O", options);
|
|
5832
|
-
const { componentExts = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_MARKDOWN], overrides = {}, overridesTypeAware = {}, parserOptions = {}, prefix,
|
|
5792
|
+
const { componentExts = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_MARKDOWN], overrides = {}, overridesTypeAware = {}, parserOptions = {}, prefix, strict = false, tsconfig: tsconfigPath, typeAware = true } = options ?? {};
|
|
5793
|
+
const hasCustomTypeAwareScope = options?.filesTypeAware !== void 0 || options?.ignoresTypeAware !== void 0;
|
|
5833
5794
|
const parserConfigs = typeAware ? [typescriptParser({
|
|
5834
5795
|
filesTypeAware,
|
|
5835
5796
|
ignoresTypeAware,
|
|
5836
5797
|
parserOptions,
|
|
5837
|
-
react,
|
|
5838
5798
|
tsconfig: tsconfigPath,
|
|
5839
5799
|
typeAware: true
|
|
5840
|
-
}), typescriptParser({
|
|
5800
|
+
}), ...hasCustomTypeAwareScope ? [typescriptParser({
|
|
5841
5801
|
filesTypeAware,
|
|
5842
5802
|
ignoresTypeAware,
|
|
5843
5803
|
parserOptions,
|
|
5844
|
-
react,
|
|
5845
5804
|
tsconfig: tsconfigPath,
|
|
5846
5805
|
typeAware: false
|
|
5847
|
-
})] : [typescriptParser({
|
|
5806
|
+
})] : []] : [typescriptParser({
|
|
5848
5807
|
filesTypeAware,
|
|
5849
5808
|
ignoresTypeAware,
|
|
5850
5809
|
parserOptions,
|
|
5851
|
-
react,
|
|
5852
5810
|
tsconfig: tsconfigPath,
|
|
5853
5811
|
typeAware: false
|
|
5854
5812
|
})];
|
|
@@ -5896,7 +5854,7 @@ const typescript = async (options) => {
|
|
|
5896
5854
|
});
|
|
5897
5855
|
tsEslintConfigs.push({
|
|
5898
5856
|
files: ["**/*.d.ts"],
|
|
5899
|
-
name: "jsse/typescript
|
|
5857
|
+
name: "jsse/typescript/disables/dts",
|
|
5900
5858
|
rules: {
|
|
5901
5859
|
"eslint-comments/no-unlimited-disable": "off",
|
|
5902
5860
|
"import/no-duplicates": "off",
|
|
@@ -5905,14 +5863,14 @@ const typescript = async (options) => {
|
|
|
5905
5863
|
}
|
|
5906
5864
|
}, {
|
|
5907
5865
|
files: ["**/*.{test,spec}.ts?(x)"],
|
|
5908
|
-
name: "jsse/typescript
|
|
5866
|
+
name: "jsse/typescript/disables/test",
|
|
5909
5867
|
rules: {
|
|
5910
5868
|
"@typescript-eslint/no-unused-expressions": "off",
|
|
5911
5869
|
"no-unused-expressions": "off"
|
|
5912
5870
|
}
|
|
5913
5871
|
}, {
|
|
5914
5872
|
files: ["**/*.js", "**/*.cjs"],
|
|
5915
|
-
name: "jsse/typescript/
|
|
5873
|
+
name: "jsse/typescript/disables/js",
|
|
5916
5874
|
rules: {
|
|
5917
5875
|
"@typescript-eslint/no-require-imports": "off",
|
|
5918
5876
|
"@typescript-eslint/no-var-requires": "off"
|
|
@@ -5943,13 +5901,21 @@ function unicornRecommended(pluginUnicorn) {
|
|
|
5943
5901
|
if (rules === void 0) throw new Error("Expected rules to be defined in unicorn plugin");
|
|
5944
5902
|
return rules;
|
|
5945
5903
|
}
|
|
5946
|
-
|
|
5904
|
+
function unicornPresetRules(pluginUnicorn, preset) {
|
|
5905
|
+
switch (preset) {
|
|
5906
|
+
case "recommended": return unicornRecommended(pluginUnicorn);
|
|
5907
|
+
case "unopinionated": return pluginUnicorn.configs.unopinionated.rules ?? {};
|
|
5908
|
+
case "all": return pluginUnicorn.configs.all.rules ?? {};
|
|
5909
|
+
default: throw new Error(`Unknown preset: ${preset}`);
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
const unicorn = async ({ overrides = {}, preset = "recommended" } = {}) => {
|
|
5947
5913
|
return [{
|
|
5948
5914
|
files: GLOB_CODE,
|
|
5949
5915
|
name: "jsse/unicorn",
|
|
5950
5916
|
plugins: { unicorn: pluginUnicorn },
|
|
5951
5917
|
rules: {
|
|
5952
|
-
...
|
|
5918
|
+
...unicornPresetRules(pluginUnicorn, preset),
|
|
5953
5919
|
...unicornOff(),
|
|
5954
5920
|
"unicorn/better-regex": "error",
|
|
5955
5921
|
"unicorn/consistent-empty-array-spread": "error",
|
|
@@ -6003,7 +5969,8 @@ const unicorn = async () => {
|
|
|
6003
5969
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
6004
5970
|
"unicorn/prefer-string-trim-start-end": "error",
|
|
6005
5971
|
"unicorn/prefer-type-error": "error",
|
|
6006
|
-
"unicorn/throw-new-error": "error"
|
|
5972
|
+
"unicorn/throw-new-error": "error",
|
|
5973
|
+
...overrides
|
|
6007
5974
|
}
|
|
6008
5975
|
}, {
|
|
6009
5976
|
files: GLOB_TESTS,
|
|
@@ -12620,22 +12587,70 @@ quansync(function* (name, cwd) {
|
|
|
12620
12587
|
return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
|
|
12621
12588
|
}).sync;
|
|
12622
12589
|
//#endregion
|
|
12590
|
+
//#region src/const.ts
|
|
12591
|
+
/**
|
|
12592
|
+
* CONSTANTS LISTS AND REFERENCES OH MY!
|
|
12593
|
+
*/
|
|
12594
|
+
const isEnvDebug = () => {
|
|
12595
|
+
return [
|
|
12596
|
+
"DEBUG",
|
|
12597
|
+
"JSSE_DEBUG",
|
|
12598
|
+
"JSSEDEBUG"
|
|
12599
|
+
].some((env) => {
|
|
12600
|
+
const value = process$1.env[env];
|
|
12601
|
+
return [
|
|
12602
|
+
"1",
|
|
12603
|
+
"true",
|
|
12604
|
+
"t",
|
|
12605
|
+
"on",
|
|
12606
|
+
"yes",
|
|
12607
|
+
"y"
|
|
12608
|
+
].includes(value ?? "");
|
|
12609
|
+
});
|
|
12610
|
+
};
|
|
12611
|
+
const DEBUG = isEnvDebug();
|
|
12612
|
+
const SLOW_RULES = [
|
|
12613
|
+
"@typescript-eslint/no-misused-promises",
|
|
12614
|
+
"@typescript-eslint/no-redeclare",
|
|
12615
|
+
"@typescript-eslint/no-unsafe-assignment",
|
|
12616
|
+
"@typescript-eslint/no-unsafe-call",
|
|
12617
|
+
"@typescript-eslint/no-unsafe-member-access",
|
|
12618
|
+
"@typescript-eslint/no-unsafe-return",
|
|
12619
|
+
"import/no-duplicates",
|
|
12620
|
+
"jsdoc/check-access",
|
|
12621
|
+
"jsdoc/check-alignment",
|
|
12622
|
+
"jsdoc/check-property-names",
|
|
12623
|
+
"jsdoc/check-types",
|
|
12624
|
+
"jsdoc/empty-tags",
|
|
12625
|
+
"jsdoc/multiline-blocks",
|
|
12626
|
+
"jsdoc/no-multi-asterisks",
|
|
12627
|
+
"jsdoc/require-property-description",
|
|
12628
|
+
"jsdoc/require-property-name",
|
|
12629
|
+
"jsdoc/require-property",
|
|
12630
|
+
"unicorn/expiring-todo-comments",
|
|
12631
|
+
"unicorn/no-unnecessary-polyfills"
|
|
12632
|
+
];
|
|
12633
|
+
//#endregion
|
|
12623
12634
|
//#region src/options.ts
|
|
12624
12635
|
function defaultOptions() {
|
|
12625
12636
|
const typescriptExists = isPackageExists("typescript");
|
|
12626
12637
|
const vitestExists = isPackageExists("vitest");
|
|
12627
12638
|
return {
|
|
12639
|
+
antfu: true,
|
|
12628
12640
|
command: true,
|
|
12629
12641
|
componentExts: [],
|
|
12630
12642
|
debug: DEBUG && process$1.env.TEST !== "true",
|
|
12643
|
+
demorgan: true,
|
|
12631
12644
|
diagnostics: true,
|
|
12645
|
+
e18e: true,
|
|
12632
12646
|
fast: false,
|
|
12633
12647
|
gitignore: true,
|
|
12634
12648
|
isInEditor: isInEditor(),
|
|
12649
|
+
jsdoc: true,
|
|
12635
12650
|
jsonc: true,
|
|
12636
12651
|
markdown: false,
|
|
12652
|
+
n: true,
|
|
12637
12653
|
off: [],
|
|
12638
|
-
overrides: {},
|
|
12639
12654
|
pnpm: false,
|
|
12640
12655
|
prettier: true,
|
|
12641
12656
|
react: false,
|
|
@@ -12652,6 +12667,7 @@ function defaultOptions() {
|
|
|
12652
12667
|
tsPrefix: "@typescript-eslint",
|
|
12653
12668
|
typeAware: false,
|
|
12654
12669
|
typescript: typescriptExists,
|
|
12670
|
+
unicorn: true,
|
|
12655
12671
|
yaml: false
|
|
12656
12672
|
};
|
|
12657
12673
|
}
|
|
@@ -12739,8 +12755,9 @@ const FLAT_CFG_PROPS = [
|
|
|
12739
12755
|
* @returns Array of ESLint flat config items
|
|
12740
12756
|
*/
|
|
12741
12757
|
async function jsse(options = {}, ...userConfigs) {
|
|
12758
|
+
const startTime = process$1.hrtime.bigint();
|
|
12742
12759
|
const normalizedOptions = normalizeOptions(options);
|
|
12743
|
-
const { command:
|
|
12760
|
+
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, off, pnpm: pnpmOptions, prettier: enablePrettier, react: enableReact, regexp: enableRegexp, reportUnusedDisableDirectives, rootId, sortGeojson: enableSortGeojson, sortImports: enableSortImports, sortPackageJson: enableSortPackageJson, sortTsconfig: enableSortTsconfig, stylistic: stylisticOptions, tailwind: tailwindOptions, test: enableTest, tsPrefix, typescript: typescriptOptions, unicorn: unicornOptions, yaml: enableYaml } = normalizedOptions;
|
|
12744
12761
|
if (debug || process$1.argv.includes("--debug")) enableDbg();
|
|
12745
12762
|
dbg("@jsse/eslint-config debug=true");
|
|
12746
12763
|
dbg("@jsse/eslint-config isInEditor: %O", isInEditor);
|
|
@@ -12761,22 +12778,22 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12761
12778
|
}));
|
|
12762
12779
|
configs.push(ignores(), javascript({
|
|
12763
12780
|
isInEditor,
|
|
12764
|
-
|
|
12781
|
+
...javascriptOptions,
|
|
12765
12782
|
reportUnusedDisableDirectives
|
|
12766
|
-
}), eslintComments(), n(), jsdoc(), imports({ stylistic: stylisticOptions }), unicorn(), antfu(), deMorgan(), e18e());
|
|
12783
|
+
}), eslintComments(), ...nOptions ? [n(typeof nOptions === "object" ? nOptions : void 0)] : [], ...jsdocOptions ? [jsdoc(typeof jsdocOptions === "object" ? jsdocOptions : void 0)] : [], imports({ stylistic: stylisticOptions }), ...unicornOptions ? [unicorn(typeof unicornOptions === "object" ? unicornOptions : {})] : [], ...antfuOptions ? [antfu(typeof antfuOptions === "object" ? antfuOptions : void 0)] : [], ...deMorganOptions ? [deMorgan(typeof deMorganOptions === "object" ? deMorganOptions : void 0)] : [], ...e18eOptions ? [e18e(typeof e18eOptions === "object" ? e18eOptions : {})] : []);
|
|
12767
12784
|
if (enableSortImports) configs.push(perfectionist());
|
|
12768
12785
|
/**
|
|
12769
12786
|
* =========================================================================
|
|
12770
12787
|
* COMMAND
|
|
12771
12788
|
* ========================================================================
|
|
12772
12789
|
*/
|
|
12773
|
-
if (
|
|
12790
|
+
if (commandOptions) configs.push(command(typeof commandOptions === "object" ? commandOptions : void 0));
|
|
12774
12791
|
/**
|
|
12775
12792
|
* =========================================================================
|
|
12776
12793
|
* PNPM
|
|
12777
12794
|
* ========================================================================
|
|
12778
12795
|
*/
|
|
12779
|
-
if (
|
|
12796
|
+
if (pnpmOptions) configs.push(pnpm(typeof pnpmOptions === "object" ? pnpmOptions : void 0));
|
|
12780
12797
|
/**
|
|
12781
12798
|
* =========================================================================
|
|
12782
12799
|
* TYPESCRIPT
|
|
@@ -12788,13 +12805,10 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12788
12805
|
const tscfg = typescript({
|
|
12789
12806
|
...typeof typescriptOptions !== "boolean" && typescriptOptions,
|
|
12790
12807
|
componentExts,
|
|
12791
|
-
overrides: overrides.typescript,
|
|
12792
|
-
overridesTypeAware: typeof typescriptOptions === "object" ? typescriptOptions.overridesTypeAware : void 0,
|
|
12793
12808
|
prefix: {
|
|
12794
12809
|
from: "@typescript-eslint",
|
|
12795
12810
|
to: tsPrefix ?? "@typescript-eslint"
|
|
12796
12811
|
},
|
|
12797
|
-
react: enableReact,
|
|
12798
12812
|
typeAware: effectiveTypeAware
|
|
12799
12813
|
});
|
|
12800
12814
|
configs.push(tscfg);
|
|
@@ -12802,26 +12816,35 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12802
12816
|
ignores: [GLOB_TS, GLOB_TSX],
|
|
12803
12817
|
name: "jsse/ignores/typescript-disabled"
|
|
12804
12818
|
}]);
|
|
12805
|
-
if (enableMarkdown) configs.push(markdown(
|
|
12819
|
+
if (enableMarkdown) configs.push(markdown({
|
|
12820
|
+
componentExts,
|
|
12821
|
+
...typeof enableMarkdown === "object" && enableMarkdown
|
|
12822
|
+
}));
|
|
12806
12823
|
if (enableYaml) {
|
|
12807
|
-
const ymlConfig = yml();
|
|
12824
|
+
const ymlConfig = yml(typeof enableYaml === "object" ? enableYaml : void 0);
|
|
12808
12825
|
configs.push(ymlConfig);
|
|
12809
12826
|
}
|
|
12810
|
-
if (enableReact) configs.push(eslintReact({
|
|
12827
|
+
if (enableReact) configs.push(eslintReact({
|
|
12828
|
+
...typeof enableReact === "object" && enableReact,
|
|
12829
|
+
reactRefresh: typeof enableReact === "object" && enableReact.reactRefresh !== void 0 ? enableReact.reactRefresh : normalizedOptions.reactRefresh !== false
|
|
12830
|
+
}));
|
|
12811
12831
|
if (enablePrettier) configs.push(prettier());
|
|
12812
12832
|
if (stylisticOptions) configs.push(stylistic(stylisticOptions === true ? {} : stylisticOptions));
|
|
12813
12833
|
if (enableRegexp) configs.push(regexp());
|
|
12814
12834
|
if (enableTest) configs.push(vitest({
|
|
12815
12835
|
isInEditor,
|
|
12816
|
-
|
|
12836
|
+
...typeof enableTest === "object" && enableTest
|
|
12817
12837
|
}), noOnlyTests({ isInEditor }));
|
|
12818
12838
|
if (enableJsonc) {
|
|
12819
12839
|
configs.push(jsonc({
|
|
12820
|
-
|
|
12821
|
-
|
|
12840
|
+
stylistic: stylisticOptions,
|
|
12841
|
+
...typeof enableJsonc === "object" && enableJsonc
|
|
12822
12842
|
}));
|
|
12823
12843
|
if (enableSortPackageJson) configs.push(sortPackageJson());
|
|
12824
|
-
if (enableSortTsconfig) configs.push(sortTsconfig({
|
|
12844
|
+
if (enableSortTsconfig) configs.push(sortTsconfig({
|
|
12845
|
+
extendTsconfigGlobs: typeof enableSortTsconfig === "object" ? enableSortTsconfig.extendTsconfigGlobs : normalizedOptions.extendTsconfigLintGlobs,
|
|
12846
|
+
...typeof enableSortTsconfig === "object" && enableSortTsconfig
|
|
12847
|
+
}));
|
|
12825
12848
|
if (enableSortGeojson) configs.push(sortGeojson());
|
|
12826
12849
|
}
|
|
12827
12850
|
if (tailwindOptions) console.error("Tailwind configuration is deprecated...");
|
|
@@ -12843,22 +12866,16 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12843
12866
|
const res = await normalizedOptions.preReturn(finalizedConfigs);
|
|
12844
12867
|
dbg("preReturn finished");
|
|
12845
12868
|
dbg("final config", res);
|
|
12869
|
+
const endTime = process$1.hrtime.bigint();
|
|
12870
|
+
dbg("defineConfig completed in %d ms", Number(endTime - startTime) / 1e6);
|
|
12846
12871
|
return res;
|
|
12847
12872
|
}
|
|
12873
|
+
const endTime = process$1.hrtime.bigint();
|
|
12874
|
+
dbg("defineConfig completed in %d ms", Number(endTime - startTime) / 1e6);
|
|
12848
12875
|
return finalizedConfigs;
|
|
12849
12876
|
}
|
|
12850
12877
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
12851
12878
|
return jsse(options, ...userConfigs);
|
|
12852
12879
|
}
|
|
12853
12880
|
//#endregion
|
|
12854
|
-
|
|
12855
|
-
const jsseReact = (options, ...configs) => {
|
|
12856
|
-
return jsse({
|
|
12857
|
-
react: true,
|
|
12858
|
-
reactRefresh: true,
|
|
12859
|
-
typescript: { tsconfig: ["./tsconfig.json", "./tsconfig.eslint.json"] },
|
|
12860
|
-
...options
|
|
12861
|
-
}, ...configs);
|
|
12862
|
-
};
|
|
12863
|
-
//#endregion
|
|
12864
|
-
export { SLOW_RULES, VERSION, changeRuleEntrySeverity, combine, combineAsync, jsse as default, jsse, defaultOptions, defineConfig, error2warn, globs_exports as globs, importPluginMarkdown, importPluginReact, importPluginReactRefresh, importPluginStylistic, interopDefault, isCI, isInEditor, jsseReact, normalizeOptions, parserPlain, parserTs, pluginAntfu, pluginDeMorgan, pluginE18e, pluginEslintComments, pluginImportLite, pluginN, pluginPerfectionist, pluginPnpm, pluginRegexp, pluginTs, pluginUnicorn, pluginUnusedImports, renameRules, replaceTypescriptEslintPrefixInplace, scopeTypeScriptRules, turnOffRules, uniqueStrings, warn2error };
|
|
12881
|
+
export { FIXABLE_RULES_MAP, VERSION, jsse as default, jsse, defaultOptions, defineConfig, globs_exports as globs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/cli.ts","../src/config-registry.test.ts","../src/config-registry.ts","../src/const.ts","../src/define-config.ts","../src/fixable.test.ts","../src/fixable.ts","../src/globs.ts","../src/index.ts","../src/lager.ts","../src/options.test.ts","../src/options.ts","../src/plugin-registry.test.ts","../src/plugin-registry.ts","../src/plugins.ts","../src/postprocess.test.ts","../src/postprocess.ts","../src/
|
|
1
|
+
{"root":["../src/cli.ts","../src/config-registry.test.ts","../src/config-registry.ts","../src/const.ts","../src/define-config.ts","../src/fixable.test.ts","../src/fixable.ts","../src/globs.ts","../src/index.ts","../src/lager.ts","../src/options.test.ts","../src/options.ts","../src/plugin-registry.test.ts","../src/plugin-registry.ts","../src/plugins.ts","../src/postprocess.test.ts","../src/postprocess.ts","../src/types.ts","../src/utils.ts","../src/_generated/fixable-rules-map.ts","../src/_generated/rule-options.d.ts","../src/_generated/version.ts","../src/_generated/dts/antfu.d.ts","../src/_generated/dts/builtins.d.ts","../src/_generated/dts/command.d.ts","../src/_generated/dts/de-morgan.d.ts","../src/_generated/dts/e18e.d.ts","../src/_generated/dts/eslint-comments.d.ts","../src/_generated/dts/eslint-react.d.ts","../src/_generated/dts/ignores.d.ts","../src/_generated/dts/imports.d.ts","../src/_generated/dts/javascript.d.ts","../src/_generated/dts/jsdoc.d.ts","../src/_generated/dts/jsonc.d.ts","../src/_generated/dts/markdown.d.ts","../src/_generated/dts/n.d.ts","../src/_generated/dts/no-only-tests.d.ts","../src/_generated/dts/perfectionist.d.ts","../src/_generated/dts/pnpm.d.ts","../src/_generated/dts/prettier.d.ts","../src/_generated/dts/react-hooks.d.ts","../src/_generated/dts/regexp.d.ts","../src/_generated/dts/sort-package-json.d.ts","../src/_generated/dts/sort-tsconfig.d.ts","../src/_generated/dts/stylistic.d.ts","../src/_generated/dts/toml.d.ts","../src/_generated/dts/typescript.d.ts","../src/_generated/dts/unicorn.d.ts","../src/_generated/dts/vitest.d.ts","../src/_generated/dts/yml.d.ts","../src/configs/_template.ts","../src/configs/antfu.ts","../src/configs/command.ts","../src/configs/de-morgan.ts","../src/configs/disables.ts","../src/configs/e18e.ts","../src/configs/eslint-comments.ts","../src/configs/eslint-react.ts","../src/configs/ignores.ts","../src/configs/imports.ts","../src/configs/javascript.ts","../src/configs/jsdoc.ts","../src/configs/jsonc.ts","../src/configs/markdown.ts","../src/configs/n.ts","../src/configs/no-only-tests.ts","../src/configs/perfectionist.ts","../src/configs/pnpm.ts","../src/configs/prettier.ts","../src/configs/react-hooks.ts","../src/configs/regexp.ts","../src/configs/rules.test.ts","../src/configs/sort-geojson.ts","../src/configs/sort-package-json.ts","../src/configs/sort-tsconfig.ts","../src/configs/stylistic.ts","../src/configs/toml.ts","../src/configs/tsdoc.ts","../src/configs/unicorn.ts","../src/configs/vitest.ts","../src/configs/yml.ts","../src/configs/ts/parser.ts","../src/configs/ts/requires-type-checking.ts","../src/configs/ts/typescript-rules.ts","../src/configs/ts/typescript.ts"],"version":"6.0.3"}
|