@coderwyd/eslint-config 2.1.1 → 2.1.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/dist/cli.cjs +7 -15
- package/dist/cli.js +7 -15
- package/dist/index.cjs +93 -147
- package/dist/index.js +93 -147
- package/package.json +13 -12
package/dist/cli.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.1.
|
|
49
|
+
var version = "2.1.3";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/ni": "^0.21.12",
|
|
52
52
|
"@types/eslint": "^8.56.2",
|
|
@@ -54,7 +54,7 @@ var devDependencies = {
|
|
|
54
54
|
"@types/node": "^20.10.8",
|
|
55
55
|
"@types/prompts": "^2.4.9",
|
|
56
56
|
"@types/yargs": "^17.0.32",
|
|
57
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
57
|
+
"@unocss/eslint-plugin": "^0.58.4",
|
|
58
58
|
bumpp: "^9.3.0",
|
|
59
59
|
eslint: "^8.56.0",
|
|
60
60
|
"eslint-flat-config-viewer": "^0.1.11",
|
|
@@ -66,7 +66,7 @@ var devDependencies = {
|
|
|
66
66
|
execa: "^8.0.1",
|
|
67
67
|
"fast-glob": "^3.3.2",
|
|
68
68
|
"fs-extra": "^11.2.0",
|
|
69
|
-
"lint-staged": "^15.2.
|
|
69
|
+
"lint-staged": "^15.2.1",
|
|
70
70
|
rimraf: "^5.0.5",
|
|
71
71
|
"simple-git-hooks": "^2.9.0",
|
|
72
72
|
"svelte-eslint-parser": "^0.33.1",
|
|
@@ -131,11 +131,7 @@ async function run(options = {}) {
|
|
|
131
131
|
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
132
132
|
const pathESLintIngore = import_node_path.default.join(cwd, ".eslintignore");
|
|
133
133
|
if (import_node_fs.default.existsSync(pathFlatConfig)) {
|
|
134
|
-
console.log(
|
|
135
|
-
import_picocolors2.default.yellow(
|
|
136
|
-
`${WARN} eslint.config.js already exists, migration wizard exited.`
|
|
137
|
-
)
|
|
138
|
-
);
|
|
134
|
+
console.log(import_picocolors2.default.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
|
|
139
135
|
return import_node_process.default.exit(1);
|
|
140
136
|
}
|
|
141
137
|
if (!SKIP_GIT_CHECK && !isGitClean()) {
|
|
@@ -167,9 +163,7 @@ async function run(options = {}) {
|
|
|
167
163
|
if (glob.type === "ignore")
|
|
168
164
|
eslintIgnores.push(...glob.patterns);
|
|
169
165
|
else if (glob.type === "unignore")
|
|
170
|
-
eslintIgnores.push(
|
|
171
|
-
...glob.patterns.map((pattern) => `!${pattern}`)
|
|
172
|
-
);
|
|
166
|
+
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
173
167
|
}
|
|
174
168
|
}
|
|
175
169
|
let eslintConfigContent = "";
|
|
@@ -246,10 +240,8 @@ ${coderwydConfig}
|
|
|
246
240
|
}
|
|
247
241
|
}
|
|
248
242
|
console.log(import_picocolors2.default.green(`${CHECK} migration completed`));
|
|
249
|
-
console.log(
|
|
250
|
-
|
|
251
|
-
`
|
|
252
|
-
);
|
|
243
|
+
console.log(`Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
|
|
244
|
+
`);
|
|
253
245
|
}
|
|
254
246
|
|
|
255
247
|
// src/cli/index.ts
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.1.
|
|
20
|
+
var version = "2.1.3";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/ni": "^0.21.12",
|
|
23
23
|
"@types/eslint": "^8.56.2",
|
|
@@ -25,7 +25,7 @@ var devDependencies = {
|
|
|
25
25
|
"@types/node": "^20.10.8",
|
|
26
26
|
"@types/prompts": "^2.4.9",
|
|
27
27
|
"@types/yargs": "^17.0.32",
|
|
28
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
28
|
+
"@unocss/eslint-plugin": "^0.58.4",
|
|
29
29
|
bumpp: "^9.3.0",
|
|
30
30
|
eslint: "^8.56.0",
|
|
31
31
|
"eslint-flat-config-viewer": "^0.1.11",
|
|
@@ -37,7 +37,7 @@ var devDependencies = {
|
|
|
37
37
|
execa: "^8.0.1",
|
|
38
38
|
"fast-glob": "^3.3.2",
|
|
39
39
|
"fs-extra": "^11.2.0",
|
|
40
|
-
"lint-staged": "^15.2.
|
|
40
|
+
"lint-staged": "^15.2.1",
|
|
41
41
|
rimraf: "^5.0.5",
|
|
42
42
|
"simple-git-hooks": "^2.9.0",
|
|
43
43
|
"svelte-eslint-parser": "^0.33.1",
|
|
@@ -102,11 +102,7 @@ async function run(options = {}) {
|
|
|
102
102
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
103
103
|
const pathESLintIngore = path.join(cwd, ".eslintignore");
|
|
104
104
|
if (fs.existsSync(pathFlatConfig)) {
|
|
105
|
-
console.log(
|
|
106
|
-
c2.yellow(
|
|
107
|
-
`${WARN} eslint.config.js already exists, migration wizard exited.`
|
|
108
|
-
)
|
|
109
|
-
);
|
|
105
|
+
console.log(c2.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
|
|
110
106
|
return process.exit(1);
|
|
111
107
|
}
|
|
112
108
|
if (!SKIP_GIT_CHECK && !isGitClean()) {
|
|
@@ -138,9 +134,7 @@ async function run(options = {}) {
|
|
|
138
134
|
if (glob.type === "ignore")
|
|
139
135
|
eslintIgnores.push(...glob.patterns);
|
|
140
136
|
else if (glob.type === "unignore")
|
|
141
|
-
eslintIgnores.push(
|
|
142
|
-
...glob.patterns.map((pattern) => `!${pattern}`)
|
|
143
|
-
);
|
|
137
|
+
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
let eslintConfigContent = "";
|
|
@@ -217,10 +211,8 @@ ${coderwydConfig}
|
|
|
217
211
|
}
|
|
218
212
|
}
|
|
219
213
|
console.log(c2.green(`${CHECK} migration completed`));
|
|
220
|
-
console.log(
|
|
221
|
-
|
|
222
|
-
`
|
|
223
|
-
);
|
|
214
|
+
console.log(`Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
|
|
215
|
+
`);
|
|
224
216
|
}
|
|
225
217
|
|
|
226
218
|
// src/cli/index.ts
|
package/dist/index.cjs
CHANGED
|
@@ -156,10 +156,7 @@ async function imports() {
|
|
|
156
156
|
"antfu/no-import-dist": "error",
|
|
157
157
|
"antfu/no-import-node-modules-by-path": "error",
|
|
158
158
|
"import/first": "error",
|
|
159
|
-
"import/newline-after-import": [
|
|
160
|
-
"error",
|
|
161
|
-
{ considerComments: true, count: 1 }
|
|
162
|
-
],
|
|
159
|
+
"import/newline-after-import": ["error", { considerComments: true, count: 1 }],
|
|
163
160
|
"import/no-duplicates": "error",
|
|
164
161
|
"import/no-mutable-exports": "error",
|
|
165
162
|
"import/no-named-default": "error",
|
|
@@ -168,16 +165,7 @@ async function imports() {
|
|
|
168
165
|
"import/order": [
|
|
169
166
|
"error",
|
|
170
167
|
{
|
|
171
|
-
groups: [
|
|
172
|
-
"builtin",
|
|
173
|
-
"external",
|
|
174
|
-
"internal",
|
|
175
|
-
"parent",
|
|
176
|
-
"sibling",
|
|
177
|
-
"index",
|
|
178
|
-
"object",
|
|
179
|
-
"type"
|
|
180
|
-
],
|
|
168
|
+
groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
|
|
181
169
|
pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
|
|
182
170
|
pathGroupsExcludedImportTypes: ["type"]
|
|
183
171
|
}
|
|
@@ -228,20 +216,14 @@ async function javascript(options = {}) {
|
|
|
228
216
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
229
217
|
},
|
|
230
218
|
rules: {
|
|
231
|
-
"accessor-pairs": [
|
|
232
|
-
"error",
|
|
233
|
-
{ enforceForClassMembers: true, setWithoutGet: true }
|
|
234
|
-
],
|
|
219
|
+
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
235
220
|
"array-callback-return": "error",
|
|
236
221
|
"block-scoped-var": "error",
|
|
237
222
|
"constructor-super": "error",
|
|
238
223
|
"default-case-last": "error",
|
|
239
224
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
240
225
|
eqeqeq: ["error", "smart"],
|
|
241
|
-
"new-cap": [
|
|
242
|
-
"error",
|
|
243
|
-
{ capIsNew: false, newIsCap: true, properties: true }
|
|
244
|
-
],
|
|
226
|
+
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
245
227
|
"no-alert": "error",
|
|
246
228
|
"no-array-constructor": "error",
|
|
247
229
|
"no-async-promise-executor": "error",
|
|
@@ -362,10 +344,7 @@ async function javascript(options = {}) {
|
|
|
362
344
|
vars: "all"
|
|
363
345
|
}
|
|
364
346
|
],
|
|
365
|
-
"no-use-before-define": [
|
|
366
|
-
"error",
|
|
367
|
-
{ classes: false, functions: false, variables: true }
|
|
368
|
-
],
|
|
347
|
+
"no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
369
348
|
"no-useless-backreference": "error",
|
|
370
349
|
"no-useless-call": "error",
|
|
371
350
|
"no-useless-catch": "error",
|
|
@@ -426,10 +405,7 @@ async function javascript(options = {}) {
|
|
|
426
405
|
varsIgnorePattern: "^_"
|
|
427
406
|
}
|
|
428
407
|
],
|
|
429
|
-
"use-isnan": [
|
|
430
|
-
"error",
|
|
431
|
-
{ enforceForIndexOf: true, enforceForSwitchCase: true }
|
|
432
|
-
],
|
|
408
|
+
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
433
409
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
434
410
|
"vars-on-top": "error",
|
|
435
411
|
yoda: ["error", "never"],
|
|
@@ -506,17 +482,13 @@ async function ensurePackages(packages) {
|
|
|
506
482
|
const { default: prompts } = await import("prompts");
|
|
507
483
|
const { result } = await prompts([
|
|
508
484
|
{
|
|
509
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
|
|
510
|
-
", "
|
|
511
|
-
)}. Do you want to install them?`,
|
|
485
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
512
486
|
name: "result",
|
|
513
487
|
type: "confirm"
|
|
514
488
|
}
|
|
515
489
|
]);
|
|
516
490
|
if (result)
|
|
517
|
-
await import("@antfu/install-pkg").then(
|
|
518
|
-
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
519
|
-
);
|
|
491
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
520
492
|
}
|
|
521
493
|
async function loadPrettierConfig(cwd) {
|
|
522
494
|
let prettierConfig = {};
|
|
@@ -732,14 +704,7 @@ function sortTsconfig() {
|
|
|
732
704
|
"jsonc/sort-keys": [
|
|
733
705
|
"error",
|
|
734
706
|
{
|
|
735
|
-
order: [
|
|
736
|
-
"extends",
|
|
737
|
-
"compilerOptions",
|
|
738
|
-
"references",
|
|
739
|
-
"files",
|
|
740
|
-
"include",
|
|
741
|
-
"exclude"
|
|
742
|
-
],
|
|
707
|
+
order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
|
|
743
708
|
pathPattern: "^$"
|
|
744
709
|
},
|
|
745
710
|
{
|
|
@@ -883,10 +848,7 @@ async function prettier(rules) {
|
|
|
883
848
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
884
849
|
async function typescript(options = {}) {
|
|
885
850
|
const { componentExts = [], overrides = {}, parserOptions = {} } = options;
|
|
886
|
-
const files = options.files ?? [
|
|
887
|
-
GLOB_SRC,
|
|
888
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
889
|
-
];
|
|
851
|
+
const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
890
852
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
891
853
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
892
854
|
const isTypeAware = !!tsconfigPath;
|
|
@@ -944,39 +906,22 @@ async function typescript(options = {}) {
|
|
|
944
906
|
}
|
|
945
907
|
},
|
|
946
908
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
947
|
-
...isTypeAware ? [
|
|
948
|
-
makeParser(true, filesTypeAware),
|
|
949
|
-
makeParser(false, files, filesTypeAware)
|
|
950
|
-
] : [makeParser(false, files)],
|
|
909
|
+
...isTypeAware ? [makeParser(true, filesTypeAware), makeParser(false, files, filesTypeAware)] : [makeParser(false, files)],
|
|
951
910
|
{
|
|
952
911
|
files,
|
|
953
912
|
name: "coderwyd:typescript:rules",
|
|
954
913
|
rules: {
|
|
955
|
-
...renameRules(
|
|
956
|
-
|
|
957
|
-
"@typescript-eslint/",
|
|
958
|
-
"ts/"
|
|
959
|
-
),
|
|
960
|
-
...renameRules(
|
|
961
|
-
pluginTs.configs.strict.rules,
|
|
962
|
-
"@typescript-eslint/",
|
|
963
|
-
"ts/"
|
|
964
|
-
),
|
|
914
|
+
...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, "@typescript-eslint/", "ts/"),
|
|
915
|
+
...renameRules(pluginTs.configs.strict.rules, "@typescript-eslint/", "ts/"),
|
|
965
916
|
"no-dupe-class-members": "off",
|
|
966
917
|
"no-loss-of-precision": "off",
|
|
967
918
|
"no-redeclare": "off",
|
|
968
919
|
"no-use-before-define": "off",
|
|
969
920
|
"no-useless-constructor": "off",
|
|
970
|
-
"ts/ban-ts-comment": [
|
|
971
|
-
"error",
|
|
972
|
-
{ "ts-ignore": "allow-with-description" }
|
|
973
|
-
],
|
|
921
|
+
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
974
922
|
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
975
923
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
976
|
-
"ts/consistent-type-imports": [
|
|
977
|
-
"error",
|
|
978
|
-
{ disallowTypeAnnotations: false, prefer: "type-imports" }
|
|
979
|
-
],
|
|
924
|
+
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
980
925
|
"ts/no-dupe-class-members": "error",
|
|
981
926
|
"ts/no-dynamic-delete": "off",
|
|
982
927
|
"ts/no-explicit-any": "off",
|
|
@@ -988,10 +933,7 @@ async function typescript(options = {}) {
|
|
|
988
933
|
"ts/no-redeclare": "error",
|
|
989
934
|
"ts/no-require-imports": "error",
|
|
990
935
|
"ts/no-unused-vars": "off",
|
|
991
|
-
"ts/no-use-before-define": [
|
|
992
|
-
"error",
|
|
993
|
-
{ classes: false, functions: false, variables: true }
|
|
994
|
-
],
|
|
936
|
+
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
995
937
|
"ts/no-useless-constructor": "off",
|
|
996
938
|
"ts/prefer-ts-expect-error": "error",
|
|
997
939
|
"ts/triple-slash-reference": "off",
|
|
@@ -1045,31 +987,64 @@ async function unicorn() {
|
|
|
1045
987
|
},
|
|
1046
988
|
rules: {
|
|
1047
989
|
"unicorn/better-regex": "error",
|
|
1048
|
-
|
|
990
|
+
"unicorn/catch-error-name": "error",
|
|
991
|
+
"unicorn/custom-error-definition": "error",
|
|
1049
992
|
"unicorn/error-message": "error",
|
|
1050
|
-
// Uppercase regex escapes
|
|
1051
993
|
"unicorn/escape-case": "error",
|
|
1052
|
-
|
|
994
|
+
"unicorn/explicit-length-check": "error",
|
|
995
|
+
// 'unicorn/filename-case': [
|
|
996
|
+
// 'error',
|
|
997
|
+
// {
|
|
998
|
+
// cases: { kebabCase: true, pascalCase: true },
|
|
999
|
+
// ignore: [/^[A-Z]+\..*$/],
|
|
1000
|
+
// },
|
|
1001
|
+
// ],
|
|
1002
|
+
"unicorn/new-for-builtins": "error",
|
|
1003
|
+
"unicorn/no-array-callback-reference": "error",
|
|
1004
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
1005
|
+
"unicorn/no-array-push-push": "error",
|
|
1006
|
+
"unicorn/no-console-spaces": "error",
|
|
1007
|
+
"unicorn/no-for-loop": "error",
|
|
1008
|
+
"unicorn/no-hex-escape": "error",
|
|
1053
1009
|
"unicorn/no-instanceof-array": "error",
|
|
1054
|
-
|
|
1010
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
1011
|
+
"unicorn/no-lonely-if": "error",
|
|
1055
1012
|
"unicorn/no-new-array": "error",
|
|
1056
|
-
// Prevent deprecated `new Buffer()`
|
|
1057
1013
|
"unicorn/no-new-buffer": "error",
|
|
1058
|
-
|
|
1059
|
-
"unicorn/
|
|
1060
|
-
|
|
1014
|
+
"unicorn/no-static-only-class": "error",
|
|
1015
|
+
"unicorn/no-unnecessary-await": "error",
|
|
1016
|
+
"unicorn/no-zero-fractions": `error`,
|
|
1017
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
1018
|
+
"unicorn/prefer-array-find": "error",
|
|
1019
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
1020
|
+
"unicorn/prefer-array-index-of": "error",
|
|
1021
|
+
"unicorn/prefer-array-some": "error",
|
|
1022
|
+
"unicorn/prefer-at": "error",
|
|
1023
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
1024
|
+
"unicorn/prefer-date-now": "error",
|
|
1025
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
1026
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
1027
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
1061
1028
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
1062
|
-
// includes over indexOf when checking for existence
|
|
1063
1029
|
"unicorn/prefer-includes": "error",
|
|
1064
|
-
|
|
1030
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
1031
|
+
"unicorn/prefer-math-trunc": "error",
|
|
1032
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
1033
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
1034
|
+
"unicorn/prefer-negative-index": "error",
|
|
1065
1035
|
"unicorn/prefer-node-protocol": "error",
|
|
1066
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1067
1036
|
"unicorn/prefer-number-properties": "error",
|
|
1068
|
-
|
|
1037
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
1038
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
1039
|
+
"unicorn/prefer-query-selector": "error",
|
|
1040
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
1041
|
+
"unicorn/prefer-regexp-test": "error",
|
|
1042
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
1043
|
+
"unicorn/prefer-string-slice": "error",
|
|
1069
1044
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1070
|
-
|
|
1045
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
1046
|
+
"unicorn/prefer-top-level-await": "error",
|
|
1071
1047
|
"unicorn/prefer-type-error": "error",
|
|
1072
|
-
// Use new when throwing error
|
|
1073
1048
|
"unicorn/throw-new-error": "error"
|
|
1074
1049
|
}
|
|
1075
1050
|
}
|
|
@@ -1108,9 +1083,7 @@ async function vue(options = {}) {
|
|
|
1108
1083
|
jsx: true
|
|
1109
1084
|
},
|
|
1110
1085
|
extraFileExtensions: [".vue"],
|
|
1111
|
-
parser: options.typescript ? await interopDefault(
|
|
1112
|
-
import("@typescript-eslint/parser")
|
|
1113
|
-
) : null,
|
|
1086
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1114
1087
|
sourceType: "module"
|
|
1115
1088
|
}
|
|
1116
1089
|
},
|
|
@@ -1132,12 +1105,7 @@ async function vue(options = {}) {
|
|
|
1132
1105
|
"vue/define-macros-order": [
|
|
1133
1106
|
"error",
|
|
1134
1107
|
{
|
|
1135
|
-
order: [
|
|
1136
|
-
"defineOptions",
|
|
1137
|
-
"defineProps",
|
|
1138
|
-
"defineEmits",
|
|
1139
|
-
"defineSlots"
|
|
1140
|
-
]
|
|
1108
|
+
order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
|
|
1141
1109
|
}
|
|
1142
1110
|
],
|
|
1143
1111
|
"vue/dot-location": ["error", "property"],
|
|
@@ -1145,19 +1113,27 @@ async function vue(options = {}) {
|
|
|
1145
1113
|
"vue/eqeqeq": ["error", "smart"],
|
|
1146
1114
|
"vue/html-indent": ["error", 2],
|
|
1147
1115
|
"vue/html-quotes": ["error", "double"],
|
|
1116
|
+
"vue/html-self-closing": [
|
|
1117
|
+
"error",
|
|
1118
|
+
{
|
|
1119
|
+
html: {
|
|
1120
|
+
component: "always",
|
|
1121
|
+
normal: "always",
|
|
1122
|
+
void: "any"
|
|
1123
|
+
},
|
|
1124
|
+
math: "always",
|
|
1125
|
+
svg: "always"
|
|
1126
|
+
}
|
|
1127
|
+
],
|
|
1148
1128
|
"vue/max-attributes-per-line": "off",
|
|
1149
1129
|
"vue/multi-word-component-names": "off",
|
|
1130
|
+
"vue/no-constant-condition": "warn",
|
|
1150
1131
|
"vue/no-dupe-keys": "off",
|
|
1151
1132
|
"vue/no-empty-pattern": "error",
|
|
1152
1133
|
"vue/no-extra-parens": ["error", "functions"],
|
|
1153
1134
|
"vue/no-irregular-whitespace": "error",
|
|
1154
1135
|
"vue/no-loss-of-precision": "error",
|
|
1155
|
-
"vue/no-restricted-syntax": [
|
|
1156
|
-
"error",
|
|
1157
|
-
"DebuggerStatement",
|
|
1158
|
-
"LabeledStatement",
|
|
1159
|
-
"WithStatement"
|
|
1160
|
-
],
|
|
1136
|
+
"vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
|
|
1161
1137
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1162
1138
|
"vue/no-setup-props-reactivity-loss": "off",
|
|
1163
1139
|
"vue/no-sparse-arrays": "error",
|
|
@@ -1172,6 +1148,7 @@ async function vue(options = {}) {
|
|
|
1172
1148
|
ignoreConstructors: false
|
|
1173
1149
|
}
|
|
1174
1150
|
],
|
|
1151
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1175
1152
|
"vue/prefer-separate-static-class": "error",
|
|
1176
1153
|
"vue/prefer-template": "error",
|
|
1177
1154
|
"vue/prop-name-casing": ["error", "camelCase"],
|
|
@@ -1213,10 +1190,7 @@ async function test(options = {}) {
|
|
|
1213
1190
|
name: "coderwyd:test:rules",
|
|
1214
1191
|
rules: {
|
|
1215
1192
|
"node/prefer-global/process": "off",
|
|
1216
|
-
"test/consistent-test-it": [
|
|
1217
|
-
"error",
|
|
1218
|
-
{ fn: "it", withinDescribe: "it" }
|
|
1219
|
-
],
|
|
1193
|
+
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1220
1194
|
"test/no-identical-title": "error",
|
|
1221
1195
|
"test/no-import-node-test": "error",
|
|
1222
1196
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
@@ -1244,26 +1218,14 @@ async function perfectionist() {
|
|
|
1244
1218
|
var import_local_pkg2 = require("local-pkg");
|
|
1245
1219
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
1246
1220
|
async function react(options = {}) {
|
|
1247
|
-
const {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
"eslint-plugin-react",
|
|
1254
|
-
"eslint-plugin-react-hooks",
|
|
1255
|
-
"eslint-plugin-react-refresh"
|
|
1221
|
+
const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript: typescript2 = true } = options;
|
|
1222
|
+
await ensurePackages(["eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-react-refresh"]);
|
|
1223
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1224
|
+
interopDefault(import("eslint-plugin-react")),
|
|
1225
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1226
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1256
1227
|
]);
|
|
1257
|
-
const
|
|
1258
|
-
[
|
|
1259
|
-
interopDefault(import("eslint-plugin-react")),
|
|
1260
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1261
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1262
|
-
]
|
|
1263
|
-
);
|
|
1264
|
-
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1265
|
-
(i) => (0, import_local_pkg2.isPackageExists)(i)
|
|
1266
|
-
);
|
|
1228
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
1267
1229
|
return [
|
|
1268
1230
|
{
|
|
1269
1231
|
name: "coderwyd:react:setup",
|
|
@@ -1293,10 +1255,7 @@ async function react(options = {}) {
|
|
|
1293
1255
|
"react-hooks/exhaustive-deps": "warn",
|
|
1294
1256
|
"react-hooks/rules-of-hooks": "error",
|
|
1295
1257
|
// react refresh
|
|
1296
|
-
"react-refresh/only-export-components": [
|
|
1297
|
-
"warn",
|
|
1298
|
-
{ allowConstantExport: isAllowConstantExport }
|
|
1299
|
-
],
|
|
1258
|
+
"react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }],
|
|
1300
1259
|
// recommended rules react
|
|
1301
1260
|
"react/display-name": "error",
|
|
1302
1261
|
"react/jsx-key": "error",
|
|
@@ -1335,9 +1294,7 @@ async function react(options = {}) {
|
|
|
1335
1294
|
async function unocss(options = {}) {
|
|
1336
1295
|
const { attributify = true, strict = false } = options;
|
|
1337
1296
|
await ensurePackages(["@unocss/eslint-plugin"]);
|
|
1338
|
-
const [pluginUnoCSS] = await Promise.all([
|
|
1339
|
-
interopDefault(import("@unocss/eslint-plugin"))
|
|
1340
|
-
]);
|
|
1297
|
+
const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
|
|
1341
1298
|
return [
|
|
1342
1299
|
{
|
|
1343
1300
|
name: "coderwyd:unocss",
|
|
@@ -1360,14 +1317,7 @@ async function unocss(options = {}) {
|
|
|
1360
1317
|
// src/configs/formatter.ts
|
|
1361
1318
|
async function formatter(options = {}, prettierRules2 = {}) {
|
|
1362
1319
|
await ensurePackages(["eslint-plugin-prettier"]);
|
|
1363
|
-
const {
|
|
1364
|
-
css = true,
|
|
1365
|
-
graphql,
|
|
1366
|
-
html = true,
|
|
1367
|
-
markdown,
|
|
1368
|
-
toml,
|
|
1369
|
-
yaml
|
|
1370
|
-
} = options || {};
|
|
1320
|
+
const { css = true, graphql, html = true, markdown, toml, yaml } = options || {};
|
|
1371
1321
|
const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
|
|
1372
1322
|
function createPrettierFormatter(files, parser, plugins) {
|
|
1373
1323
|
const rules = {
|
|
@@ -1424,9 +1374,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1424
1374
|
}
|
|
1425
1375
|
if (toml) {
|
|
1426
1376
|
await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
|
|
1427
|
-
const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
|
|
1428
|
-
"prettier-plugin-toml"
|
|
1429
|
-
]);
|
|
1377
|
+
const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]);
|
|
1430
1378
|
configs.push(tomlConfig);
|
|
1431
1379
|
}
|
|
1432
1380
|
return configs;
|
|
@@ -1453,9 +1401,7 @@ async function svelte(options = {}) {
|
|
|
1453
1401
|
parser: parserSvelte,
|
|
1454
1402
|
parserOptions: {
|
|
1455
1403
|
extraFileExtensions: [".svelte"],
|
|
1456
|
-
parser: options.typescript ? await interopDefault(
|
|
1457
|
-
import("@typescript-eslint/parser")
|
|
1458
|
-
) : null
|
|
1404
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1459
1405
|
}
|
|
1460
1406
|
},
|
|
1461
1407
|
name: "coderwyd:svelte:rules",
|
package/dist/index.js
CHANGED
|
@@ -122,10 +122,7 @@ async function imports() {
|
|
|
122
122
|
"antfu/no-import-dist": "error",
|
|
123
123
|
"antfu/no-import-node-modules-by-path": "error",
|
|
124
124
|
"import/first": "error",
|
|
125
|
-
"import/newline-after-import": [
|
|
126
|
-
"error",
|
|
127
|
-
{ considerComments: true, count: 1 }
|
|
128
|
-
],
|
|
125
|
+
"import/newline-after-import": ["error", { considerComments: true, count: 1 }],
|
|
129
126
|
"import/no-duplicates": "error",
|
|
130
127
|
"import/no-mutable-exports": "error",
|
|
131
128
|
"import/no-named-default": "error",
|
|
@@ -134,16 +131,7 @@ async function imports() {
|
|
|
134
131
|
"import/order": [
|
|
135
132
|
"error",
|
|
136
133
|
{
|
|
137
|
-
groups: [
|
|
138
|
-
"builtin",
|
|
139
|
-
"external",
|
|
140
|
-
"internal",
|
|
141
|
-
"parent",
|
|
142
|
-
"sibling",
|
|
143
|
-
"index",
|
|
144
|
-
"object",
|
|
145
|
-
"type"
|
|
146
|
-
],
|
|
134
|
+
groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
|
|
147
135
|
pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
|
|
148
136
|
pathGroupsExcludedImportTypes: ["type"]
|
|
149
137
|
}
|
|
@@ -194,20 +182,14 @@ async function javascript(options = {}) {
|
|
|
194
182
|
"unused-imports": default6
|
|
195
183
|
},
|
|
196
184
|
rules: {
|
|
197
|
-
"accessor-pairs": [
|
|
198
|
-
"error",
|
|
199
|
-
{ enforceForClassMembers: true, setWithoutGet: true }
|
|
200
|
-
],
|
|
185
|
+
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
201
186
|
"array-callback-return": "error",
|
|
202
187
|
"block-scoped-var": "error",
|
|
203
188
|
"constructor-super": "error",
|
|
204
189
|
"default-case-last": "error",
|
|
205
190
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
206
191
|
eqeqeq: ["error", "smart"],
|
|
207
|
-
"new-cap": [
|
|
208
|
-
"error",
|
|
209
|
-
{ capIsNew: false, newIsCap: true, properties: true }
|
|
210
|
-
],
|
|
192
|
+
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
211
193
|
"no-alert": "error",
|
|
212
194
|
"no-array-constructor": "error",
|
|
213
195
|
"no-async-promise-executor": "error",
|
|
@@ -328,10 +310,7 @@ async function javascript(options = {}) {
|
|
|
328
310
|
vars: "all"
|
|
329
311
|
}
|
|
330
312
|
],
|
|
331
|
-
"no-use-before-define": [
|
|
332
|
-
"error",
|
|
333
|
-
{ classes: false, functions: false, variables: true }
|
|
334
|
-
],
|
|
313
|
+
"no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
335
314
|
"no-useless-backreference": "error",
|
|
336
315
|
"no-useless-call": "error",
|
|
337
316
|
"no-useless-catch": "error",
|
|
@@ -392,10 +371,7 @@ async function javascript(options = {}) {
|
|
|
392
371
|
varsIgnorePattern: "^_"
|
|
393
372
|
}
|
|
394
373
|
],
|
|
395
|
-
"use-isnan": [
|
|
396
|
-
"error",
|
|
397
|
-
{ enforceForIndexOf: true, enforceForSwitchCase: true }
|
|
398
|
-
],
|
|
374
|
+
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
399
375
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
400
376
|
"vars-on-top": "error",
|
|
401
377
|
yoda: ["error", "never"],
|
|
@@ -472,17 +448,13 @@ async function ensurePackages(packages) {
|
|
|
472
448
|
const { default: prompts } = await import("prompts");
|
|
473
449
|
const { result } = await prompts([
|
|
474
450
|
{
|
|
475
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
|
|
476
|
-
", "
|
|
477
|
-
)}. Do you want to install them?`,
|
|
451
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
478
452
|
name: "result",
|
|
479
453
|
type: "confirm"
|
|
480
454
|
}
|
|
481
455
|
]);
|
|
482
456
|
if (result)
|
|
483
|
-
await import("@antfu/install-pkg").then(
|
|
484
|
-
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
485
|
-
);
|
|
457
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
486
458
|
}
|
|
487
459
|
async function loadPrettierConfig(cwd) {
|
|
488
460
|
let prettierConfig = {};
|
|
@@ -698,14 +670,7 @@ function sortTsconfig() {
|
|
|
698
670
|
"jsonc/sort-keys": [
|
|
699
671
|
"error",
|
|
700
672
|
{
|
|
701
|
-
order: [
|
|
702
|
-
"extends",
|
|
703
|
-
"compilerOptions",
|
|
704
|
-
"references",
|
|
705
|
-
"files",
|
|
706
|
-
"include",
|
|
707
|
-
"exclude"
|
|
708
|
-
],
|
|
673
|
+
order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
|
|
709
674
|
pathPattern: "^$"
|
|
710
675
|
},
|
|
711
676
|
{
|
|
@@ -849,10 +814,7 @@ async function prettier(rules) {
|
|
|
849
814
|
import process2 from "node:process";
|
|
850
815
|
async function typescript(options = {}) {
|
|
851
816
|
const { componentExts = [], overrides = {}, parserOptions = {} } = options;
|
|
852
|
-
const files = options.files ?? [
|
|
853
|
-
GLOB_SRC,
|
|
854
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
855
|
-
];
|
|
817
|
+
const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
856
818
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
857
819
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
858
820
|
const isTypeAware = !!tsconfigPath;
|
|
@@ -910,39 +872,22 @@ async function typescript(options = {}) {
|
|
|
910
872
|
}
|
|
911
873
|
},
|
|
912
874
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
913
|
-
...isTypeAware ? [
|
|
914
|
-
makeParser(true, filesTypeAware),
|
|
915
|
-
makeParser(false, files, filesTypeAware)
|
|
916
|
-
] : [makeParser(false, files)],
|
|
875
|
+
...isTypeAware ? [makeParser(true, filesTypeAware), makeParser(false, files, filesTypeAware)] : [makeParser(false, files)],
|
|
917
876
|
{
|
|
918
877
|
files,
|
|
919
878
|
name: "coderwyd:typescript:rules",
|
|
920
879
|
rules: {
|
|
921
|
-
...renameRules(
|
|
922
|
-
|
|
923
|
-
"@typescript-eslint/",
|
|
924
|
-
"ts/"
|
|
925
|
-
),
|
|
926
|
-
...renameRules(
|
|
927
|
-
pluginTs.configs.strict.rules,
|
|
928
|
-
"@typescript-eslint/",
|
|
929
|
-
"ts/"
|
|
930
|
-
),
|
|
880
|
+
...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, "@typescript-eslint/", "ts/"),
|
|
881
|
+
...renameRules(pluginTs.configs.strict.rules, "@typescript-eslint/", "ts/"),
|
|
931
882
|
"no-dupe-class-members": "off",
|
|
932
883
|
"no-loss-of-precision": "off",
|
|
933
884
|
"no-redeclare": "off",
|
|
934
885
|
"no-use-before-define": "off",
|
|
935
886
|
"no-useless-constructor": "off",
|
|
936
|
-
"ts/ban-ts-comment": [
|
|
937
|
-
"error",
|
|
938
|
-
{ "ts-ignore": "allow-with-description" }
|
|
939
|
-
],
|
|
887
|
+
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
940
888
|
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
941
889
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
942
|
-
"ts/consistent-type-imports": [
|
|
943
|
-
"error",
|
|
944
|
-
{ disallowTypeAnnotations: false, prefer: "type-imports" }
|
|
945
|
-
],
|
|
890
|
+
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
946
891
|
"ts/no-dupe-class-members": "error",
|
|
947
892
|
"ts/no-dynamic-delete": "off",
|
|
948
893
|
"ts/no-explicit-any": "off",
|
|
@@ -954,10 +899,7 @@ async function typescript(options = {}) {
|
|
|
954
899
|
"ts/no-redeclare": "error",
|
|
955
900
|
"ts/no-require-imports": "error",
|
|
956
901
|
"ts/no-unused-vars": "off",
|
|
957
|
-
"ts/no-use-before-define": [
|
|
958
|
-
"error",
|
|
959
|
-
{ classes: false, functions: false, variables: true }
|
|
960
|
-
],
|
|
902
|
+
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
961
903
|
"ts/no-useless-constructor": "off",
|
|
962
904
|
"ts/prefer-ts-expect-error": "error",
|
|
963
905
|
"ts/triple-slash-reference": "off",
|
|
@@ -1011,31 +953,64 @@ async function unicorn() {
|
|
|
1011
953
|
},
|
|
1012
954
|
rules: {
|
|
1013
955
|
"unicorn/better-regex": "error",
|
|
1014
|
-
|
|
956
|
+
"unicorn/catch-error-name": "error",
|
|
957
|
+
"unicorn/custom-error-definition": "error",
|
|
1015
958
|
"unicorn/error-message": "error",
|
|
1016
|
-
// Uppercase regex escapes
|
|
1017
959
|
"unicorn/escape-case": "error",
|
|
1018
|
-
|
|
960
|
+
"unicorn/explicit-length-check": "error",
|
|
961
|
+
// 'unicorn/filename-case': [
|
|
962
|
+
// 'error',
|
|
963
|
+
// {
|
|
964
|
+
// cases: { kebabCase: true, pascalCase: true },
|
|
965
|
+
// ignore: [/^[A-Z]+\..*$/],
|
|
966
|
+
// },
|
|
967
|
+
// ],
|
|
968
|
+
"unicorn/new-for-builtins": "error",
|
|
969
|
+
"unicorn/no-array-callback-reference": "error",
|
|
970
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
971
|
+
"unicorn/no-array-push-push": "error",
|
|
972
|
+
"unicorn/no-console-spaces": "error",
|
|
973
|
+
"unicorn/no-for-loop": "error",
|
|
974
|
+
"unicorn/no-hex-escape": "error",
|
|
1019
975
|
"unicorn/no-instanceof-array": "error",
|
|
1020
|
-
|
|
976
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
977
|
+
"unicorn/no-lonely-if": "error",
|
|
1021
978
|
"unicorn/no-new-array": "error",
|
|
1022
|
-
// Prevent deprecated `new Buffer()`
|
|
1023
979
|
"unicorn/no-new-buffer": "error",
|
|
1024
|
-
|
|
1025
|
-
"unicorn/
|
|
1026
|
-
|
|
980
|
+
"unicorn/no-static-only-class": "error",
|
|
981
|
+
"unicorn/no-unnecessary-await": "error",
|
|
982
|
+
"unicorn/no-zero-fractions": `error`,
|
|
983
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
984
|
+
"unicorn/prefer-array-find": "error",
|
|
985
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
986
|
+
"unicorn/prefer-array-index-of": "error",
|
|
987
|
+
"unicorn/prefer-array-some": "error",
|
|
988
|
+
"unicorn/prefer-at": "error",
|
|
989
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
990
|
+
"unicorn/prefer-date-now": "error",
|
|
991
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
992
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
993
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
1027
994
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
1028
|
-
// includes over indexOf when checking for existence
|
|
1029
995
|
"unicorn/prefer-includes": "error",
|
|
1030
|
-
|
|
996
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
997
|
+
"unicorn/prefer-math-trunc": "error",
|
|
998
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
999
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
1000
|
+
"unicorn/prefer-negative-index": "error",
|
|
1031
1001
|
"unicorn/prefer-node-protocol": "error",
|
|
1032
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1033
1002
|
"unicorn/prefer-number-properties": "error",
|
|
1034
|
-
|
|
1003
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
1004
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
1005
|
+
"unicorn/prefer-query-selector": "error",
|
|
1006
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
1007
|
+
"unicorn/prefer-regexp-test": "error",
|
|
1008
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
1009
|
+
"unicorn/prefer-string-slice": "error",
|
|
1035
1010
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1036
|
-
|
|
1011
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
1012
|
+
"unicorn/prefer-top-level-await": "error",
|
|
1037
1013
|
"unicorn/prefer-type-error": "error",
|
|
1038
|
-
// Use new when throwing error
|
|
1039
1014
|
"unicorn/throw-new-error": "error"
|
|
1040
1015
|
}
|
|
1041
1016
|
}
|
|
@@ -1074,9 +1049,7 @@ async function vue(options = {}) {
|
|
|
1074
1049
|
jsx: true
|
|
1075
1050
|
},
|
|
1076
1051
|
extraFileExtensions: [".vue"],
|
|
1077
|
-
parser: options.typescript ? await interopDefault(
|
|
1078
|
-
import("@typescript-eslint/parser")
|
|
1079
|
-
) : null,
|
|
1052
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1080
1053
|
sourceType: "module"
|
|
1081
1054
|
}
|
|
1082
1055
|
},
|
|
@@ -1098,12 +1071,7 @@ async function vue(options = {}) {
|
|
|
1098
1071
|
"vue/define-macros-order": [
|
|
1099
1072
|
"error",
|
|
1100
1073
|
{
|
|
1101
|
-
order: [
|
|
1102
|
-
"defineOptions",
|
|
1103
|
-
"defineProps",
|
|
1104
|
-
"defineEmits",
|
|
1105
|
-
"defineSlots"
|
|
1106
|
-
]
|
|
1074
|
+
order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
|
|
1107
1075
|
}
|
|
1108
1076
|
],
|
|
1109
1077
|
"vue/dot-location": ["error", "property"],
|
|
@@ -1111,19 +1079,27 @@ async function vue(options = {}) {
|
|
|
1111
1079
|
"vue/eqeqeq": ["error", "smart"],
|
|
1112
1080
|
"vue/html-indent": ["error", 2],
|
|
1113
1081
|
"vue/html-quotes": ["error", "double"],
|
|
1082
|
+
"vue/html-self-closing": [
|
|
1083
|
+
"error",
|
|
1084
|
+
{
|
|
1085
|
+
html: {
|
|
1086
|
+
component: "always",
|
|
1087
|
+
normal: "always",
|
|
1088
|
+
void: "any"
|
|
1089
|
+
},
|
|
1090
|
+
math: "always",
|
|
1091
|
+
svg: "always"
|
|
1092
|
+
}
|
|
1093
|
+
],
|
|
1114
1094
|
"vue/max-attributes-per-line": "off",
|
|
1115
1095
|
"vue/multi-word-component-names": "off",
|
|
1096
|
+
"vue/no-constant-condition": "warn",
|
|
1116
1097
|
"vue/no-dupe-keys": "off",
|
|
1117
1098
|
"vue/no-empty-pattern": "error",
|
|
1118
1099
|
"vue/no-extra-parens": ["error", "functions"],
|
|
1119
1100
|
"vue/no-irregular-whitespace": "error",
|
|
1120
1101
|
"vue/no-loss-of-precision": "error",
|
|
1121
|
-
"vue/no-restricted-syntax": [
|
|
1122
|
-
"error",
|
|
1123
|
-
"DebuggerStatement",
|
|
1124
|
-
"LabeledStatement",
|
|
1125
|
-
"WithStatement"
|
|
1126
|
-
],
|
|
1102
|
+
"vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
|
|
1127
1103
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1128
1104
|
"vue/no-setup-props-reactivity-loss": "off",
|
|
1129
1105
|
"vue/no-sparse-arrays": "error",
|
|
@@ -1138,6 +1114,7 @@ async function vue(options = {}) {
|
|
|
1138
1114
|
ignoreConstructors: false
|
|
1139
1115
|
}
|
|
1140
1116
|
],
|
|
1117
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1141
1118
|
"vue/prefer-separate-static-class": "error",
|
|
1142
1119
|
"vue/prefer-template": "error",
|
|
1143
1120
|
"vue/prop-name-casing": ["error", "camelCase"],
|
|
@@ -1179,10 +1156,7 @@ async function test(options = {}) {
|
|
|
1179
1156
|
name: "coderwyd:test:rules",
|
|
1180
1157
|
rules: {
|
|
1181
1158
|
"node/prefer-global/process": "off",
|
|
1182
|
-
"test/consistent-test-it": [
|
|
1183
|
-
"error",
|
|
1184
|
-
{ fn: "it", withinDescribe: "it" }
|
|
1185
|
-
],
|
|
1159
|
+
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1186
1160
|
"test/no-identical-title": "error",
|
|
1187
1161
|
"test/no-import-node-test": "error",
|
|
1188
1162
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
@@ -1210,26 +1184,14 @@ async function perfectionist() {
|
|
|
1210
1184
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1211
1185
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
1212
1186
|
async function react(options = {}) {
|
|
1213
|
-
const {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
"eslint-plugin-react",
|
|
1220
|
-
"eslint-plugin-react-hooks",
|
|
1221
|
-
"eslint-plugin-react-refresh"
|
|
1187
|
+
const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript: typescript2 = true } = options;
|
|
1188
|
+
await ensurePackages(["eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-react-refresh"]);
|
|
1189
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1190
|
+
interopDefault(import("eslint-plugin-react")),
|
|
1191
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1192
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1222
1193
|
]);
|
|
1223
|
-
const
|
|
1224
|
-
[
|
|
1225
|
-
interopDefault(import("eslint-plugin-react")),
|
|
1226
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1227
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1228
|
-
]
|
|
1229
|
-
);
|
|
1230
|
-
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1231
|
-
(i) => isPackageExists2(i)
|
|
1232
|
-
);
|
|
1194
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists2(i));
|
|
1233
1195
|
return [
|
|
1234
1196
|
{
|
|
1235
1197
|
name: "coderwyd:react:setup",
|
|
@@ -1259,10 +1221,7 @@ async function react(options = {}) {
|
|
|
1259
1221
|
"react-hooks/exhaustive-deps": "warn",
|
|
1260
1222
|
"react-hooks/rules-of-hooks": "error",
|
|
1261
1223
|
// react refresh
|
|
1262
|
-
"react-refresh/only-export-components": [
|
|
1263
|
-
"warn",
|
|
1264
|
-
{ allowConstantExport: isAllowConstantExport }
|
|
1265
|
-
],
|
|
1224
|
+
"react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }],
|
|
1266
1225
|
// recommended rules react
|
|
1267
1226
|
"react/display-name": "error",
|
|
1268
1227
|
"react/jsx-key": "error",
|
|
@@ -1301,9 +1260,7 @@ async function react(options = {}) {
|
|
|
1301
1260
|
async function unocss(options = {}) {
|
|
1302
1261
|
const { attributify = true, strict = false } = options;
|
|
1303
1262
|
await ensurePackages(["@unocss/eslint-plugin"]);
|
|
1304
|
-
const [pluginUnoCSS] = await Promise.all([
|
|
1305
|
-
interopDefault(import("@unocss/eslint-plugin"))
|
|
1306
|
-
]);
|
|
1263
|
+
const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
|
|
1307
1264
|
return [
|
|
1308
1265
|
{
|
|
1309
1266
|
name: "coderwyd:unocss",
|
|
@@ -1326,14 +1283,7 @@ async function unocss(options = {}) {
|
|
|
1326
1283
|
// src/configs/formatter.ts
|
|
1327
1284
|
async function formatter(options = {}, prettierRules2 = {}) {
|
|
1328
1285
|
await ensurePackages(["eslint-plugin-prettier"]);
|
|
1329
|
-
const {
|
|
1330
|
-
css = true,
|
|
1331
|
-
graphql,
|
|
1332
|
-
html = true,
|
|
1333
|
-
markdown,
|
|
1334
|
-
toml,
|
|
1335
|
-
yaml
|
|
1336
|
-
} = options || {};
|
|
1286
|
+
const { css = true, graphql, html = true, markdown, toml, yaml } = options || {};
|
|
1337
1287
|
const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
|
|
1338
1288
|
function createPrettierFormatter(files, parser, plugins) {
|
|
1339
1289
|
const rules = {
|
|
@@ -1390,9 +1340,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1390
1340
|
}
|
|
1391
1341
|
if (toml) {
|
|
1392
1342
|
await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
|
|
1393
|
-
const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
|
|
1394
|
-
"prettier-plugin-toml"
|
|
1395
|
-
]);
|
|
1343
|
+
const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]);
|
|
1396
1344
|
configs.push(tomlConfig);
|
|
1397
1345
|
}
|
|
1398
1346
|
return configs;
|
|
@@ -1419,9 +1367,7 @@ async function svelte(options = {}) {
|
|
|
1419
1367
|
parser: parserSvelte,
|
|
1420
1368
|
parserOptions: {
|
|
1421
1369
|
extraFileExtensions: [".svelte"],
|
|
1422
|
-
parser: options.typescript ? await interopDefault(
|
|
1423
|
-
import("@typescript-eslint/parser")
|
|
1424
|
-
) : null
|
|
1370
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1425
1371
|
}
|
|
1426
1372
|
},
|
|
1427
1373
|
name: "coderwyd:svelte:rules",
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
5
|
-
"packageManager": "pnpm@8.
|
|
4
|
+
"version": "2.1.3",
|
|
5
|
+
"packageManager": "pnpm@8.15.1",
|
|
6
6
|
"description": "Donny's ESLint config",
|
|
7
7
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
8
8
|
"license": "MIT",
|
|
@@ -68,27 +68,27 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
70
70
|
"@antfu/install-pkg": "^0.3.1",
|
|
71
|
-
"@eslint-types/jsdoc": "48.0.
|
|
72
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
71
|
+
"@eslint-types/jsdoc": "48.0.4",
|
|
72
|
+
"@eslint-types/typescript-eslint": "^6.19.1",
|
|
73
73
|
"@eslint-types/unicorn": "^50.0.1",
|
|
74
74
|
"@toml-tools/parser": "^1.0.0",
|
|
75
75
|
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
76
76
|
"@typescript-eslint/parser": "^6.18.1",
|
|
77
77
|
"eslint-config-flat-gitignore": "^0.1.2",
|
|
78
78
|
"eslint-config-prettier": "^9.1.0",
|
|
79
|
-
"eslint-plugin-antfu": "^2.1.
|
|
79
|
+
"eslint-plugin-antfu": "^2.1.2",
|
|
80
80
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
81
81
|
"eslint-plugin-i": "^2.29.1",
|
|
82
|
-
"eslint-plugin-jsdoc": "^48.0.
|
|
83
|
-
"eslint-plugin-jsonc": "^2.
|
|
82
|
+
"eslint-plugin-jsdoc": "^48.0.4",
|
|
83
|
+
"eslint-plugin-jsonc": "^2.13.0",
|
|
84
84
|
"eslint-plugin-n": "^16.6.2",
|
|
85
85
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
86
86
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
87
87
|
"eslint-plugin-prettier": "^5.1.3",
|
|
88
88
|
"eslint-plugin-unicorn": "^50.0.1",
|
|
89
89
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
90
|
-
"eslint-plugin-vitest": "^0.3.
|
|
91
|
-
"eslint-plugin-vue": "^9.
|
|
90
|
+
"eslint-plugin-vitest": "^0.3.21",
|
|
91
|
+
"eslint-plugin-vue": "^9.21.1",
|
|
92
92
|
"globals": "^13.24.0",
|
|
93
93
|
"jsonc-eslint-parser": "^2.4.0",
|
|
94
94
|
"local-pkg": "^0.5.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"prettier": "^3.2.4",
|
|
98
98
|
"prettier-plugin-toml": "^2.0.1",
|
|
99
99
|
"prompts": "^2.4.2",
|
|
100
|
-
"vue-eslint-parser": "^9.4.
|
|
100
|
+
"vue-eslint-parser": "^9.4.2",
|
|
101
101
|
"yargs": "^17.7.2"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@types/node": "^20.10.8",
|
|
108
108
|
"@types/prompts": "^2.4.9",
|
|
109
109
|
"@types/yargs": "^17.0.32",
|
|
110
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
110
|
+
"@unocss/eslint-plugin": "^0.58.4",
|
|
111
111
|
"bumpp": "^9.3.0",
|
|
112
112
|
"eslint": "^8.56.0",
|
|
113
113
|
"eslint-flat-config-viewer": "^0.1.11",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"execa": "^8.0.1",
|
|
120
120
|
"fast-glob": "^3.3.2",
|
|
121
121
|
"fs-extra": "^11.2.0",
|
|
122
|
-
"lint-staged": "^15.2.
|
|
122
|
+
"lint-staged": "^15.2.1",
|
|
123
123
|
"rimraf": "^5.0.5",
|
|
124
124
|
"simple-git-hooks": "^2.9.0",
|
|
125
125
|
"svelte-eslint-parser": "^0.33.1",
|
|
@@ -136,6 +136,7 @@
|
|
|
136
136
|
"build": "tsup",
|
|
137
137
|
"dev": "tsup --format esm,cjs --watch & eslint-flat-config-viewer",
|
|
138
138
|
"lint": "eslint .",
|
|
139
|
+
"lint:fix": "eslint . --fix",
|
|
139
140
|
"release": "bumpp && pnpm publish",
|
|
140
141
|
"typecheck": "tsc --noEmit"
|
|
141
142
|
}
|