@coderwyd/eslint-config 2.1.1 → 2.1.2

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 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.1";
49
+ var version = "2.1.2";
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.3",
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.0",
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
- `Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
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.1";
20
+ var version = "2.1.2";
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.3",
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.0",
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
- `Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
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
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
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",
@@ -1108,9 +1050,7 @@ async function vue(options = {}) {
1108
1050
  jsx: true
1109
1051
  },
1110
1052
  extraFileExtensions: [".vue"],
1111
- parser: options.typescript ? await interopDefault(
1112
- import("@typescript-eslint/parser")
1113
- ) : null,
1053
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1114
1054
  sourceType: "module"
1115
1055
  }
1116
1056
  },
@@ -1132,12 +1072,7 @@ async function vue(options = {}) {
1132
1072
  "vue/define-macros-order": [
1133
1073
  "error",
1134
1074
  {
1135
- order: [
1136
- "defineOptions",
1137
- "defineProps",
1138
- "defineEmits",
1139
- "defineSlots"
1140
- ]
1075
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1141
1076
  }
1142
1077
  ],
1143
1078
  "vue/dot-location": ["error", "property"],
@@ -1145,19 +1080,27 @@ async function vue(options = {}) {
1145
1080
  "vue/eqeqeq": ["error", "smart"],
1146
1081
  "vue/html-indent": ["error", 2],
1147
1082
  "vue/html-quotes": ["error", "double"],
1083
+ "vue/html-self-closing": [
1084
+ "error",
1085
+ {
1086
+ html: {
1087
+ component: "always",
1088
+ normal: "always",
1089
+ void: "any"
1090
+ },
1091
+ math: "always",
1092
+ svg: "always"
1093
+ }
1094
+ ],
1148
1095
  "vue/max-attributes-per-line": "off",
1149
1096
  "vue/multi-word-component-names": "off",
1097
+ "vue/no-constant-condition": "warn",
1150
1098
  "vue/no-dupe-keys": "off",
1151
1099
  "vue/no-empty-pattern": "error",
1152
1100
  "vue/no-extra-parens": ["error", "functions"],
1153
1101
  "vue/no-irregular-whitespace": "error",
1154
1102
  "vue/no-loss-of-precision": "error",
1155
- "vue/no-restricted-syntax": [
1156
- "error",
1157
- "DebuggerStatement",
1158
- "LabeledStatement",
1159
- "WithStatement"
1160
- ],
1103
+ "vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
1161
1104
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
1162
1105
  "vue/no-setup-props-reactivity-loss": "off",
1163
1106
  "vue/no-sparse-arrays": "error",
@@ -1172,6 +1115,7 @@ async function vue(options = {}) {
1172
1115
  ignoreConstructors: false
1173
1116
  }
1174
1117
  ],
1118
+ "vue/padding-line-between-blocks": ["error", "always"],
1175
1119
  "vue/prefer-separate-static-class": "error",
1176
1120
  "vue/prefer-template": "error",
1177
1121
  "vue/prop-name-casing": ["error", "camelCase"],
@@ -1213,10 +1157,7 @@ async function test(options = {}) {
1213
1157
  name: "coderwyd:test:rules",
1214
1158
  rules: {
1215
1159
  "node/prefer-global/process": "off",
1216
- "test/consistent-test-it": [
1217
- "error",
1218
- { fn: "it", withinDescribe: "it" }
1219
- ],
1160
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1220
1161
  "test/no-identical-title": "error",
1221
1162
  "test/no-import-node-test": "error",
1222
1163
  "test/no-only-tests": isInEditor ? "off" : "error",
@@ -1244,26 +1185,14 @@ async function perfectionist() {
1244
1185
  var import_local_pkg2 = require("local-pkg");
1245
1186
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1246
1187
  async function react(options = {}) {
1247
- const {
1248
- files = [GLOB_JSX, GLOB_TSX],
1249
- overrides = {},
1250
- typescript: typescript2 = true
1251
- } = options;
1252
- await ensurePackages([
1253
- "eslint-plugin-react",
1254
- "eslint-plugin-react-hooks",
1255
- "eslint-plugin-react-refresh"
1188
+ const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript: typescript2 = true } = options;
1189
+ await ensurePackages(["eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-react-refresh"]);
1190
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1191
+ interopDefault(import("eslint-plugin-react")),
1192
+ interopDefault(import("eslint-plugin-react-hooks")),
1193
+ interopDefault(import("eslint-plugin-react-refresh"))
1256
1194
  ]);
1257
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
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
- );
1195
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1267
1196
  return [
1268
1197
  {
1269
1198
  name: "coderwyd:react:setup",
@@ -1293,10 +1222,7 @@ async function react(options = {}) {
1293
1222
  "react-hooks/exhaustive-deps": "warn",
1294
1223
  "react-hooks/rules-of-hooks": "error",
1295
1224
  // react refresh
1296
- "react-refresh/only-export-components": [
1297
- "warn",
1298
- { allowConstantExport: isAllowConstantExport }
1299
- ],
1225
+ "react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }],
1300
1226
  // recommended rules react
1301
1227
  "react/display-name": "error",
1302
1228
  "react/jsx-key": "error",
@@ -1335,9 +1261,7 @@ async function react(options = {}) {
1335
1261
  async function unocss(options = {}) {
1336
1262
  const { attributify = true, strict = false } = options;
1337
1263
  await ensurePackages(["@unocss/eslint-plugin"]);
1338
- const [pluginUnoCSS] = await Promise.all([
1339
- interopDefault(import("@unocss/eslint-plugin"))
1340
- ]);
1264
+ const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
1341
1265
  return [
1342
1266
  {
1343
1267
  name: "coderwyd:unocss",
@@ -1360,14 +1284,7 @@ async function unocss(options = {}) {
1360
1284
  // src/configs/formatter.ts
1361
1285
  async function formatter(options = {}, prettierRules2 = {}) {
1362
1286
  await ensurePackages(["eslint-plugin-prettier"]);
1363
- const {
1364
- css = true,
1365
- graphql,
1366
- html = true,
1367
- markdown,
1368
- toml,
1369
- yaml
1370
- } = options || {};
1287
+ const { css = true, graphql, html = true, markdown, toml, yaml } = options || {};
1371
1288
  const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1372
1289
  function createPrettierFormatter(files, parser, plugins) {
1373
1290
  const rules = {
@@ -1424,9 +1341,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1424
1341
  }
1425
1342
  if (toml) {
1426
1343
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1427
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1428
- "prettier-plugin-toml"
1429
- ]);
1344
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]);
1430
1345
  configs.push(tomlConfig);
1431
1346
  }
1432
1347
  return configs;
@@ -1453,9 +1368,7 @@ async function svelte(options = {}) {
1453
1368
  parser: parserSvelte,
1454
1369
  parserOptions: {
1455
1370
  extraFileExtensions: [".svelte"],
1456
- parser: options.typescript ? await interopDefault(
1457
- import("@typescript-eslint/parser")
1458
- ) : null
1371
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1459
1372
  }
1460
1373
  },
1461
1374
  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
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
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",
@@ -1074,9 +1016,7 @@ async function vue(options = {}) {
1074
1016
  jsx: true
1075
1017
  },
1076
1018
  extraFileExtensions: [".vue"],
1077
- parser: options.typescript ? await interopDefault(
1078
- import("@typescript-eslint/parser")
1079
- ) : null,
1019
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1080
1020
  sourceType: "module"
1081
1021
  }
1082
1022
  },
@@ -1098,12 +1038,7 @@ async function vue(options = {}) {
1098
1038
  "vue/define-macros-order": [
1099
1039
  "error",
1100
1040
  {
1101
- order: [
1102
- "defineOptions",
1103
- "defineProps",
1104
- "defineEmits",
1105
- "defineSlots"
1106
- ]
1041
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1107
1042
  }
1108
1043
  ],
1109
1044
  "vue/dot-location": ["error", "property"],
@@ -1111,19 +1046,27 @@ async function vue(options = {}) {
1111
1046
  "vue/eqeqeq": ["error", "smart"],
1112
1047
  "vue/html-indent": ["error", 2],
1113
1048
  "vue/html-quotes": ["error", "double"],
1049
+ "vue/html-self-closing": [
1050
+ "error",
1051
+ {
1052
+ html: {
1053
+ component: "always",
1054
+ normal: "always",
1055
+ void: "any"
1056
+ },
1057
+ math: "always",
1058
+ svg: "always"
1059
+ }
1060
+ ],
1114
1061
  "vue/max-attributes-per-line": "off",
1115
1062
  "vue/multi-word-component-names": "off",
1063
+ "vue/no-constant-condition": "warn",
1116
1064
  "vue/no-dupe-keys": "off",
1117
1065
  "vue/no-empty-pattern": "error",
1118
1066
  "vue/no-extra-parens": ["error", "functions"],
1119
1067
  "vue/no-irregular-whitespace": "error",
1120
1068
  "vue/no-loss-of-precision": "error",
1121
- "vue/no-restricted-syntax": [
1122
- "error",
1123
- "DebuggerStatement",
1124
- "LabeledStatement",
1125
- "WithStatement"
1126
- ],
1069
+ "vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
1127
1070
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
1128
1071
  "vue/no-setup-props-reactivity-loss": "off",
1129
1072
  "vue/no-sparse-arrays": "error",
@@ -1138,6 +1081,7 @@ async function vue(options = {}) {
1138
1081
  ignoreConstructors: false
1139
1082
  }
1140
1083
  ],
1084
+ "vue/padding-line-between-blocks": ["error", "always"],
1141
1085
  "vue/prefer-separate-static-class": "error",
1142
1086
  "vue/prefer-template": "error",
1143
1087
  "vue/prop-name-casing": ["error", "camelCase"],
@@ -1179,10 +1123,7 @@ async function test(options = {}) {
1179
1123
  name: "coderwyd:test:rules",
1180
1124
  rules: {
1181
1125
  "node/prefer-global/process": "off",
1182
- "test/consistent-test-it": [
1183
- "error",
1184
- { fn: "it", withinDescribe: "it" }
1185
- ],
1126
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1186
1127
  "test/no-identical-title": "error",
1187
1128
  "test/no-import-node-test": "error",
1188
1129
  "test/no-only-tests": isInEditor ? "off" : "error",
@@ -1210,26 +1151,14 @@ async function perfectionist() {
1210
1151
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1211
1152
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1212
1153
  async function react(options = {}) {
1213
- const {
1214
- files = [GLOB_JSX, GLOB_TSX],
1215
- overrides = {},
1216
- typescript: typescript2 = true
1217
- } = options;
1218
- await ensurePackages([
1219
- "eslint-plugin-react",
1220
- "eslint-plugin-react-hooks",
1221
- "eslint-plugin-react-refresh"
1154
+ const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript: typescript2 = true } = options;
1155
+ await ensurePackages(["eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-react-refresh"]);
1156
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1157
+ interopDefault(import("eslint-plugin-react")),
1158
+ interopDefault(import("eslint-plugin-react-hooks")),
1159
+ interopDefault(import("eslint-plugin-react-refresh"))
1222
1160
  ]);
1223
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
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
- );
1161
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists2(i));
1233
1162
  return [
1234
1163
  {
1235
1164
  name: "coderwyd:react:setup",
@@ -1259,10 +1188,7 @@ async function react(options = {}) {
1259
1188
  "react-hooks/exhaustive-deps": "warn",
1260
1189
  "react-hooks/rules-of-hooks": "error",
1261
1190
  // react refresh
1262
- "react-refresh/only-export-components": [
1263
- "warn",
1264
- { allowConstantExport: isAllowConstantExport }
1265
- ],
1191
+ "react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }],
1266
1192
  // recommended rules react
1267
1193
  "react/display-name": "error",
1268
1194
  "react/jsx-key": "error",
@@ -1301,9 +1227,7 @@ async function react(options = {}) {
1301
1227
  async function unocss(options = {}) {
1302
1228
  const { attributify = true, strict = false } = options;
1303
1229
  await ensurePackages(["@unocss/eslint-plugin"]);
1304
- const [pluginUnoCSS] = await Promise.all([
1305
- interopDefault(import("@unocss/eslint-plugin"))
1306
- ]);
1230
+ const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
1307
1231
  return [
1308
1232
  {
1309
1233
  name: "coderwyd:unocss",
@@ -1326,14 +1250,7 @@ async function unocss(options = {}) {
1326
1250
  // src/configs/formatter.ts
1327
1251
  async function formatter(options = {}, prettierRules2 = {}) {
1328
1252
  await ensurePackages(["eslint-plugin-prettier"]);
1329
- const {
1330
- css = true,
1331
- graphql,
1332
- html = true,
1333
- markdown,
1334
- toml,
1335
- yaml
1336
- } = options || {};
1253
+ const { css = true, graphql, html = true, markdown, toml, yaml } = options || {};
1337
1254
  const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1338
1255
  function createPrettierFormatter(files, parser, plugins) {
1339
1256
  const rules = {
@@ -1390,9 +1307,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1390
1307
  }
1391
1308
  if (toml) {
1392
1309
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1393
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1394
- "prettier-plugin-toml"
1395
- ]);
1310
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]);
1396
1311
  configs.push(tomlConfig);
1397
1312
  }
1398
1313
  return configs;
@@ -1419,9 +1334,7 @@ async function svelte(options = {}) {
1419
1334
  parser: parserSvelte,
1420
1335
  parserOptions: {
1421
1336
  extraFileExtensions: [".svelte"],
1422
- parser: options.typescript ? await interopDefault(
1423
- import("@typescript-eslint/parser")
1424
- ) : null
1337
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1425
1338
  }
1426
1339
  },
1427
1340
  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.1",
5
- "packageManager": "pnpm@8.14.1",
4
+ "version": "2.1.2",
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.2",
72
- "@eslint-types/typescript-eslint": "^6.18.1",
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.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.2",
83
- "eslint-plugin-jsonc": "^2.12.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.20",
91
- "eslint-plugin-vue": "^9.20.1",
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.0",
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.3",
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.0",
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
  }