@coderwyd/eslint-config 2.1.5 → 2.1.7

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/README.md CHANGED
@@ -218,10 +218,10 @@ interface OptionsConfig {
218
218
  * {
219
219
  * "html": true,
220
220
  * "css": true,
221
- * "graphql": true,
222
- * "markdown": true
223
- * "yaml": true
224
- * "toml": true
221
+ * "graphql": false,
222
+ * "markdown": false
223
+ * "yaml": false
224
+ * "toml": false
225
225
  * }
226
226
  */
227
227
  formatter?: OptionsFormatters
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.5";
49
+ var version = "2.1.7";
50
50
  var devDependencies = {
51
51
  "@antfu/ni": "^0.21.12",
52
52
  "@types/eslint": "^8.56.2",
@@ -131,7 +131,11 @@ 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(import_picocolors2.default.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
134
+ console.log(
135
+ import_picocolors2.default.yellow(
136
+ `${WARN} eslint.config.js already exists, migration wizard exited.`
137
+ )
138
+ );
135
139
  return import_node_process.default.exit(1);
136
140
  }
137
141
  if (!SKIP_GIT_CHECK && !isGitClean()) {
@@ -163,7 +167,9 @@ async function run(options = {}) {
163
167
  if (glob.type === "ignore")
164
168
  eslintIgnores.push(...glob.patterns);
165
169
  else if (glob.type === "unignore")
166
- eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
170
+ eslintIgnores.push(
171
+ ...glob.patterns.map((pattern) => `!${pattern}`)
172
+ );
167
173
  }
168
174
  }
169
175
  let eslintConfigContent = "";
@@ -240,8 +246,10 @@ ${coderwydConfig}
240
246
  }
241
247
  }
242
248
  console.log(import_picocolors2.default.green(`${CHECK} migration completed`));
243
- console.log(`Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
244
- `);
249
+ console.log(
250
+ `Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
251
+ `
252
+ );
245
253
  }
246
254
 
247
255
  // 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.5";
20
+ var version = "2.1.7";
21
21
  var devDependencies = {
22
22
  "@antfu/ni": "^0.21.12",
23
23
  "@types/eslint": "^8.56.2",
@@ -102,7 +102,11 @@ 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(c2.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
105
+ console.log(
106
+ c2.yellow(
107
+ `${WARN} eslint.config.js already exists, migration wizard exited.`
108
+ )
109
+ );
106
110
  return process.exit(1);
107
111
  }
108
112
  if (!SKIP_GIT_CHECK && !isGitClean()) {
@@ -134,7 +138,9 @@ async function run(options = {}) {
134
138
  if (glob.type === "ignore")
135
139
  eslintIgnores.push(...glob.patterns);
136
140
  else if (glob.type === "unignore")
137
- eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
141
+ eslintIgnores.push(
142
+ ...glob.patterns.map((pattern) => `!${pattern}`)
143
+ );
138
144
  }
139
145
  }
140
146
  let eslintConfigContent = "";
@@ -211,8 +217,10 @@ ${coderwydConfig}
211
217
  }
212
218
  }
213
219
  console.log(c2.green(`${CHECK} migration completed`));
214
- console.log(`Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
215
- `);
220
+ console.log(
221
+ `Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
222
+ `
223
+ );
216
224
  }
217
225
 
218
226
  // src/cli/index.ts
package/dist/index.cjs CHANGED
@@ -156,7 +156,6 @@ 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": ["error", { considerComments: true, count: 1 }],
160
159
  "import/no-duplicates": "error",
161
160
  "import/no-mutable-exports": "error",
162
161
  "import/no-named-default": "error",
@@ -165,11 +164,27 @@ async function imports() {
165
164
  "import/order": [
166
165
  "error",
167
166
  {
168
- groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
167
+ groups: [
168
+ "builtin",
169
+ "external",
170
+ "internal",
171
+ "parent",
172
+ "sibling",
173
+ "index",
174
+ "object",
175
+ "type"
176
+ ],
169
177
  pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
170
178
  pathGroupsExcludedImportTypes: ["type"]
171
179
  }
172
- ]
180
+ ],
181
+ ...{
182
+ // format
183
+ "import/newline-after-import": [
184
+ "error",
185
+ { considerComments: true, count: 1 }
186
+ ]
187
+ }
173
188
  }
174
189
  },
175
190
  {
@@ -216,14 +231,20 @@ async function javascript(options = {}) {
216
231
  "unused-imports": import_eslint_plugin_unused_imports.default
217
232
  },
218
233
  rules: {
219
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
234
+ "accessor-pairs": [
235
+ "error",
236
+ { enforceForClassMembers: true, setWithoutGet: true }
237
+ ],
220
238
  "array-callback-return": "error",
221
239
  "block-scoped-var": "error",
222
240
  "constructor-super": "error",
223
241
  "default-case-last": "error",
224
242
  "dot-notation": ["error", { allowKeywords: true }],
225
243
  eqeqeq: ["error", "smart"],
226
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
244
+ "new-cap": [
245
+ "error",
246
+ { capIsNew: false, newIsCap: true, properties: true }
247
+ ],
227
248
  "no-alert": "error",
228
249
  "no-array-constructor": "error",
229
250
  "no-async-promise-executor": "error",
@@ -344,7 +365,10 @@ async function javascript(options = {}) {
344
365
  vars: "all"
345
366
  }
346
367
  ],
347
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
368
+ "no-use-before-define": [
369
+ "error",
370
+ { classes: false, functions: false, variables: true }
371
+ ],
348
372
  "no-useless-backreference": "error",
349
373
  "no-useless-call": "error",
350
374
  "no-useless-catch": "error",
@@ -405,7 +429,10 @@ async function javascript(options = {}) {
405
429
  varsIgnorePattern: "^_"
406
430
  }
407
431
  ],
408
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
432
+ "use-isnan": [
433
+ "error",
434
+ { enforceForIndexOf: true, enforceForSwitchCase: true }
435
+ ],
409
436
  "valid-typeof": ["error", { requireStringLiterals: true }],
410
437
  "vars-on-top": "error",
411
438
  yoda: ["error", "never"],
@@ -418,6 +445,12 @@ async function javascript(options = {}) {
418
445
  rules: {
419
446
  "no-console": "off"
420
447
  }
448
+ },
449
+ {
450
+ files: ["**/*.{test,spec}.js?(x)"],
451
+ rules: {
452
+ "no-unused-expressions": "off"
453
+ }
421
454
  }
422
455
  ];
423
456
  }
@@ -488,7 +521,9 @@ async function ensurePackages(packages) {
488
521
  }
489
522
  ]);
490
523
  if (result)
491
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
524
+ await import("@antfu/install-pkg").then(
525
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
526
+ );
492
527
  }
493
528
  async function loadPrettierConfig(cwd) {
494
529
  let prettierConfig = {};
@@ -533,7 +568,12 @@ async function jsdoc() {
533
568
  "jsdoc/require-property-name": "warn",
534
569
  "jsdoc/require-returns-check": "warn",
535
570
  "jsdoc/require-returns-description": "warn",
536
- "jsdoc/require-yields-check": "warn"
571
+ "jsdoc/require-yields-check": "warn",
572
+ ...{
573
+ // format
574
+ "jsdoc/check-alignment": "warn",
575
+ "jsdoc/multiline-blocks": "warn"
576
+ }
537
577
  }
538
578
  }
539
579
  ];
@@ -586,6 +626,28 @@ async function jsonc(options = {}) {
586
626
  "jsonc/space-unary-ops": "error",
587
627
  "jsonc/valid-json-number": "error",
588
628
  "jsonc/vue-custom-block/no-parsing-error": "error",
629
+ ...{
630
+ // format
631
+ "jsonc/array-bracket-spacing": ["error", "never"],
632
+ "jsonc/comma-dangle": ["error", "never"],
633
+ "jsonc/comma-style": ["error", "last"],
634
+ "jsonc/indent": ["error", 2],
635
+ "jsonc/key-spacing": [
636
+ "error",
637
+ { afterColon: true, beforeColon: false }
638
+ ],
639
+ "jsonc/object-curly-newline": [
640
+ "error",
641
+ { consistent: true, multiline: true }
642
+ ],
643
+ "jsonc/object-curly-spacing": ["error", "always"],
644
+ "jsonc/object-property-newline": [
645
+ "error",
646
+ { allowMultiplePropertiesPerLine: true }
647
+ ],
648
+ "jsonc/quote-props": "error",
649
+ "jsonc/quotes": "error"
650
+ },
589
651
  ...overrides
590
652
  }
591
653
  }
@@ -704,7 +766,14 @@ function sortTsconfig() {
704
766
  "jsonc/sort-keys": [
705
767
  "error",
706
768
  {
707
- order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
769
+ order: [
770
+ "extends",
771
+ "compilerOptions",
772
+ "references",
773
+ "files",
774
+ "include",
775
+ "exclude"
776
+ ],
708
777
  pathPattern: "^$"
709
778
  },
710
779
  {
@@ -848,7 +917,10 @@ async function prettier(rules) {
848
917
  var import_node_process2 = __toESM(require("process"), 1);
849
918
  async function typescript(options = {}) {
850
919
  const { componentExts = [], overrides = {}, parserOptions = {} } = options;
851
- const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
920
+ const files = options.files ?? [
921
+ GLOB_SRC,
922
+ ...componentExts.map((ext) => `**/*.${ext}`)
923
+ ];
852
924
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
853
925
  const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
854
926
  const isTypeAware = !!tsconfigPath;
@@ -906,22 +978,41 @@ async function typescript(options = {}) {
906
978
  }
907
979
  },
908
980
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
909
- ...isTypeAware ? [makeParser(true, filesTypeAware), makeParser(false, files, filesTypeAware)] : [makeParser(false, files)],
981
+ ...isTypeAware ? [
982
+ makeParser(true, filesTypeAware),
983
+ makeParser(false, files, filesTypeAware)
984
+ ] : [makeParser(false, files)],
910
985
  {
911
986
  files,
912
987
  name: "coderwyd:typescript:rules",
913
988
  rules: {
914
- ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, "@typescript-eslint/", "ts/"),
915
- ...renameRules(pluginTs.configs.strict.rules, "@typescript-eslint/", "ts/"),
989
+ ...renameRules(
990
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
991
+ "@typescript-eslint/",
992
+ "ts/"
993
+ ),
994
+ ...renameRules(
995
+ pluginTs.configs.strict.rules,
996
+ "@typescript-eslint/",
997
+ "ts/"
998
+ ),
916
999
  "no-dupe-class-members": "off",
917
1000
  "no-loss-of-precision": "off",
918
1001
  "no-redeclare": "off",
919
1002
  "no-use-before-define": "off",
920
1003
  "no-useless-constructor": "off",
921
- "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1004
+ "ts/ban-ts-comment": [
1005
+ "error",
1006
+ { "ts-ignore": "allow-with-description" }
1007
+ ],
922
1008
  "ts/ban-types": ["error", { types: { Function: false } }],
923
1009
  "ts/consistent-type-definitions": ["error", "interface"],
924
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1010
+ "ts/consistent-type-imports": [
1011
+ "error",
1012
+ { disallowTypeAnnotations: false, prefer: "type-imports" }
1013
+ ],
1014
+ "ts/method-signature-style": ["error", "property"],
1015
+ // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
925
1016
  "ts/no-dupe-class-members": "error",
926
1017
  "ts/no-dynamic-delete": "off",
927
1018
  "ts/no-explicit-any": "off",
@@ -933,7 +1024,10 @@ async function typescript(options = {}) {
933
1024
  "ts/no-redeclare": "error",
934
1025
  "ts/no-require-imports": "error",
935
1026
  "ts/no-unused-vars": "off",
936
- "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1027
+ "ts/no-use-before-define": [
1028
+ "error",
1029
+ { classes: false, functions: false, variables: true }
1030
+ ],
937
1031
  "ts/no-useless-constructor": "off",
938
1032
  "ts/prefer-ts-expect-error": "error",
939
1033
  "ts/triple-slash-reference": "off",
@@ -1083,7 +1177,9 @@ async function vue(options = {}) {
1083
1177
  jsx: true
1084
1178
  },
1085
1179
  extraFileExtensions: [".vue"],
1086
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1180
+ parser: options.typescript ? await interopDefault(
1181
+ import("@typescript-eslint/parser")
1182
+ ) : null,
1087
1183
  sourceType: "module"
1088
1184
  }
1089
1185
  },
@@ -1105,7 +1201,12 @@ async function vue(options = {}) {
1105
1201
  "vue/define-macros-order": [
1106
1202
  "error",
1107
1203
  {
1108
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1204
+ order: [
1205
+ "defineOptions",
1206
+ "defineProps",
1207
+ "defineEmits",
1208
+ "defineSlots"
1209
+ ]
1109
1210
  }
1110
1211
  ],
1111
1212
  "vue/dot-location": ["error", "property"],
@@ -1133,7 +1234,12 @@ async function vue(options = {}) {
1133
1234
  "vue/no-extra-parens": ["error", "functions"],
1134
1235
  "vue/no-irregular-whitespace": "error",
1135
1236
  "vue/no-loss-of-precision": "error",
1136
- "vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
1237
+ "vue/no-restricted-syntax": [
1238
+ "error",
1239
+ "DebuggerStatement",
1240
+ "LabeledStatement",
1241
+ "WithStatement"
1242
+ ],
1137
1243
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
1138
1244
  "vue/no-setup-props-reactivity-loss": "off",
1139
1245
  "vue/no-sparse-arrays": "error",
@@ -1148,7 +1254,6 @@ async function vue(options = {}) {
1148
1254
  ignoreConstructors: false
1149
1255
  }
1150
1256
  ],
1151
- "vue/padding-line-between-blocks": ["error", "always"],
1152
1257
  "vue/prefer-separate-static-class": "error",
1153
1258
  "vue/prefer-template": "error",
1154
1259
  "vue/prop-name-casing": ["error", "camelCase"],
@@ -1157,6 +1262,46 @@ async function vue(options = {}) {
1157
1262
  "vue/space-infix-ops": "error",
1158
1263
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1159
1264
  "vue/valid-define-options": "warn",
1265
+ ...{
1266
+ // format
1267
+ "vue/array-bracket-spacing": ["error", "never"],
1268
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1269
+ "vue/block-spacing": ["error", "always"],
1270
+ "vue/block-tag-newline": [
1271
+ "error",
1272
+ {
1273
+ multiline: "always",
1274
+ singleline: "always"
1275
+ }
1276
+ ],
1277
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1278
+ "vue/comma-dangle": ["error", "always-multiline"],
1279
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1280
+ "vue/comma-style": ["error", "last"],
1281
+ "vue/html-comment-content-spacing": [
1282
+ "error",
1283
+ "always",
1284
+ {
1285
+ exceptions: ["-"]
1286
+ }
1287
+ ],
1288
+ "vue/key-spacing": [
1289
+ "error",
1290
+ { afterColon: true, beforeColon: false }
1291
+ ],
1292
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1293
+ "vue/object-curly-newline": "off",
1294
+ "vue/object-curly-spacing": ["error", "always"],
1295
+ "vue/object-property-newline": [
1296
+ "error",
1297
+ { allowMultiplePropertiesPerLine: true }
1298
+ ],
1299
+ "vue/operator-linebreak": ["error", "before"],
1300
+ "vue/padding-line-between-blocks": ["error", "always"],
1301
+ "vue/quote-props": ["error", "consistent-as-needed"],
1302
+ "vue/space-in-parens": ["error", "never"],
1303
+ "vue/template-curly-spacing": "error"
1304
+ },
1160
1305
  ...overrides
1161
1306
  }
1162
1307
  }
@@ -1190,7 +1335,10 @@ async function test(options = {}) {
1190
1335
  name: "coderwyd:test:rules",
1191
1336
  rules: {
1192
1337
  "node/prefer-global/process": "off",
1193
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1338
+ "test/consistent-test-it": [
1339
+ "error",
1340
+ { fn: "it", withinDescribe: "it" }
1341
+ ],
1194
1342
  "test/no-identical-title": "error",
1195
1343
  "test/no-import-node-test": "error",
1196
1344
  "test/no-only-tests": isInEditor ? "off" : "error",
@@ -1218,14 +1366,26 @@ async function perfectionist() {
1218
1366
  var import_local_pkg2 = require("local-pkg");
1219
1367
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1220
1368
  async function react(options = {}) {
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"))
1369
+ const {
1370
+ files = [GLOB_JSX, GLOB_TSX],
1371
+ overrides = {},
1372
+ typescript: typescript2 = true
1373
+ } = options;
1374
+ await ensurePackages([
1375
+ "eslint-plugin-react",
1376
+ "eslint-plugin-react-hooks",
1377
+ "eslint-plugin-react-refresh"
1227
1378
  ]);
1228
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1379
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1380
+ [
1381
+ interopDefault(import("eslint-plugin-react")),
1382
+ interopDefault(import("eslint-plugin-react-hooks")),
1383
+ interopDefault(import("eslint-plugin-react-refresh"))
1384
+ ]
1385
+ );
1386
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1387
+ (i) => (0, import_local_pkg2.isPackageExists)(i)
1388
+ );
1229
1389
  return [
1230
1390
  {
1231
1391
  name: "coderwyd:react:setup",
@@ -1255,7 +1415,10 @@ async function react(options = {}) {
1255
1415
  "react-hooks/exhaustive-deps": "warn",
1256
1416
  "react-hooks/rules-of-hooks": "error",
1257
1417
  // react refresh
1258
- "react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }],
1418
+ "react-refresh/only-export-components": [
1419
+ "warn",
1420
+ { allowConstantExport: isAllowConstantExport }
1421
+ ],
1259
1422
  // recommended rules react
1260
1423
  "react/display-name": "error",
1261
1424
  "react/jsx-key": "error",
@@ -1294,7 +1457,9 @@ async function react(options = {}) {
1294
1457
  async function unocss(options = {}) {
1295
1458
  const { attributify = true, strict = false } = options;
1296
1459
  await ensurePackages(["@unocss/eslint-plugin"]);
1297
- const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
1460
+ const [pluginUnoCSS] = await Promise.all([
1461
+ interopDefault(import("@unocss/eslint-plugin"))
1462
+ ]);
1298
1463
  return [
1299
1464
  {
1300
1465
  name: "coderwyd:unocss",
@@ -1317,7 +1482,14 @@ async function unocss(options = {}) {
1317
1482
  // src/configs/formatter.ts
1318
1483
  async function formatter(options = {}, prettierRules2 = {}) {
1319
1484
  await ensurePackages(["eslint-plugin-prettier"]);
1320
- const { css = true, graphql, html = true, markdown, toml, yaml } = options || {};
1485
+ const {
1486
+ css = true,
1487
+ graphql,
1488
+ html = true,
1489
+ markdown,
1490
+ toml,
1491
+ yaml
1492
+ } = options || {};
1321
1493
  const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1322
1494
  function createPrettierFormatter(files, parser, plugins) {
1323
1495
  const rules = {
@@ -1342,7 +1514,10 @@ async function formatter(options = {}, prettierRules2 = {}) {
1342
1514
  prettier: pluginPrettier
1343
1515
  },
1344
1516
  rules: {
1345
- "prettier/prettier": ["warn", parser === "markdown" ? markdownRules : rules]
1517
+ "prettier/prettier": [
1518
+ "warn",
1519
+ parser === "markdown" ? markdownRules : rules
1520
+ ]
1346
1521
  }
1347
1522
  };
1348
1523
  return config;
@@ -1355,16 +1530,16 @@ async function formatter(options = {}, prettierRules2 = {}) {
1355
1530
  }
1356
1531
  }
1357
1532
  ];
1533
+ if (html) {
1534
+ const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1535
+ configs.push(htmlConfig);
1536
+ }
1358
1537
  if (css) {
1359
1538
  const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1360
1539
  const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1361
1540
  const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1362
1541
  configs.push(cssConfig, scssConfig, lessConfig);
1363
1542
  }
1364
- if (html) {
1365
- const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1366
- configs.push(htmlConfig);
1367
- }
1368
1543
  if (markdown) {
1369
1544
  const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1370
1545
  configs.push(markdownConfig);
@@ -1379,7 +1554,9 @@ async function formatter(options = {}, prettierRules2 = {}) {
1379
1554
  }
1380
1555
  if (toml) {
1381
1556
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1382
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]);
1557
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1558
+ "prettier-plugin-toml"
1559
+ ]);
1383
1560
  configs.push(tomlConfig);
1384
1561
  }
1385
1562
  return configs;
@@ -1406,7 +1583,9 @@ async function svelte(options = {}) {
1406
1583
  parser: parserSvelte,
1407
1584
  parserOptions: {
1408
1585
  extraFileExtensions: [".svelte"],
1409
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1586
+ parser: options.typescript ? await interopDefault(
1587
+ import("@typescript-eslint/parser")
1588
+ ) : null
1410
1589
  }
1411
1590
  },
1412
1591
  name: "coderwyd:svelte:rules",
@@ -1455,6 +1634,22 @@ async function svelte(options = {}) {
1455
1634
  varsIgnorePattern: "^(_|\\$\\$Props$)"
1456
1635
  }
1457
1636
  ],
1637
+ ...{
1638
+ // format
1639
+ "style/no-trailing-spaces": "off",
1640
+ // superseded by svelte/no-trailing-spaces
1641
+ "svelte/derived-has-same-inputs-outputs": "error",
1642
+ "svelte/html-closing-bracket-spacing": "error",
1643
+ "svelte/html-quotes": ["error", { prefer: "single" }],
1644
+ "svelte/indent": [
1645
+ "error",
1646
+ { alignAttributesVertically: true, indent: 2 }
1647
+ ],
1648
+ "svelte/mustache-spacing": "error",
1649
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1650
+ "svelte/no-trailing-spaces": "error",
1651
+ "svelte/spaced-html-comment": "error"
1652
+ },
1458
1653
  ...overrides
1459
1654
  }
1460
1655
  }
@@ -1463,6 +1658,7 @@ async function svelte(options = {}) {
1463
1658
 
1464
1659
  // src/index.ts
1465
1660
  var flatConfigProps = [
1661
+ "name",
1466
1662
  "files",
1467
1663
  "ignores",
1468
1664
  "languageOptions",
@@ -1488,10 +1684,18 @@ async function defineConfig(options = {}, ...userConfigs) {
1488
1684
  const configs = [];
1489
1685
  if (enableGitignore) {
1490
1686
  if (typeof enableGitignore !== "boolean") {
1491
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1687
+ configs.push(
1688
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1689
+ r(enableGitignore)
1690
+ ])
1691
+ );
1492
1692
  } else {
1493
1693
  if (import_node_fs.default.existsSync(".gitignore"))
1494
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1694
+ configs.push(
1695
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1696
+ r()
1697
+ ])
1698
+ );
1495
1699
  }
1496
1700
  }
1497
1701
  configs.push(
@@ -1576,10 +1780,15 @@ async function defineConfig(options = {}, ...userConfigs) {
1576
1780
  prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1577
1781
  }
1578
1782
  if (usePrettierrc) {
1579
- const prettierConfig = await loadPrettierConfig(options.cwd ?? import_node_process3.default.cwd());
1783
+ const prettierConfig = await loadPrettierConfig(
1784
+ options.cwd ?? import_node_process3.default.cwd()
1785
+ );
1580
1786
  Object.assign(prettierRules2, prettierConfig);
1581
1787
  }
1582
- configs.push(prettier(prettierRules2), formatter(options.formatter, prettierRules2));
1788
+ configs.push(
1789
+ prettier(prettierRules2),
1790
+ formatter(options.formatter, prettierRules2)
1791
+ );
1583
1792
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1584
1793
  if (key in options)
1585
1794
  acc[key] = options[key];
package/dist/index.d.cts CHANGED
@@ -36,14 +36,14 @@ type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
36
36
  type Awaitable<T> = T | Promise<T>;
37
37
  type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
38
38
  interface OptionsFormatters {
39
- /**
40
- * Enable formatting support for CSS, Less, Sass, and SCSS.
41
- */
42
- css?: boolean;
43
39
  /**
44
40
  * Enable formatting support for HTML.
45
41
  */
46
42
  html?: boolean;
43
+ /**
44
+ * Enable formatting support for CSS, Less, Sass, and SCSS.
45
+ */
46
+ css?: boolean;
47
47
  /**
48
48
  * Enable formatting support for Markdown.
49
49
  */
package/dist/index.d.ts CHANGED
@@ -36,14 +36,14 @@ type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
36
36
  type Awaitable<T> = T | Promise<T>;
37
37
  type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
38
38
  interface OptionsFormatters {
39
- /**
40
- * Enable formatting support for CSS, Less, Sass, and SCSS.
41
- */
42
- css?: boolean;
43
39
  /**
44
40
  * Enable formatting support for HTML.
45
41
  */
46
42
  html?: boolean;
43
+ /**
44
+ * Enable formatting support for CSS, Less, Sass, and SCSS.
45
+ */
46
+ css?: boolean;
47
47
  /**
48
48
  * Enable formatting support for Markdown.
49
49
  */
package/dist/index.js CHANGED
@@ -122,7 +122,6 @@ 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": ["error", { considerComments: true, count: 1 }],
126
125
  "import/no-duplicates": "error",
127
126
  "import/no-mutable-exports": "error",
128
127
  "import/no-named-default": "error",
@@ -131,11 +130,27 @@ async function imports() {
131
130
  "import/order": [
132
131
  "error",
133
132
  {
134
- groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
133
+ groups: [
134
+ "builtin",
135
+ "external",
136
+ "internal",
137
+ "parent",
138
+ "sibling",
139
+ "index",
140
+ "object",
141
+ "type"
142
+ ],
135
143
  pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
136
144
  pathGroupsExcludedImportTypes: ["type"]
137
145
  }
138
- ]
146
+ ],
147
+ ...{
148
+ // format
149
+ "import/newline-after-import": [
150
+ "error",
151
+ { considerComments: true, count: 1 }
152
+ ]
153
+ }
139
154
  }
140
155
  },
141
156
  {
@@ -182,14 +197,20 @@ async function javascript(options = {}) {
182
197
  "unused-imports": default6
183
198
  },
184
199
  rules: {
185
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
200
+ "accessor-pairs": [
201
+ "error",
202
+ { enforceForClassMembers: true, setWithoutGet: true }
203
+ ],
186
204
  "array-callback-return": "error",
187
205
  "block-scoped-var": "error",
188
206
  "constructor-super": "error",
189
207
  "default-case-last": "error",
190
208
  "dot-notation": ["error", { allowKeywords: true }],
191
209
  eqeqeq: ["error", "smart"],
192
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
210
+ "new-cap": [
211
+ "error",
212
+ { capIsNew: false, newIsCap: true, properties: true }
213
+ ],
193
214
  "no-alert": "error",
194
215
  "no-array-constructor": "error",
195
216
  "no-async-promise-executor": "error",
@@ -310,7 +331,10 @@ async function javascript(options = {}) {
310
331
  vars: "all"
311
332
  }
312
333
  ],
313
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
334
+ "no-use-before-define": [
335
+ "error",
336
+ { classes: false, functions: false, variables: true }
337
+ ],
314
338
  "no-useless-backreference": "error",
315
339
  "no-useless-call": "error",
316
340
  "no-useless-catch": "error",
@@ -371,7 +395,10 @@ async function javascript(options = {}) {
371
395
  varsIgnorePattern: "^_"
372
396
  }
373
397
  ],
374
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
398
+ "use-isnan": [
399
+ "error",
400
+ { enforceForIndexOf: true, enforceForSwitchCase: true }
401
+ ],
375
402
  "valid-typeof": ["error", { requireStringLiterals: true }],
376
403
  "vars-on-top": "error",
377
404
  yoda: ["error", "never"],
@@ -384,6 +411,12 @@ async function javascript(options = {}) {
384
411
  rules: {
385
412
  "no-console": "off"
386
413
  }
414
+ },
415
+ {
416
+ files: ["**/*.{test,spec}.js?(x)"],
417
+ rules: {
418
+ "no-unused-expressions": "off"
419
+ }
387
420
  }
388
421
  ];
389
422
  }
@@ -454,7 +487,9 @@ async function ensurePackages(packages) {
454
487
  }
455
488
  ]);
456
489
  if (result)
457
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
490
+ await import("@antfu/install-pkg").then(
491
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
492
+ );
458
493
  }
459
494
  async function loadPrettierConfig(cwd) {
460
495
  let prettierConfig = {};
@@ -499,7 +534,12 @@ async function jsdoc() {
499
534
  "jsdoc/require-property-name": "warn",
500
535
  "jsdoc/require-returns-check": "warn",
501
536
  "jsdoc/require-returns-description": "warn",
502
- "jsdoc/require-yields-check": "warn"
537
+ "jsdoc/require-yields-check": "warn",
538
+ ...{
539
+ // format
540
+ "jsdoc/check-alignment": "warn",
541
+ "jsdoc/multiline-blocks": "warn"
542
+ }
503
543
  }
504
544
  }
505
545
  ];
@@ -552,6 +592,28 @@ async function jsonc(options = {}) {
552
592
  "jsonc/space-unary-ops": "error",
553
593
  "jsonc/valid-json-number": "error",
554
594
  "jsonc/vue-custom-block/no-parsing-error": "error",
595
+ ...{
596
+ // format
597
+ "jsonc/array-bracket-spacing": ["error", "never"],
598
+ "jsonc/comma-dangle": ["error", "never"],
599
+ "jsonc/comma-style": ["error", "last"],
600
+ "jsonc/indent": ["error", 2],
601
+ "jsonc/key-spacing": [
602
+ "error",
603
+ { afterColon: true, beforeColon: false }
604
+ ],
605
+ "jsonc/object-curly-newline": [
606
+ "error",
607
+ { consistent: true, multiline: true }
608
+ ],
609
+ "jsonc/object-curly-spacing": ["error", "always"],
610
+ "jsonc/object-property-newline": [
611
+ "error",
612
+ { allowMultiplePropertiesPerLine: true }
613
+ ],
614
+ "jsonc/quote-props": "error",
615
+ "jsonc/quotes": "error"
616
+ },
555
617
  ...overrides
556
618
  }
557
619
  }
@@ -670,7 +732,14 @@ function sortTsconfig() {
670
732
  "jsonc/sort-keys": [
671
733
  "error",
672
734
  {
673
- order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
735
+ order: [
736
+ "extends",
737
+ "compilerOptions",
738
+ "references",
739
+ "files",
740
+ "include",
741
+ "exclude"
742
+ ],
674
743
  pathPattern: "^$"
675
744
  },
676
745
  {
@@ -814,7 +883,10 @@ async function prettier(rules) {
814
883
  import process2 from "node:process";
815
884
  async function typescript(options = {}) {
816
885
  const { componentExts = [], overrides = {}, parserOptions = {} } = options;
817
- const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
886
+ const files = options.files ?? [
887
+ GLOB_SRC,
888
+ ...componentExts.map((ext) => `**/*.${ext}`)
889
+ ];
818
890
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
819
891
  const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
820
892
  const isTypeAware = !!tsconfigPath;
@@ -872,22 +944,41 @@ async function typescript(options = {}) {
872
944
  }
873
945
  },
874
946
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
875
- ...isTypeAware ? [makeParser(true, filesTypeAware), makeParser(false, files, filesTypeAware)] : [makeParser(false, files)],
947
+ ...isTypeAware ? [
948
+ makeParser(true, filesTypeAware),
949
+ makeParser(false, files, filesTypeAware)
950
+ ] : [makeParser(false, files)],
876
951
  {
877
952
  files,
878
953
  name: "coderwyd:typescript:rules",
879
954
  rules: {
880
- ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, "@typescript-eslint/", "ts/"),
881
- ...renameRules(pluginTs.configs.strict.rules, "@typescript-eslint/", "ts/"),
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
+ ),
882
965
  "no-dupe-class-members": "off",
883
966
  "no-loss-of-precision": "off",
884
967
  "no-redeclare": "off",
885
968
  "no-use-before-define": "off",
886
969
  "no-useless-constructor": "off",
887
- "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
970
+ "ts/ban-ts-comment": [
971
+ "error",
972
+ { "ts-ignore": "allow-with-description" }
973
+ ],
888
974
  "ts/ban-types": ["error", { types: { Function: false } }],
889
975
  "ts/consistent-type-definitions": ["error", "interface"],
890
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
976
+ "ts/consistent-type-imports": [
977
+ "error",
978
+ { disallowTypeAnnotations: false, prefer: "type-imports" }
979
+ ],
980
+ "ts/method-signature-style": ["error", "property"],
981
+ // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
891
982
  "ts/no-dupe-class-members": "error",
892
983
  "ts/no-dynamic-delete": "off",
893
984
  "ts/no-explicit-any": "off",
@@ -899,7 +990,10 @@ async function typescript(options = {}) {
899
990
  "ts/no-redeclare": "error",
900
991
  "ts/no-require-imports": "error",
901
992
  "ts/no-unused-vars": "off",
902
- "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
993
+ "ts/no-use-before-define": [
994
+ "error",
995
+ { classes: false, functions: false, variables: true }
996
+ ],
903
997
  "ts/no-useless-constructor": "off",
904
998
  "ts/prefer-ts-expect-error": "error",
905
999
  "ts/triple-slash-reference": "off",
@@ -1049,7 +1143,9 @@ async function vue(options = {}) {
1049
1143
  jsx: true
1050
1144
  },
1051
1145
  extraFileExtensions: [".vue"],
1052
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1146
+ parser: options.typescript ? await interopDefault(
1147
+ import("@typescript-eslint/parser")
1148
+ ) : null,
1053
1149
  sourceType: "module"
1054
1150
  }
1055
1151
  },
@@ -1071,7 +1167,12 @@ async function vue(options = {}) {
1071
1167
  "vue/define-macros-order": [
1072
1168
  "error",
1073
1169
  {
1074
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1170
+ order: [
1171
+ "defineOptions",
1172
+ "defineProps",
1173
+ "defineEmits",
1174
+ "defineSlots"
1175
+ ]
1075
1176
  }
1076
1177
  ],
1077
1178
  "vue/dot-location": ["error", "property"],
@@ -1099,7 +1200,12 @@ async function vue(options = {}) {
1099
1200
  "vue/no-extra-parens": ["error", "functions"],
1100
1201
  "vue/no-irregular-whitespace": "error",
1101
1202
  "vue/no-loss-of-precision": "error",
1102
- "vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
1203
+ "vue/no-restricted-syntax": [
1204
+ "error",
1205
+ "DebuggerStatement",
1206
+ "LabeledStatement",
1207
+ "WithStatement"
1208
+ ],
1103
1209
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
1104
1210
  "vue/no-setup-props-reactivity-loss": "off",
1105
1211
  "vue/no-sparse-arrays": "error",
@@ -1114,7 +1220,6 @@ async function vue(options = {}) {
1114
1220
  ignoreConstructors: false
1115
1221
  }
1116
1222
  ],
1117
- "vue/padding-line-between-blocks": ["error", "always"],
1118
1223
  "vue/prefer-separate-static-class": "error",
1119
1224
  "vue/prefer-template": "error",
1120
1225
  "vue/prop-name-casing": ["error", "camelCase"],
@@ -1123,6 +1228,46 @@ async function vue(options = {}) {
1123
1228
  "vue/space-infix-ops": "error",
1124
1229
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1125
1230
  "vue/valid-define-options": "warn",
1231
+ ...{
1232
+ // format
1233
+ "vue/array-bracket-spacing": ["error", "never"],
1234
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1235
+ "vue/block-spacing": ["error", "always"],
1236
+ "vue/block-tag-newline": [
1237
+ "error",
1238
+ {
1239
+ multiline: "always",
1240
+ singleline: "always"
1241
+ }
1242
+ ],
1243
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1244
+ "vue/comma-dangle": ["error", "always-multiline"],
1245
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1246
+ "vue/comma-style": ["error", "last"],
1247
+ "vue/html-comment-content-spacing": [
1248
+ "error",
1249
+ "always",
1250
+ {
1251
+ exceptions: ["-"]
1252
+ }
1253
+ ],
1254
+ "vue/key-spacing": [
1255
+ "error",
1256
+ { afterColon: true, beforeColon: false }
1257
+ ],
1258
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1259
+ "vue/object-curly-newline": "off",
1260
+ "vue/object-curly-spacing": ["error", "always"],
1261
+ "vue/object-property-newline": [
1262
+ "error",
1263
+ { allowMultiplePropertiesPerLine: true }
1264
+ ],
1265
+ "vue/operator-linebreak": ["error", "before"],
1266
+ "vue/padding-line-between-blocks": ["error", "always"],
1267
+ "vue/quote-props": ["error", "consistent-as-needed"],
1268
+ "vue/space-in-parens": ["error", "never"],
1269
+ "vue/template-curly-spacing": "error"
1270
+ },
1126
1271
  ...overrides
1127
1272
  }
1128
1273
  }
@@ -1156,7 +1301,10 @@ async function test(options = {}) {
1156
1301
  name: "coderwyd:test:rules",
1157
1302
  rules: {
1158
1303
  "node/prefer-global/process": "off",
1159
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1304
+ "test/consistent-test-it": [
1305
+ "error",
1306
+ { fn: "it", withinDescribe: "it" }
1307
+ ],
1160
1308
  "test/no-identical-title": "error",
1161
1309
  "test/no-import-node-test": "error",
1162
1310
  "test/no-only-tests": isInEditor ? "off" : "error",
@@ -1184,14 +1332,26 @@ async function perfectionist() {
1184
1332
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1185
1333
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1186
1334
  async function react(options = {}) {
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"))
1335
+ const {
1336
+ files = [GLOB_JSX, GLOB_TSX],
1337
+ overrides = {},
1338
+ typescript: typescript2 = true
1339
+ } = options;
1340
+ await ensurePackages([
1341
+ "eslint-plugin-react",
1342
+ "eslint-plugin-react-hooks",
1343
+ "eslint-plugin-react-refresh"
1193
1344
  ]);
1194
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists2(i));
1345
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1346
+ [
1347
+ interopDefault(import("eslint-plugin-react")),
1348
+ interopDefault(import("eslint-plugin-react-hooks")),
1349
+ interopDefault(import("eslint-plugin-react-refresh"))
1350
+ ]
1351
+ );
1352
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1353
+ (i) => isPackageExists2(i)
1354
+ );
1195
1355
  return [
1196
1356
  {
1197
1357
  name: "coderwyd:react:setup",
@@ -1221,7 +1381,10 @@ async function react(options = {}) {
1221
1381
  "react-hooks/exhaustive-deps": "warn",
1222
1382
  "react-hooks/rules-of-hooks": "error",
1223
1383
  // react refresh
1224
- "react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }],
1384
+ "react-refresh/only-export-components": [
1385
+ "warn",
1386
+ { allowConstantExport: isAllowConstantExport }
1387
+ ],
1225
1388
  // recommended rules react
1226
1389
  "react/display-name": "error",
1227
1390
  "react/jsx-key": "error",
@@ -1260,7 +1423,9 @@ async function react(options = {}) {
1260
1423
  async function unocss(options = {}) {
1261
1424
  const { attributify = true, strict = false } = options;
1262
1425
  await ensurePackages(["@unocss/eslint-plugin"]);
1263
- const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
1426
+ const [pluginUnoCSS] = await Promise.all([
1427
+ interopDefault(import("@unocss/eslint-plugin"))
1428
+ ]);
1264
1429
  return [
1265
1430
  {
1266
1431
  name: "coderwyd:unocss",
@@ -1283,7 +1448,14 @@ async function unocss(options = {}) {
1283
1448
  // src/configs/formatter.ts
1284
1449
  async function formatter(options = {}, prettierRules2 = {}) {
1285
1450
  await ensurePackages(["eslint-plugin-prettier"]);
1286
- const { css = true, graphql, html = true, markdown, toml, yaml } = options || {};
1451
+ const {
1452
+ css = true,
1453
+ graphql,
1454
+ html = true,
1455
+ markdown,
1456
+ toml,
1457
+ yaml
1458
+ } = options || {};
1287
1459
  const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1288
1460
  function createPrettierFormatter(files, parser, plugins) {
1289
1461
  const rules = {
@@ -1308,7 +1480,10 @@ async function formatter(options = {}, prettierRules2 = {}) {
1308
1480
  prettier: pluginPrettier
1309
1481
  },
1310
1482
  rules: {
1311
- "prettier/prettier": ["warn", parser === "markdown" ? markdownRules : rules]
1483
+ "prettier/prettier": [
1484
+ "warn",
1485
+ parser === "markdown" ? markdownRules : rules
1486
+ ]
1312
1487
  }
1313
1488
  };
1314
1489
  return config;
@@ -1321,16 +1496,16 @@ async function formatter(options = {}, prettierRules2 = {}) {
1321
1496
  }
1322
1497
  }
1323
1498
  ];
1499
+ if (html) {
1500
+ const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1501
+ configs.push(htmlConfig);
1502
+ }
1324
1503
  if (css) {
1325
1504
  const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1326
1505
  const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1327
1506
  const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1328
1507
  configs.push(cssConfig, scssConfig, lessConfig);
1329
1508
  }
1330
- if (html) {
1331
- const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1332
- configs.push(htmlConfig);
1333
- }
1334
1509
  if (markdown) {
1335
1510
  const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1336
1511
  configs.push(markdownConfig);
@@ -1345,7 +1520,9 @@ async function formatter(options = {}, prettierRules2 = {}) {
1345
1520
  }
1346
1521
  if (toml) {
1347
1522
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1348
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]);
1523
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1524
+ "prettier-plugin-toml"
1525
+ ]);
1349
1526
  configs.push(tomlConfig);
1350
1527
  }
1351
1528
  return configs;
@@ -1372,7 +1549,9 @@ async function svelte(options = {}) {
1372
1549
  parser: parserSvelte,
1373
1550
  parserOptions: {
1374
1551
  extraFileExtensions: [".svelte"],
1375
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1552
+ parser: options.typescript ? await interopDefault(
1553
+ import("@typescript-eslint/parser")
1554
+ ) : null
1376
1555
  }
1377
1556
  },
1378
1557
  name: "coderwyd:svelte:rules",
@@ -1421,6 +1600,22 @@ async function svelte(options = {}) {
1421
1600
  varsIgnorePattern: "^(_|\\$\\$Props$)"
1422
1601
  }
1423
1602
  ],
1603
+ ...{
1604
+ // format
1605
+ "style/no-trailing-spaces": "off",
1606
+ // superseded by svelte/no-trailing-spaces
1607
+ "svelte/derived-has-same-inputs-outputs": "error",
1608
+ "svelte/html-closing-bracket-spacing": "error",
1609
+ "svelte/html-quotes": ["error", { prefer: "single" }],
1610
+ "svelte/indent": [
1611
+ "error",
1612
+ { alignAttributesVertically: true, indent: 2 }
1613
+ ],
1614
+ "svelte/mustache-spacing": "error",
1615
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1616
+ "svelte/no-trailing-spaces": "error",
1617
+ "svelte/spaced-html-comment": "error"
1618
+ },
1424
1619
  ...overrides
1425
1620
  }
1426
1621
  }
@@ -1429,6 +1624,7 @@ async function svelte(options = {}) {
1429
1624
 
1430
1625
  // src/index.ts
1431
1626
  var flatConfigProps = [
1627
+ "name",
1432
1628
  "files",
1433
1629
  "ignores",
1434
1630
  "languageOptions",
@@ -1454,10 +1650,18 @@ async function defineConfig(options = {}, ...userConfigs) {
1454
1650
  const configs = [];
1455
1651
  if (enableGitignore) {
1456
1652
  if (typeof enableGitignore !== "boolean") {
1457
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1653
+ configs.push(
1654
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1655
+ r(enableGitignore)
1656
+ ])
1657
+ );
1458
1658
  } else {
1459
1659
  if (fs.existsSync(".gitignore"))
1460
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1660
+ configs.push(
1661
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1662
+ r()
1663
+ ])
1664
+ );
1461
1665
  }
1462
1666
  }
1463
1667
  configs.push(
@@ -1542,10 +1746,15 @@ async function defineConfig(options = {}, ...userConfigs) {
1542
1746
  prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1543
1747
  }
1544
1748
  if (usePrettierrc) {
1545
- const prettierConfig = await loadPrettierConfig(options.cwd ?? process3.cwd());
1749
+ const prettierConfig = await loadPrettierConfig(
1750
+ options.cwd ?? process3.cwd()
1751
+ );
1546
1752
  Object.assign(prettierRules2, prettierConfig);
1547
1753
  }
1548
- configs.push(prettier(prettierRules2), formatter(options.formatter, prettierRules2));
1754
+ configs.push(
1755
+ prettier(prettierRules2),
1756
+ formatter(options.formatter, prettierRules2)
1757
+ );
1549
1758
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1550
1759
  if (key in options)
1551
1760
  acc[key] = options[key];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "2.1.5",
4
+ "version": "2.1.7",
5
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/)",
@@ -15,6 +15,9 @@
15
15
  "eslint-config-svelte",
16
16
  "prettier"
17
17
  ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
18
21
  "exports": {
19
22
  ".": {
20
23
  "types": "./dist/index.d.ts",
@@ -30,9 +33,6 @@
30
33
  "bin",
31
34
  "dist"
32
35
  ],
33
- "publishConfig": {
34
- "access": "public"
35
- },
36
36
  "engines": {
37
37
  "node": ">=16.14.0"
38
38
  },