@w5s/eslint-config 3.13.0 → 3.16.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.ts +402 -69
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +419 -135
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
- package/src/config/jsdoc.ts +48 -13
- package/src/config/jsonc.ts +1 -1
- package/src/config/jsx.ts +51 -0
- package/src/config/react.ts +4 -2
- package/src/config/ts.ts +39 -2
- package/src/config/yml.ts +1 -1
- package/src/config.ts +1 -0
- package/src/defineConfig.ts +4 -1
- package/src/glob.ts +2 -0
- package/src/rules/esRules/bestPractices.ts +4 -4
- package/src/rules/esRules/errors.ts +7 -7
- package/src/rules/esRules/es6.ts +35 -35
- package/src/rules/esRules/overrides.ts +1 -1
- package/src/rules/esStylistic.ts +98 -0
- package/src/rules/tsRules.ts +1 -63
- package/src/typegen/jsx-a11y.d.ts +427 -0
package/dist/index.js
CHANGED
|
@@ -4,9 +4,13 @@ import eslintConfig from "@eslint/js";
|
|
|
4
4
|
import globals from "globals";
|
|
5
5
|
import { eslintIgnores } from "@w5s/eslint-config-ignore";
|
|
6
6
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
//#endregion
|
|
7
10
|
//#region src/glob.ts
|
|
8
11
|
const sourceGlob$1 = `**/${Project.extensionsToGlob(Project.sourceExtensions())}`;
|
|
9
12
|
const esSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["javascript", "javascriptreact"]))}`;
|
|
13
|
+
const jsxSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["javascriptreact", "typescriptreact"]))}`;
|
|
10
14
|
const jsonSourceGlob = `**/${Project.extensionsToGlob([
|
|
11
15
|
".json",
|
|
12
16
|
".json5",
|
|
@@ -102,7 +106,6 @@ const bestPractices = () => ({
|
|
|
102
106
|
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
103
107
|
"default-case-last": "error",
|
|
104
108
|
"default-param-last": "error",
|
|
105
|
-
"dot-location": ["error", "property"],
|
|
106
109
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
107
110
|
"eqeqeq": [
|
|
108
111
|
"error",
|
|
@@ -155,7 +158,6 @@ const bestPractices = () => ({
|
|
|
155
158
|
ignore: [],
|
|
156
159
|
ignoreArrayIndexes: true
|
|
157
160
|
}],
|
|
158
|
-
"no-multi-spaces": ["error", { ignoreEOLComments: false }],
|
|
159
161
|
"no-multi-str": "error",
|
|
160
162
|
"no-native-reassign": "off",
|
|
161
163
|
"no-new": "error",
|
|
@@ -300,17 +302,6 @@ const errors = () => ({
|
|
|
300
302
|
"no-empty-character-class": "error",
|
|
301
303
|
"no-ex-assign": "error",
|
|
302
304
|
"no-extra-boolean-cast": "error",
|
|
303
|
-
"no-extra-parens": [
|
|
304
|
-
"off",
|
|
305
|
-
"all",
|
|
306
|
-
{
|
|
307
|
-
conditionalAssign: true,
|
|
308
|
-
enforceForArrowConditionals: false,
|
|
309
|
-
ignoreJSX: "all",
|
|
310
|
-
nestedBinaryExpressions: false,
|
|
311
|
-
returnAssign: false
|
|
312
|
-
}
|
|
313
|
-
],
|
|
314
305
|
"no-extra-semi": "error",
|
|
315
306
|
"no-func-assign": "error",
|
|
316
307
|
"no-import-assign": "error",
|
|
@@ -344,21 +335,7 @@ const errors = () => ({
|
|
|
344
335
|
//#endregion
|
|
345
336
|
//#region src/rules/esRules/es6.ts
|
|
346
337
|
const es6 = () => ({
|
|
347
|
-
"arrow-body-style": [
|
|
348
|
-
"error",
|
|
349
|
-
"as-needed",
|
|
350
|
-
{ requireReturnForObjectLiteral: false }
|
|
351
|
-
],
|
|
352
|
-
"arrow-parens": ["error", "always"],
|
|
353
|
-
"arrow-spacing": ["error", {
|
|
354
|
-
after: true,
|
|
355
|
-
before: true
|
|
356
|
-
}],
|
|
357
338
|
"constructor-super": "error",
|
|
358
|
-
"generator-star-spacing": ["error", {
|
|
359
|
-
after: true,
|
|
360
|
-
before: false
|
|
361
|
-
}],
|
|
362
339
|
"no-class-assign": "error",
|
|
363
340
|
"no-confusing-arrow": ["error", { allowParens: true }],
|
|
364
341
|
"no-const-assign": "error",
|
|
@@ -379,57 +356,17 @@ const es6 = () => ({
|
|
|
379
356
|
ignoreImport: false
|
|
380
357
|
}],
|
|
381
358
|
"no-var": "error",
|
|
382
|
-
"object-shorthand": [
|
|
383
|
-
"error",
|
|
384
|
-
"always",
|
|
385
|
-
{
|
|
386
|
-
avoidQuotes: true,
|
|
387
|
-
ignoreConstructors: false
|
|
388
|
-
}
|
|
389
|
-
],
|
|
390
|
-
"prefer-arrow-callback": ["error", {
|
|
391
|
-
allowNamedFunctions: false,
|
|
392
|
-
allowUnboundThis: true
|
|
393
|
-
}],
|
|
394
359
|
"prefer-const": ["error", {
|
|
395
360
|
destructuring: "any",
|
|
396
361
|
ignoreReadBeforeAssign: true
|
|
397
362
|
}],
|
|
398
|
-
"prefer-destructuring": [
|
|
399
|
-
"error",
|
|
400
|
-
{
|
|
401
|
-
AssignmentExpression: {
|
|
402
|
-
array: true,
|
|
403
|
-
object: false
|
|
404
|
-
},
|
|
405
|
-
VariableDeclarator: {
|
|
406
|
-
array: false,
|
|
407
|
-
object: true
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
{ enforceForRenamedProperties: false }
|
|
411
|
-
],
|
|
412
363
|
"prefer-numeric-literals": "error",
|
|
413
364
|
"prefer-reflect": "off",
|
|
414
365
|
"prefer-rest-params": "error",
|
|
415
366
|
"prefer-spread": "error",
|
|
416
367
|
"prefer-template": "error",
|
|
417
368
|
"require-yield": "error",
|
|
418
|
-
"
|
|
419
|
-
"sort-imports": ["off", {
|
|
420
|
-
ignoreCase: false,
|
|
421
|
-
ignoreDeclarationSort: false,
|
|
422
|
-
ignoreMemberSort: false,
|
|
423
|
-
memberSyntaxSortOrder: [
|
|
424
|
-
"none",
|
|
425
|
-
"all",
|
|
426
|
-
"multiple",
|
|
427
|
-
"single"
|
|
428
|
-
]
|
|
429
|
-
}],
|
|
430
|
-
"symbol-description": "error",
|
|
431
|
-
"template-curly-spacing": "error",
|
|
432
|
-
"yield-star-spacing": ["error", "after"]
|
|
369
|
+
"symbol-description": "error"
|
|
433
370
|
});
|
|
434
371
|
//#endregion
|
|
435
372
|
//#region src/rules/esRules/overrides.ts
|
|
@@ -442,8 +379,7 @@ const overrides = () => ({
|
|
|
442
379
|
"no-underscore-dangle": "off",
|
|
443
380
|
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
|
444
381
|
"no-use-before-define": ["error", "nofunc"],
|
|
445
|
-
"no-void": ["error", { allowAsStatement: true }]
|
|
446
|
-
"unicode-bom": ["error", "never"]
|
|
382
|
+
"no-void": ["error", { allowAsStatement: true }]
|
|
447
383
|
});
|
|
448
384
|
//#endregion
|
|
449
385
|
//#region src/rules/esRules/strict.ts
|
|
@@ -574,46 +510,74 @@ imports["recommended"] = {
|
|
|
574
510
|
imports["stylistic"] = { "import/newline-after-import": ["error", { count: 1 }] };
|
|
575
511
|
//#endregion
|
|
576
512
|
//#region src/config/jsdoc.ts
|
|
577
|
-
const
|
|
513
|
+
const defaultJsFiles = [esSourceGlob];
|
|
514
|
+
const defaultTsFiles = [tsSourceGlob];
|
|
578
515
|
async function jsdoc(options = {}) {
|
|
579
516
|
const [jsdocPlugin] = await Promise.all([interopDefault(import("eslint-plugin-jsdoc"))]);
|
|
580
517
|
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
581
518
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
"jsdoc/valid-types": "off"
|
|
598
|
-
} : {},
|
|
599
|
-
...stylisticEnabled ? {
|
|
600
|
-
...jsdocPlugin.configs["flat/stylistic-typescript"].rules,
|
|
601
|
-
"jsdoc/check-alignment": "warn",
|
|
602
|
-
"jsdoc/multiline-blocks": "warn",
|
|
603
|
-
"jsdoc/tag-lines": [
|
|
604
|
-
"warn",
|
|
605
|
-
"any",
|
|
606
|
-
{ startLines: 1 }
|
|
607
|
-
]
|
|
608
|
-
} : {},
|
|
609
|
-
...rules
|
|
519
|
+
const recommendedRules = recommended ? jsdocPlugin.configs["flat/recommended-typescript-flavor"].rules : {};
|
|
520
|
+
const stylisticRules = stylisticEnabled ? {
|
|
521
|
+
...jsdocPlugin.configs["flat/stylistic-typescript"].rules,
|
|
522
|
+
"jsdoc/check-alignment": "warn",
|
|
523
|
+
"jsdoc/multiline-blocks": "warn",
|
|
524
|
+
"jsdoc/tag-lines": [
|
|
525
|
+
"warn",
|
|
526
|
+
"any",
|
|
527
|
+
{ startLines: 1 }
|
|
528
|
+
]
|
|
529
|
+
} : {};
|
|
530
|
+
return [
|
|
531
|
+
{
|
|
532
|
+
name: "w5s/jsdoc/setup",
|
|
533
|
+
plugins: { jsdoc: jsdocPlugin }
|
|
610
534
|
},
|
|
611
|
-
|
|
612
|
-
|
|
535
|
+
{
|
|
536
|
+
files: withDefaultFiles(files, defaultJsFiles),
|
|
537
|
+
name: "w5s/jsdoc/rules-js",
|
|
538
|
+
rules: {
|
|
539
|
+
...recommendedRules,
|
|
540
|
+
...recommended ? {
|
|
541
|
+
"jsdoc/no-undefined-types": "off",
|
|
542
|
+
"jsdoc/require-hyphen-before-param-description": ["warn", "always"],
|
|
543
|
+
"jsdoc/require-jsdoc": "off",
|
|
544
|
+
"jsdoc/require-param-description": "off",
|
|
545
|
+
"jsdoc/require-param-type": "off",
|
|
546
|
+
"jsdoc/require-returns": "off",
|
|
547
|
+
"jsdoc/require-returns-type": "off",
|
|
548
|
+
"jsdoc/valid-types": "off"
|
|
549
|
+
} : {},
|
|
550
|
+
...stylisticRules,
|
|
551
|
+
...rules
|
|
552
|
+
},
|
|
553
|
+
settings: { jsdoc: { mode: "typescript" } }
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
files: withDefaultFiles(files, defaultTsFiles),
|
|
557
|
+
name: "w5s/jsdoc/rules-ts",
|
|
558
|
+
rules: {
|
|
559
|
+
...recommendedRules,
|
|
560
|
+
...recommended ? {
|
|
561
|
+
"jsdoc/no-types": "warn",
|
|
562
|
+
"jsdoc/no-undefined-types": "off",
|
|
563
|
+
"jsdoc/require-hyphen-before-param-description": ["warn", "always"],
|
|
564
|
+
"jsdoc/require-jsdoc": "off",
|
|
565
|
+
"jsdoc/require-param-description": "off",
|
|
566
|
+
"jsdoc/require-param-type": "off",
|
|
567
|
+
"jsdoc/require-returns": "off",
|
|
568
|
+
"jsdoc/require-returns-type": "off",
|
|
569
|
+
"jsdoc/valid-types": "off"
|
|
570
|
+
} : {},
|
|
571
|
+
...stylisticRules,
|
|
572
|
+
...rules
|
|
573
|
+
},
|
|
574
|
+
settings: { jsdoc: { mode: "typescript" } }
|
|
575
|
+
}
|
|
576
|
+
];
|
|
613
577
|
}
|
|
614
578
|
//#endregion
|
|
615
579
|
//#region src/config/jsonc.ts
|
|
616
|
-
const defaultFiles$
|
|
580
|
+
const defaultFiles$9 = [jsonSourceGlob];
|
|
617
581
|
async function jsonc(options = {}) {
|
|
618
582
|
const [jsoncPlugin, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
619
583
|
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
@@ -624,7 +588,7 @@ async function jsonc(options = {}) {
|
|
|
624
588
|
plugins: { jsonc: jsoncPlugin }
|
|
625
589
|
},
|
|
626
590
|
{
|
|
627
|
-
files: withDefaultFiles(files, defaultFiles$
|
|
591
|
+
files: withDefaultFiles(files, defaultFiles$9),
|
|
628
592
|
languageOptions: { parser: jsoncParser },
|
|
629
593
|
name: "w5s/jsonc/rules",
|
|
630
594
|
rules: {
|
|
@@ -851,6 +815,28 @@ function sortTsconfigJson() {
|
|
|
851
815
|
};
|
|
852
816
|
}
|
|
853
817
|
//#endregion
|
|
818
|
+
//#region src/config/jsx.ts
|
|
819
|
+
const defaultFiles$8 = [jsxSourceGlob];
|
|
820
|
+
async function jsx(options = {}) {
|
|
821
|
+
const { files, jsxA11y = false, recommended = true, rules = {} } = options;
|
|
822
|
+
const [jsxA11yPlugin] = await Promise.all([jsxA11y ? interopDefault(import("eslint-plugin-jsx-a11y")) : void 0]);
|
|
823
|
+
return [{
|
|
824
|
+
languageOptions: {
|
|
825
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
826
|
+
sourceType: "module"
|
|
827
|
+
},
|
|
828
|
+
name: "w5s/jsx/setup",
|
|
829
|
+
plugins: { ...jsxA11yPlugin ? { "jsx-a11y": jsxA11yPlugin } : {} }
|
|
830
|
+
}, {
|
|
831
|
+
files: withDefaultFiles(files, defaultFiles$8),
|
|
832
|
+
name: "w5s/jsx/rules",
|
|
833
|
+
rules: {
|
|
834
|
+
...recommended && jsxA11yPlugin != null ? jsxA11yPlugin.configs["recommended"].rules : {},
|
|
835
|
+
...rules
|
|
836
|
+
}
|
|
837
|
+
}];
|
|
838
|
+
}
|
|
839
|
+
//#endregion
|
|
854
840
|
//#region src/config/markdown.ts
|
|
855
841
|
const defaultFiles$7 = [
|
|
856
842
|
`**/${Project.extensionsToGlob(Project.queryExtensions(["markdown"]))}`,
|
|
@@ -952,10 +938,307 @@ async function perfectionist(options = {}) {
|
|
|
952
938
|
}
|
|
953
939
|
//#endregion
|
|
954
940
|
//#region src/config/react.ts
|
|
941
|
+
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
942
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
943
|
+
/**
|
|
944
|
+
* Concat multiple flat configs into a single flat config array.
|
|
945
|
+
*
|
|
946
|
+
* It also resolves promises and flattens the result.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
*
|
|
950
|
+
* ```ts
|
|
951
|
+
* import eslint from '@eslint/js'
|
|
952
|
+
*
|
|
953
|
+
* export default ESLintConfig.concat(
|
|
954
|
+
* {
|
|
955
|
+
* plugins: {},
|
|
956
|
+
* rules: {},
|
|
957
|
+
* },
|
|
958
|
+
* // It can also takes a array of configs:
|
|
959
|
+
* [
|
|
960
|
+
* {
|
|
961
|
+
* plugins: {},
|
|
962
|
+
* rules: {},
|
|
963
|
+
* }
|
|
964
|
+
* // ...
|
|
965
|
+
* ],
|
|
966
|
+
* // Or promises:
|
|
967
|
+
* Promise.resolve({
|
|
968
|
+
* files: ['*.ts'],
|
|
969
|
+
* rules: {},
|
|
970
|
+
* })
|
|
971
|
+
* );
|
|
972
|
+
* ```
|
|
973
|
+
* @param configs
|
|
974
|
+
*/
|
|
975
|
+
async function concat(...configs) {
|
|
976
|
+
return (await Promise.all(configs)).flat();
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Always return 'off'. `_status` is the previous rule value.
|
|
980
|
+
*
|
|
981
|
+
* @param _status
|
|
982
|
+
*/
|
|
983
|
+
function fixme(_status) {
|
|
984
|
+
return "off";
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Return a new merged flat configuration
|
|
988
|
+
*
|
|
989
|
+
* @param configs
|
|
990
|
+
*/
|
|
991
|
+
function merge(...configs) {
|
|
992
|
+
const keys = new Set(configs.flatMap((i) => Object.keys(i)));
|
|
993
|
+
const merged = configs.reduce((acc, cur) => {
|
|
994
|
+
return {
|
|
995
|
+
...acc,
|
|
996
|
+
...cur,
|
|
997
|
+
files: [...acc.files ?? [], ...cur.files ?? []],
|
|
998
|
+
ignores: [...acc.ignores ?? [], ...cur.ignores ?? []],
|
|
999
|
+
languageOptions: {
|
|
1000
|
+
...acc.languageOptions,
|
|
1001
|
+
...cur.languageOptions
|
|
1002
|
+
},
|
|
1003
|
+
linterOptions: {
|
|
1004
|
+
...acc.linterOptions,
|
|
1005
|
+
...cur.linterOptions
|
|
1006
|
+
},
|
|
1007
|
+
plugins: {
|
|
1008
|
+
...acc.plugins,
|
|
1009
|
+
...cur.plugins
|
|
1010
|
+
},
|
|
1011
|
+
rules: {
|
|
1012
|
+
...acc.rules,
|
|
1013
|
+
...cur.rules
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
}, {});
|
|
1017
|
+
for (const key of Object.keys(merged)) if (!keys.has(key)) delete merged[key];
|
|
1018
|
+
return merged;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Renames rules in the given object according to the given map.
|
|
1022
|
+
*
|
|
1023
|
+
* Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
|
|
1024
|
+
* `{ 'old-prefix/rule-name': 'error' }`, this function will return
|
|
1025
|
+
* `{ 'new-prefix/rule-name': 'error' }`.
|
|
1026
|
+
*
|
|
1027
|
+
* @param rules The object containing the rules to rename.
|
|
1028
|
+
* @param map The object containing the rename map.
|
|
1029
|
+
*/
|
|
1030
|
+
function renameRules(rules, map) {
|
|
1031
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
1032
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
1033
|
+
else if (from === "" && !key.includes("/") && to !== "") return [to + key, value];
|
|
1034
|
+
return [key, value];
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* @namespace
|
|
1039
|
+
*/
|
|
1040
|
+
const ESLintConfig = Object.freeze({
|
|
1041
|
+
concat,
|
|
1042
|
+
fixme,
|
|
1043
|
+
merge,
|
|
1044
|
+
renameRules
|
|
1045
|
+
});
|
|
1046
|
+
const getDefaultOrElse = (_) => _?.default ?? _;
|
|
1047
|
+
function interopDefault(m) {
|
|
1048
|
+
return m != null && typeof m.then === "function" ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
|
|
1049
|
+
}
|
|
1050
|
+
const meta = Object.freeze({
|
|
1051
|
+
buildNumber: 1,
|
|
1052
|
+
name: "@w5s/dev",
|
|
1053
|
+
version: "3.7.0"
|
|
1054
|
+
});
|
|
1055
|
+
/**
|
|
1056
|
+
* Supported ECMA version
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```ts
|
|
1060
|
+
* Project.ecmaVersion() // 2022
|
|
1061
|
+
* ```
|
|
1062
|
+
*/
|
|
1063
|
+
function ecmaVersion() {
|
|
1064
|
+
return 2022;
|
|
1065
|
+
}
|
|
1066
|
+
function escapeRegExp(value) {
|
|
1067
|
+
return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
|
|
1068
|
+
}
|
|
1069
|
+
const registry = {
|
|
1070
|
+
css: [".css"],
|
|
1071
|
+
graphql: [".gql", ".graphql"],
|
|
1072
|
+
javascript: [
|
|
1073
|
+
".js",
|
|
1074
|
+
".cjs",
|
|
1075
|
+
".mjs"
|
|
1076
|
+
],
|
|
1077
|
+
javascriptreact: [".jsx"],
|
|
1078
|
+
jpeg: [".jpg", ".jpeg"],
|
|
1079
|
+
json: [".json"],
|
|
1080
|
+
jsonc: [".jsonc"],
|
|
1081
|
+
less: [".less"],
|
|
1082
|
+
markdown: [
|
|
1083
|
+
".markdown",
|
|
1084
|
+
".mdown",
|
|
1085
|
+
".mkd",
|
|
1086
|
+
".md"
|
|
1087
|
+
],
|
|
1088
|
+
sass: [".sass"],
|
|
1089
|
+
scss: [".scss"],
|
|
1090
|
+
typescript: [
|
|
1091
|
+
".ts",
|
|
1092
|
+
".cts",
|
|
1093
|
+
".mts"
|
|
1094
|
+
],
|
|
1095
|
+
typescriptreact: [".tsx"],
|
|
1096
|
+
vue: [".vue"],
|
|
1097
|
+
yaml: [".yaml", ".yml"]
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* Return a list of extensions
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```ts
|
|
1104
|
+
* Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
|
|
1105
|
+
* Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
|
|
1106
|
+
* ```
|
|
1107
|
+
*
|
|
1108
|
+
* @param languages
|
|
1109
|
+
*/
|
|
1110
|
+
function queryExtensions(languages) {
|
|
1111
|
+
return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort((left, right) => left.localeCompare(right));
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Supported file extensions
|
|
1115
|
+
*
|
|
1116
|
+
* @example
|
|
1117
|
+
* ```ts
|
|
1118
|
+
* Project.sourceExtensions() // ['.ts', '.js', ...]
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
function sourceExtensions() {
|
|
1122
|
+
return queryExtensions([
|
|
1123
|
+
"javascript",
|
|
1124
|
+
"javascriptreact",
|
|
1125
|
+
"typescript",
|
|
1126
|
+
"typescriptreact"
|
|
1127
|
+
]);
|
|
1128
|
+
}
|
|
1129
|
+
const RESOURCE_EXTENSIONS = Object.freeze([
|
|
1130
|
+
".gif",
|
|
1131
|
+
".png",
|
|
1132
|
+
".svg",
|
|
1133
|
+
...queryExtensions([
|
|
1134
|
+
"css",
|
|
1135
|
+
"graphql",
|
|
1136
|
+
"jpeg",
|
|
1137
|
+
"less",
|
|
1138
|
+
"sass",
|
|
1139
|
+
"sass",
|
|
1140
|
+
"yaml"
|
|
1141
|
+
])
|
|
1142
|
+
]);
|
|
1143
|
+
/**
|
|
1144
|
+
* Resource file extensions
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* ```ts
|
|
1148
|
+
* Project.resourceExtensions() // ['.css', '.sass', ...]
|
|
1149
|
+
* ```
|
|
1150
|
+
*/
|
|
1151
|
+
function resourceExtensions() {
|
|
1152
|
+
return RESOURCE_EXTENSIONS;
|
|
1153
|
+
}
|
|
1154
|
+
const IGNORED = Object.freeze([
|
|
1155
|
+
"node_modules/",
|
|
1156
|
+
"build/",
|
|
1157
|
+
"cjs/",
|
|
1158
|
+
"coverage/",
|
|
1159
|
+
"dist/",
|
|
1160
|
+
"dts/",
|
|
1161
|
+
"esm/",
|
|
1162
|
+
"lib/",
|
|
1163
|
+
"mjs/",
|
|
1164
|
+
"umd/"
|
|
1165
|
+
]);
|
|
1166
|
+
/**
|
|
1167
|
+
* Return a RegExp that will match any list of extensions
|
|
1168
|
+
*
|
|
1169
|
+
* @param extensions
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```ts
|
|
1172
|
+
* Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
|
|
1173
|
+
* ```
|
|
1174
|
+
*/
|
|
1175
|
+
function extensionsToMatcher(extensions) {
|
|
1176
|
+
return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Files and folders to always ignore
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```ts
|
|
1183
|
+
* IGNORED // ['node_modules/', 'build/', ...]
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
function ignored() {
|
|
1187
|
+
return IGNORED;
|
|
1188
|
+
}
|
|
1189
|
+
const reExtension = /^\./;
|
|
1190
|
+
/**
|
|
1191
|
+
* Return a glob matcher that will match any list of extensions
|
|
1192
|
+
*
|
|
1193
|
+
* @param extensions
|
|
1194
|
+
* @example
|
|
1195
|
+
* ```ts
|
|
1196
|
+
* Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
|
|
1197
|
+
* ```
|
|
1198
|
+
*/
|
|
1199
|
+
function extensionsToGlob(extensions) {
|
|
1200
|
+
return `*.+(${extensions.map((_) => _.replace(reExtension, "")).join("|")})`;
|
|
1201
|
+
}
|
|
1202
|
+
const Project = Object.freeze({
|
|
1203
|
+
ecmaVersion,
|
|
1204
|
+
extensionsToGlob,
|
|
1205
|
+
extensionsToMatcher,
|
|
1206
|
+
ignored,
|
|
1207
|
+
queryExtensions,
|
|
1208
|
+
resourceExtensions,
|
|
1209
|
+
sourceExtensions
|
|
1210
|
+
});
|
|
1211
|
+
/**
|
|
1212
|
+
* Project common scripts
|
|
1213
|
+
*/
|
|
1214
|
+
const ProjectScript = {
|
|
1215
|
+
Build: "build",
|
|
1216
|
+
Clean: "clean",
|
|
1217
|
+
CodeAnalysis: "code-analysis",
|
|
1218
|
+
Coverage: "coverage",
|
|
1219
|
+
Develop: "develop",
|
|
1220
|
+
Docs: "docs",
|
|
1221
|
+
Format: "format",
|
|
1222
|
+
Install: "install",
|
|
1223
|
+
Lint: "lint",
|
|
1224
|
+
Prepare: "prepare",
|
|
1225
|
+
Release: "release",
|
|
1226
|
+
Rescue: "rescue",
|
|
1227
|
+
Spellcheck: "spellcheck",
|
|
1228
|
+
Test: "test",
|
|
1229
|
+
Typecheck: "typecheck",
|
|
1230
|
+
Validate: "validate"
|
|
1231
|
+
};
|
|
1232
|
+
exports.ESLintConfig = ESLintConfig;
|
|
1233
|
+
exports.Project = Project;
|
|
1234
|
+
exports.ProjectScript = ProjectScript;
|
|
1235
|
+
exports.interopDefault = interopDefault;
|
|
1236
|
+
exports.meta = meta;
|
|
1237
|
+
})))();
|
|
955
1238
|
const defaultFiles$4 = [sourceGlob$1];
|
|
956
1239
|
async function react(options = {}) {
|
|
957
1240
|
const [reactPlugin] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin"))]);
|
|
958
|
-
const { files, recommended, rules = {} } = options;
|
|
1241
|
+
const { files, recommended = true, rules = {} } = options;
|
|
959
1242
|
return [{
|
|
960
1243
|
name: "w5s/react/setup",
|
|
961
1244
|
plugins: { react: reactPlugin }
|
|
@@ -967,7 +1250,7 @@ async function react(options = {}) {
|
|
|
967
1250
|
},
|
|
968
1251
|
name: "w5s/react/rules",
|
|
969
1252
|
rules: {
|
|
970
|
-
...recommended ? reactPlugin.configs["recommended"].rules : {},
|
|
1253
|
+
...recommended ? import_dist.ESLintConfig.renameRules(reactPlugin.configs["recommended"].rules, { "@eslint-react": "react" }) : {},
|
|
971
1254
|
...rules
|
|
972
1255
|
}
|
|
973
1256
|
}];
|
|
@@ -1050,7 +1333,6 @@ async function test(options = {}) {
|
|
|
1050
1333
|
const tsRules = () => {
|
|
1051
1334
|
const baseRules = esRules();
|
|
1052
1335
|
return ESLintConfig.renameRules({
|
|
1053
|
-
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
1054
1336
|
"@typescript-eslint/ban-ts-comment": ["warn", {
|
|
1055
1337
|
"minimumDescriptionLength": 3,
|
|
1056
1338
|
"ts-check": false,
|
|
@@ -1058,37 +1340,14 @@ const tsRules = () => {
|
|
|
1058
1340
|
"ts-ignore": "allow-with-description",
|
|
1059
1341
|
"ts-nocheck": true
|
|
1060
1342
|
}],
|
|
1061
|
-
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
1062
|
-
assertionStyle: "as",
|
|
1063
|
-
objectLiteralTypeAssertions: "never"
|
|
1064
|
-
}],
|
|
1065
1343
|
"@typescript-eslint/default-param-last": baseRules["default-param-last"],
|
|
1066
1344
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1067
1345
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
1068
|
-
"@typescript-eslint/naming-convention": [
|
|
1069
|
-
"error",
|
|
1070
|
-
{
|
|
1071
|
-
format: [
|
|
1072
|
-
"PascalCase",
|
|
1073
|
-
"camelCase",
|
|
1074
|
-
"UPPER_CASE"
|
|
1075
|
-
],
|
|
1076
|
-
leadingUnderscore: "allow",
|
|
1077
|
-
selector: "variable",
|
|
1078
|
-
trailingUnderscore: "allow"
|
|
1079
|
-
},
|
|
1080
|
-
{
|
|
1081
|
-
format: ["PascalCase"],
|
|
1082
|
-
selector: "typeLike"
|
|
1083
|
-
}
|
|
1084
|
-
],
|
|
1085
1346
|
"@typescript-eslint/no-dupe-class-members": baseRules["no-dupe-class-members"],
|
|
1086
1347
|
"@typescript-eslint/no-empty-function": baseRules["no-empty-function"],
|
|
1087
1348
|
"@typescript-eslint/no-empty-interface": ["error", { allowSingleExtends: true }],
|
|
1088
1349
|
"@typescript-eslint/no-empty-object-type": "off",
|
|
1089
1350
|
"@typescript-eslint/no-explicit-any": "off",
|
|
1090
|
-
"@typescript-eslint/no-extra-parens": baseRules["no-extra-parens"],
|
|
1091
|
-
"@typescript-eslint/no-inferrable-types": "error",
|
|
1092
1351
|
"@typescript-eslint/no-loop-func": baseRules["no-loop-func"],
|
|
1093
1352
|
"@typescript-eslint/no-loss-of-precision": baseRules["no-loss-of-precision"],
|
|
1094
1353
|
"@typescript-eslint/no-magic-numbers": baseRules["no-magic-numbers"],
|
|
@@ -1103,7 +1362,6 @@ const tsRules = () => {
|
|
|
1103
1362
|
"@typescript-eslint/no-unused-vars": baseRules["no-unused-vars"],
|
|
1104
1363
|
"@typescript-eslint/no-use-before-define": baseRules["no-use-before-define"],
|
|
1105
1364
|
"@typescript-eslint/no-useless-constructor": baseRules["no-useless-constructor"],
|
|
1106
|
-
"@typescript-eslint/no-var-requires": "error",
|
|
1107
1365
|
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
1108
1366
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
1109
1367
|
"@typescript-eslint/require-await": baseRules["require-await"],
|
|
@@ -1120,6 +1378,7 @@ async function ts(options = {}) {
|
|
|
1120
1378
|
const tsTypeCheckedRules = tsPlugin.configs["recommended-type-checked-only"].rules;
|
|
1121
1379
|
const { files, rules = {}, stylistic = true, typeChecked = false } = options;
|
|
1122
1380
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1381
|
+
const tsCustomRules = tsRules();
|
|
1123
1382
|
return [
|
|
1124
1383
|
{
|
|
1125
1384
|
name: "w5s/ts/setup",
|
|
@@ -1135,8 +1394,33 @@ async function ts(options = {}) {
|
|
|
1135
1394
|
rules: {
|
|
1136
1395
|
...ESLintConfig.renameRules(tsRecommendedRules, { "@typescript-eslint": "ts" }),
|
|
1137
1396
|
...ESLintConfig.renameRules(tsStrictRules, { "@typescript-eslint": "ts" }),
|
|
1138
|
-
...
|
|
1139
|
-
...stylisticEnabled ? {
|
|
1397
|
+
...tsCustomRules,
|
|
1398
|
+
...stylisticEnabled ? {
|
|
1399
|
+
...ESLintConfig.renameRules(tsPlugin.configs["stylistic"]?.rules, { "@typescript-eslint": "ts" }),
|
|
1400
|
+
"ts/array-type": ["error", { default: "generic" }],
|
|
1401
|
+
"ts/consistent-type-assertions": ["error", {
|
|
1402
|
+
assertionStyle: "as",
|
|
1403
|
+
objectLiteralTypeAssertions: "allow"
|
|
1404
|
+
}],
|
|
1405
|
+
"ts/naming-convention": [
|
|
1406
|
+
"error",
|
|
1407
|
+
{
|
|
1408
|
+
format: [
|
|
1409
|
+
"PascalCase",
|
|
1410
|
+
"camelCase",
|
|
1411
|
+
"UPPER_CASE"
|
|
1412
|
+
],
|
|
1413
|
+
leadingUnderscore: "allow",
|
|
1414
|
+
selector: "variable",
|
|
1415
|
+
trailingUnderscore: "allow"
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
format: ["PascalCase"],
|
|
1419
|
+
selector: "typeLike"
|
|
1420
|
+
}
|
|
1421
|
+
],
|
|
1422
|
+
"ts/no-empty-function": tsCustomRules["ts/no-empty-function"]
|
|
1423
|
+
} : {},
|
|
1140
1424
|
...rules
|
|
1141
1425
|
}
|
|
1142
1426
|
},
|
|
@@ -1246,16 +1530,16 @@ async function defineConfig(options = {}) {
|
|
|
1246
1530
|
...optionsOrBoolean
|
|
1247
1531
|
});
|
|
1248
1532
|
const includeEnabled = (factory, input) => input.enabled ? [factory(input)] : [];
|
|
1249
|
-
return ESLintConfig.concat(...includeEnabled(e18e, toOption(plugins.e18e)), ...includeEnabled(es, toOption(plugins.es)), ...includeEnabled(ts, toOption(plugins.ts)), ...includeEnabled(ignores, toOption(options)), ...includeEnabled(jsonc, toOption(plugins.jsonc)), ...includeEnabled(jsdoc, toOption(plugins.jsdoc)), ...includeEnabled(react, toOption(plugins.react)), ...includeEnabled(stylistic, toOption(plugins.stylistic)), ...includeEnabled(imports, toOption(plugins.import)), ...includeEnabled(markdown, toOption(plugins.markdown)), ...includeEnabled(next, toOption(plugins.next, false)), ...includeEnabled(node, toOption(plugins.node)), ...includeEnabled(perfectionist, toOption(plugins.perfectionist)), ...includeEnabled(unicorn, toOption(plugins.unicorn)), ...includeEnabled(yml, toOption(plugins.yml)), ...includeEnabled(test, toOption(plugins.test)), ...rules ? [{ rules }] : []);
|
|
1533
|
+
return ESLintConfig.concat(...includeEnabled(e18e, toOption(plugins.e18e)), ...includeEnabled(es, toOption(plugins.es)), ...includeEnabled(ts, toOption(plugins.ts)), ...includeEnabled(ignores, toOption(options)), ...includeEnabled(jsonc, toOption(plugins.jsonc)), ...includeEnabled(jsdoc, toOption(plugins.jsdoc)), ...includeEnabled(jsx, toOption(plugins.jsx)), ...includeEnabled(react, toOption(plugins.react)), ...includeEnabled(stylistic, toOption(plugins.stylistic)), ...includeEnabled(imports, toOption(plugins.import)), ...includeEnabled(markdown, toOption(plugins.markdown)), ...includeEnabled(next, toOption(plugins.next, false)), ...includeEnabled(node, toOption(plugins.node)), ...includeEnabled(perfectionist, toOption(plugins.perfectionist)), ...includeEnabled(unicorn, toOption(plugins.unicorn)), ...includeEnabled(yml, toOption(plugins.yml)), ...includeEnabled(test, toOption(plugins.test)), ...rules ? [{ rules }] : []);
|
|
1250
1534
|
}
|
|
1251
1535
|
//#endregion
|
|
1252
1536
|
//#region src/meta.ts
|
|
1253
1537
|
const meta = Object.freeze({
|
|
1254
1538
|
buildNumber: 1,
|
|
1255
1539
|
name: "@w5s/eslint-config",
|
|
1256
|
-
version: "3.
|
|
1540
|
+
version: "3.16.0"
|
|
1257
1541
|
});
|
|
1258
1542
|
//#endregion
|
|
1259
|
-
export { StylisticConfig, defineConfig as default, defineConfig, e18e, es, ignores, imports, jsdoc, jsonc, markdown, meta, next, node, perfectionist, react, stylistic, test, ts, unicorn, yml };
|
|
1543
|
+
export { StylisticConfig, defineConfig as default, defineConfig, e18e, es, ignores, imports, jsdoc, jsonc, jsx, markdown, meta, next, node, perfectionist, react, stylistic, test, ts, unicorn, yml };
|
|
1260
1544
|
|
|
1261
1545
|
//# sourceMappingURL=index.js.map
|