@so1ve/eslint-config 3.23.0 → 3.24.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/dist/index.d.mts +3 -3
- package/dist/index.mjs +217 -116
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -16358,10 +16358,10 @@ interface Options extends OptionsComponentExts {
|
|
|
16358
16358
|
/**
|
|
16359
16359
|
* Extend the global ignores.
|
|
16360
16360
|
*
|
|
16361
|
-
* Passing an array to extends the ignores.
|
|
16362
|
-
*
|
|
16361
|
+
* Passing an array to extends the ignores. Passing a function to modify the
|
|
16362
|
+
* default ignores.
|
|
16363
16363
|
*
|
|
16364
|
-
* @default []
|
|
16364
|
+
* @default [ ]
|
|
16365
16365
|
*/
|
|
16366
16366
|
ignores?: string[] | ((originals: string[]) => string[]);
|
|
16367
16367
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -13,10 +13,10 @@ import * as pluginRegexp from "eslint-plugin-regexp";
|
|
|
13
13
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
14
14
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
15
15
|
import globals from "globals";
|
|
16
|
-
import
|
|
16
|
+
import fsPromises from "node:fs/promises";
|
|
17
17
|
import process$1 from "node:process";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
|
-
import fs
|
|
19
|
+
import fs from "node:fs";
|
|
20
20
|
import path from "node:path";
|
|
21
21
|
import tseslint from "typescript-eslint";
|
|
22
22
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
@@ -246,6 +246,59 @@ async function formatting(options) {
|
|
|
246
246
|
files: [GLOB_PACKAGEJSON],
|
|
247
247
|
rules: { "jsonc/sort-keys": [
|
|
248
248
|
"error",
|
|
249
|
+
{
|
|
250
|
+
pathPattern: "^$",
|
|
251
|
+
order: [
|
|
252
|
+
"name",
|
|
253
|
+
"displayName",
|
|
254
|
+
"private",
|
|
255
|
+
"preview",
|
|
256
|
+
"version",
|
|
257
|
+
"packageManager",
|
|
258
|
+
"publisher",
|
|
259
|
+
"author",
|
|
260
|
+
"contributors",
|
|
261
|
+
"type",
|
|
262
|
+
"description",
|
|
263
|
+
"keywords",
|
|
264
|
+
"homepage",
|
|
265
|
+
"repository",
|
|
266
|
+
"bugs",
|
|
267
|
+
"funding",
|
|
268
|
+
"categories",
|
|
269
|
+
"license",
|
|
270
|
+
"sideEffects",
|
|
271
|
+
"exports",
|
|
272
|
+
"bin",
|
|
273
|
+
"main",
|
|
274
|
+
"module",
|
|
275
|
+
"browser",
|
|
276
|
+
"unpkg",
|
|
277
|
+
"jsdelivr",
|
|
278
|
+
"types",
|
|
279
|
+
"typesVersions",
|
|
280
|
+
"icon",
|
|
281
|
+
"files",
|
|
282
|
+
"engines",
|
|
283
|
+
"extensionKind",
|
|
284
|
+
"activationEvents",
|
|
285
|
+
"contributes",
|
|
286
|
+
"eslintConfig",
|
|
287
|
+
"publishConfig",
|
|
288
|
+
"scripts",
|
|
289
|
+
"husky",
|
|
290
|
+
"simple-git-hooks",
|
|
291
|
+
"lint-staged",
|
|
292
|
+
"dependencies",
|
|
293
|
+
"devDependencies",
|
|
294
|
+
"optionalDependencies",
|
|
295
|
+
"peerDependencies",
|
|
296
|
+
"peerDependenciesMeta",
|
|
297
|
+
"pnpm",
|
|
298
|
+
"overrides",
|
|
299
|
+
"resolutions"
|
|
300
|
+
]
|
|
301
|
+
},
|
|
249
302
|
{
|
|
250
303
|
pathPattern: "^exports$",
|
|
251
304
|
order: { type: "asc" }
|
|
@@ -258,122 +311,170 @@ async function formatting(options) {
|
|
|
258
311
|
"import",
|
|
259
312
|
"default"
|
|
260
313
|
]
|
|
261
|
-
}
|
|
262
|
-
] }
|
|
263
|
-
}, {
|
|
264
|
-
name: "so1ve/formatting/rules/sort-tsconfig",
|
|
265
|
-
files: GLOB_TSCONFIG,
|
|
266
|
-
rules: { "jsonc/sort-keys": [
|
|
267
|
-
"error",
|
|
314
|
+
},
|
|
268
315
|
{
|
|
269
|
-
pathPattern: "
|
|
270
|
-
order:
|
|
271
|
-
"extends",
|
|
272
|
-
"compilerOptions",
|
|
273
|
-
"references",
|
|
274
|
-
"files",
|
|
275
|
-
"include",
|
|
276
|
-
"exclude"
|
|
277
|
-
]
|
|
316
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
|
|
317
|
+
order: { type: "asc" }
|
|
278
318
|
},
|
|
279
319
|
{
|
|
280
|
-
pathPattern: "^
|
|
281
|
-
order:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
"disableSolutionSearching",
|
|
287
|
-
"disableReferencedProjectLoad",
|
|
288
|
-
"target",
|
|
289
|
-
"jsx",
|
|
290
|
-
"jsxFactory",
|
|
291
|
-
"jsxFragmentFactory",
|
|
292
|
-
"jsxImportSource",
|
|
293
|
-
"lib",
|
|
294
|
-
"moduleDetection",
|
|
295
|
-
"noLib",
|
|
296
|
-
"reactNamespace",
|
|
297
|
-
"useDefineForClassFields",
|
|
298
|
-
"emitDecoratorMetadata",
|
|
299
|
-
"experimentalDecorators",
|
|
300
|
-
"baseUrl",
|
|
301
|
-
"rootDir",
|
|
302
|
-
"rootDirs",
|
|
303
|
-
"customConditions",
|
|
304
|
-
"module",
|
|
305
|
-
"moduleResolution",
|
|
306
|
-
"moduleSuffixes",
|
|
307
|
-
"noResolve",
|
|
308
|
-
"resolveJsonModule",
|
|
309
|
-
"resolvePackageJsonExports",
|
|
310
|
-
"resolvePackageJsonImports",
|
|
311
|
-
"typeRoots",
|
|
312
|
-
"types",
|
|
313
|
-
"allowArbitraryExtensions",
|
|
314
|
-
"allowImportingTsExtensions",
|
|
315
|
-
"allowUmdGlobalAccess",
|
|
316
|
-
"allowJs",
|
|
317
|
-
"checkJs",
|
|
318
|
-
"maxNodeModuleJsDepth",
|
|
319
|
-
"strict",
|
|
320
|
-
"strictBindCallApply",
|
|
321
|
-
"strictFunctionTypes",
|
|
322
|
-
"strictNullChecks",
|
|
323
|
-
"strictPropertyInitialization",
|
|
324
|
-
"allowUnreachableCode",
|
|
325
|
-
"allowUnusedLabels",
|
|
326
|
-
"alwaysStrict",
|
|
327
|
-
"exactOptionalPropertyTypes",
|
|
328
|
-
"noFallthroughCasesInSwitch",
|
|
329
|
-
"noImplicitAny",
|
|
330
|
-
"noImplicitOverride",
|
|
331
|
-
"noImplicitReturns",
|
|
332
|
-
"noImplicitThis",
|
|
333
|
-
"noPropertyAccessFromIndexSignature",
|
|
334
|
-
"noUncheckedIndexedAccess",
|
|
335
|
-
"noUnusedLocals",
|
|
336
|
-
"noUnusedParameters",
|
|
337
|
-
"useUnknownInCatchVariables",
|
|
338
|
-
"declaration",
|
|
339
|
-
"declarationDir",
|
|
340
|
-
"declarationMap",
|
|
341
|
-
"downlevelIteration",
|
|
342
|
-
"emitBOM",
|
|
343
|
-
"emitDeclarationOnly",
|
|
344
|
-
"importHelpers",
|
|
345
|
-
"importsNotUsedAsValues",
|
|
346
|
-
"inlineSourceMap",
|
|
347
|
-
"inlineSources",
|
|
348
|
-
"mapRoot",
|
|
349
|
-
"newLine",
|
|
350
|
-
"noEmit",
|
|
351
|
-
"noEmitHelpers",
|
|
352
|
-
"noEmitOnError",
|
|
353
|
-
"outDir",
|
|
354
|
-
"outFile",
|
|
355
|
-
"preserveConstEnums",
|
|
356
|
-
"preserveValueImports",
|
|
357
|
-
"removeComments",
|
|
358
|
-
"sourceMap",
|
|
359
|
-
"sourceRoot",
|
|
360
|
-
"stripInternal",
|
|
361
|
-
"allowSyntheticDefaultImports",
|
|
362
|
-
"esModuleInterop",
|
|
363
|
-
"forceConsistentCasingInFileNames",
|
|
364
|
-
"isolatedModules",
|
|
365
|
-
"preserveSymlinks",
|
|
366
|
-
"verbatimModuleSyntax",
|
|
367
|
-
"skipDefaultLibCheck",
|
|
368
|
-
"skipLibCheck",
|
|
369
|
-
"paths"
|
|
370
|
-
]
|
|
320
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$",
|
|
321
|
+
order: { type: "asc" }
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
pathPattern: "^workspaces\\.catalog$",
|
|
325
|
+
order: { type: "asc" }
|
|
371
326
|
},
|
|
372
327
|
{
|
|
373
|
-
pathPattern: "^
|
|
328
|
+
pathPattern: "^workspaces\\.catalogs\\.[^.]+$",
|
|
374
329
|
order: { type: "asc" }
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$",
|
|
333
|
+
order: [
|
|
334
|
+
"pre-commit",
|
|
335
|
+
"prepare-commit-msg",
|
|
336
|
+
"commit-msg",
|
|
337
|
+
"post-commit",
|
|
338
|
+
"pre-rebase",
|
|
339
|
+
"post-rewrite",
|
|
340
|
+
"post-checkout",
|
|
341
|
+
"post-merge",
|
|
342
|
+
"pre-push",
|
|
343
|
+
"pre-auto-gc"
|
|
344
|
+
]
|
|
375
345
|
}
|
|
376
346
|
] }
|
|
347
|
+
}, {
|
|
348
|
+
name: "so1ve/formatting/rules/sort-tsconfig",
|
|
349
|
+
files: GLOB_TSCONFIG,
|
|
350
|
+
rules: {
|
|
351
|
+
"jsonc/sort-array-values": [
|
|
352
|
+
"error",
|
|
353
|
+
{
|
|
354
|
+
pathPattern: "^compilerOptions\\.types$",
|
|
355
|
+
order: { type: "asc" }
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
pathPattern: "^include$",
|
|
359
|
+
order: { type: "asc" }
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
pathPattern: "^exclude$",
|
|
363
|
+
order: { type: "asc" }
|
|
364
|
+
}
|
|
365
|
+
],
|
|
366
|
+
"jsonc/sort-keys": [
|
|
367
|
+
"error",
|
|
368
|
+
{
|
|
369
|
+
pathPattern: "^$",
|
|
370
|
+
order: [
|
|
371
|
+
"extends",
|
|
372
|
+
"compilerOptions",
|
|
373
|
+
"references",
|
|
374
|
+
"files",
|
|
375
|
+
"include",
|
|
376
|
+
"exclude"
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
pathPattern: "^compilerOptions$",
|
|
381
|
+
order: [
|
|
382
|
+
"incremental",
|
|
383
|
+
"composite",
|
|
384
|
+
"tsBuildInfoFile",
|
|
385
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
386
|
+
"disableSolutionSearching",
|
|
387
|
+
"disableReferencedProjectLoad",
|
|
388
|
+
"target",
|
|
389
|
+
"jsx",
|
|
390
|
+
"jsxFactory",
|
|
391
|
+
"jsxFragmentFactory",
|
|
392
|
+
"jsxImportSource",
|
|
393
|
+
"lib",
|
|
394
|
+
"moduleDetection",
|
|
395
|
+
"noLib",
|
|
396
|
+
"reactNamespace",
|
|
397
|
+
"useDefineForClassFields",
|
|
398
|
+
"emitDecoratorMetadata",
|
|
399
|
+
"experimentalDecorators",
|
|
400
|
+
"baseUrl",
|
|
401
|
+
"rootDir",
|
|
402
|
+
"rootDirs",
|
|
403
|
+
"customConditions",
|
|
404
|
+
"module",
|
|
405
|
+
"moduleResolution",
|
|
406
|
+
"moduleSuffixes",
|
|
407
|
+
"noResolve",
|
|
408
|
+
"resolveJsonModule",
|
|
409
|
+
"resolvePackageJsonExports",
|
|
410
|
+
"resolvePackageJsonImports",
|
|
411
|
+
"typeRoots",
|
|
412
|
+
"types",
|
|
413
|
+
"allowArbitraryExtensions",
|
|
414
|
+
"allowImportingTsExtensions",
|
|
415
|
+
"allowUmdGlobalAccess",
|
|
416
|
+
"allowJs",
|
|
417
|
+
"checkJs",
|
|
418
|
+
"maxNodeModuleJsDepth",
|
|
419
|
+
"strict",
|
|
420
|
+
"strictBindCallApply",
|
|
421
|
+
"strictFunctionTypes",
|
|
422
|
+
"strictNullChecks",
|
|
423
|
+
"strictPropertyInitialization",
|
|
424
|
+
"allowUnreachableCode",
|
|
425
|
+
"allowUnusedLabels",
|
|
426
|
+
"alwaysStrict",
|
|
427
|
+
"exactOptionalPropertyTypes",
|
|
428
|
+
"noFallthroughCasesInSwitch",
|
|
429
|
+
"noImplicitAny",
|
|
430
|
+
"noImplicitOverride",
|
|
431
|
+
"noImplicitReturns",
|
|
432
|
+
"noImplicitThis",
|
|
433
|
+
"noPropertyAccessFromIndexSignature",
|
|
434
|
+
"noUncheckedIndexedAccess",
|
|
435
|
+
"noUnusedLocals",
|
|
436
|
+
"noUnusedParameters",
|
|
437
|
+
"useUnknownInCatchVariables",
|
|
438
|
+
"declaration",
|
|
439
|
+
"declarationDir",
|
|
440
|
+
"declarationMap",
|
|
441
|
+
"downlevelIteration",
|
|
442
|
+
"emitBOM",
|
|
443
|
+
"emitDeclarationOnly",
|
|
444
|
+
"importHelpers",
|
|
445
|
+
"importsNotUsedAsValues",
|
|
446
|
+
"inlineSourceMap",
|
|
447
|
+
"inlineSources",
|
|
448
|
+
"mapRoot",
|
|
449
|
+
"newLine",
|
|
450
|
+
"noEmit",
|
|
451
|
+
"noEmitHelpers",
|
|
452
|
+
"noEmitOnError",
|
|
453
|
+
"outDir",
|
|
454
|
+
"outFile",
|
|
455
|
+
"preserveConstEnums",
|
|
456
|
+
"preserveValueImports",
|
|
457
|
+
"removeComments",
|
|
458
|
+
"sourceMap",
|
|
459
|
+
"sourceRoot",
|
|
460
|
+
"stripInternal",
|
|
461
|
+
"allowSyntheticDefaultImports",
|
|
462
|
+
"esModuleInterop",
|
|
463
|
+
"forceConsistentCasingInFileNames",
|
|
464
|
+
"isolatedModules",
|
|
465
|
+
"preserveSymlinks",
|
|
466
|
+
"verbatimModuleSyntax",
|
|
467
|
+
"skipDefaultLibCheck",
|
|
468
|
+
"skipLibCheck",
|
|
469
|
+
"paths"
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
pathPattern: "^compilerOptions\\.paths$",
|
|
474
|
+
order: { type: "asc" }
|
|
475
|
+
}
|
|
476
|
+
]
|
|
477
|
+
}
|
|
377
478
|
}],
|
|
378
479
|
(options?.test ?? true) && {
|
|
379
480
|
name: "so1ve/formatting/rules/test",
|
|
@@ -516,7 +617,7 @@ async function javascript({ overrides } = {}) {
|
|
|
516
617
|
{
|
|
517
618
|
name: "so1ve/javascript/rules",
|
|
518
619
|
languageOptions: {
|
|
519
|
-
ecmaVersion:
|
|
620
|
+
ecmaVersion: "latest",
|
|
520
621
|
globals: {
|
|
521
622
|
...globals.browser,
|
|
522
623
|
...globals.es2021,
|
|
@@ -527,7 +628,7 @@ async function javascript({ overrides } = {}) {
|
|
|
527
628
|
},
|
|
528
629
|
parserOptions: {
|
|
529
630
|
ecmaFeatures: { jsx: true },
|
|
530
|
-
ecmaVersion:
|
|
631
|
+
ecmaVersion: "latest",
|
|
531
632
|
sourceType: "module"
|
|
532
633
|
},
|
|
533
634
|
sourceType: "module"
|
|
@@ -954,7 +1055,7 @@ async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {
|
|
|
954
1055
|
while (directory) {
|
|
955
1056
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
956
1057
|
try {
|
|
957
|
-
const stats = await
|
|
1058
|
+
const stats = await fsPromises.stat(filePath);
|
|
958
1059
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
959
1060
|
} catch {}
|
|
960
1061
|
if (directory === stopAt || directory === root) break;
|
|
@@ -969,7 +1070,7 @@ function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {})
|
|
|
969
1070
|
while (directory) {
|
|
970
1071
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
971
1072
|
try {
|
|
972
|
-
const stats = fs
|
|
1073
|
+
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
973
1074
|
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
974
1075
|
} catch {}
|
|
975
1076
|
if (directory === stopAt || directory === root) break;
|
|
@@ -982,7 +1083,7 @@ function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {})
|
|
|
982
1083
|
async function detectCatalogUsage() {
|
|
983
1084
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
984
1085
|
if (!workspaceFile) return false;
|
|
985
|
-
const yaml$1 = await
|
|
1086
|
+
const yaml$1 = await fsPromises.readFile(workspaceFile, "utf-8");
|
|
986
1087
|
return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
|
|
987
1088
|
}
|
|
988
1089
|
async function pnpm(options) {
|
|
@@ -1729,7 +1830,7 @@ function so1ve(options = {}, ...userConfigs) {
|
|
|
1729
1830
|
const { astro: enableAstro = isPackageExists("astro"), componentExts = [], gitignore: enableGitignore = true, ignores: userIgnores = [], pnpm: enablePnpm = !!findUpSync("pnpm-workspace.yaml"), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
1730
1831
|
const configs = [];
|
|
1731
1832
|
if (enableGitignore) if (typeof enableGitignore === "boolean") {
|
|
1732
|
-
if (fs
|
|
1833
|
+
if (fs.existsSync(".gitignore")) configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1733
1834
|
} else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1734
1835
|
configs.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command());
|
|
1735
1836
|
if (enablePnpm) configs.push(pnpm({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@so1ve/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Ray's eslint config.",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"typescript-eslint": "^8.50.1",
|
|
77
77
|
"vue-eslint-parser": "^10.2.0",
|
|
78
78
|
"yaml-eslint-parser": "^1.3.2",
|
|
79
|
-
"@so1ve/eslint-plugin": "3.
|
|
80
|
-
"@so1ve/eslint-plugin-sort-imports": "3.
|
|
79
|
+
"@so1ve/eslint-plugin": "3.24.0",
|
|
80
|
+
"@so1ve/eslint-plugin-sort-imports": "3.24.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"find-up-simple": "^1.0.1"
|