@ntnyq/eslint-config 3.5.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -61,6 +61,7 @@ __export(src_exports, {
61
61
  GLOB_TOML: () => GLOB_TOML,
62
62
  GLOB_TS: () => GLOB_TS,
63
63
  GLOB_TSX: () => GLOB_TSX,
64
+ GLOB_TYPES: () => GLOB_TYPES,
64
65
  GLOB_VUE: () => GLOB_VUE,
65
66
  GLOB_YAML: () => GLOB_YAML,
66
67
  antfu: () => antfu,
@@ -213,6 +214,7 @@ var GLOB_JSX = `${GLOB_JS}x`;
213
214
  var GLOB_TS = "**/*.?([cm])ts";
214
215
  var GLOB_TSX = `${GLOB_TS}x`;
215
216
  var GLOB_DTS = "**/*.d.?([cm])ts";
217
+ var GLOB_TYPES = [GLOB_DTS, `**/types/${GLOB_TS}`, `**/types.ts`];
216
218
  var GLOB_TEST = [
217
219
  `**/*.test.${GLOB_SRC_EXT}`,
218
220
  `**/*.spec.${GLOB_SRC_EXT}`,
@@ -395,12 +397,12 @@ var unCategorizedRules = {
395
397
  "vue/no-multiple-objects-in-class": "error",
396
398
  "vue/prefer-separate-static-class": "error",
397
399
  "vue/no-ref-object-reactivity-loss": "error",
398
- "vue/no-duplicate-attr-inheritance": "error",
399
400
  "vue/prefer-prop-type-boolean-first": "error",
400
401
  "vue/html-comment-indent": ["error", 2],
401
402
  "vue/next-tick-style": ["error", "promise"],
402
403
  "vue/v-for-delimiter-style": ["error", "in"],
403
404
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
405
+ "vue/slot-name-casing": ["error", "camelCase"],
404
406
  "vue/custom-event-name-casing": ["error", "camelCase"],
405
407
  "vue/define-props-declaration": ["error", "type-based"],
406
408
  "vue/define-emits-declaration": ["error", "type-literal"],
@@ -415,6 +417,12 @@ var unCategorizedRules = {
415
417
  reset: true
416
418
  }
417
419
  ],
420
+ "vue/no-duplicate-attr-inheritance": [
421
+ "error",
422
+ {
423
+ checkMultiRootNodes: true
424
+ }
425
+ ],
418
426
  "vue/block-order": [
419
427
  "error",
420
428
  {
@@ -698,7 +706,13 @@ var node = (options = {}) => [
698
706
  // src/configs/sort.ts
699
707
  var sort = (options = {}) => {
700
708
  const configs2 = [];
701
- if (options.tsconfig ?? true) {
709
+ const {
710
+ tsconfig: enableSortTsconfig = true,
711
+ packageJson: enableSortPackageJson = true,
712
+ i18nLocale: enableSortI18nLocale = true,
713
+ pnpmWorkspace: enableSortPnpmWorkspace = true
714
+ } = options;
715
+ if (enableSortTsconfig) {
702
716
  configs2.push({
703
717
  name: "ntnyq/sort/tsconfig",
704
718
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
@@ -814,7 +828,7 @@ var sort = (options = {}) => {
814
828
  }
815
829
  });
816
830
  }
817
- if (options.packageJson ?? true) {
831
+ if (enableSortPackageJson) {
818
832
  configs2.push({
819
833
  name: "ntnyq/sort/package-json",
820
834
  files: ["**/package.json"],
@@ -982,7 +996,7 @@ var sort = (options = {}) => {
982
996
  }
983
997
  });
984
998
  }
985
- if (options.i18nLocale ?? true) {
999
+ if (enableSortI18nLocale) {
986
1000
  configs2.push(
987
1001
  {
988
1002
  name: "ntnyq/sort/i18n-locale/json",
@@ -1012,7 +1026,7 @@ var sort = (options = {}) => {
1012
1026
  }
1013
1027
  );
1014
1028
  }
1015
- if (options.pnpmWorkspace ?? true) {
1029
+ if (enableSortPnpmWorkspace) {
1016
1030
  configs2.push({
1017
1031
  name: "ntnyq/sort/pnpm-workspace",
1018
1032
  files: ["**/pnpm-workspace.yaml"],
@@ -1042,25 +1056,25 @@ var toml = (options = {}) => [
1042
1056
  toml: import_eslint_plugin_toml.default
1043
1057
  },
1044
1058
  rules: {
1045
- "toml/comma-style": "error",
1046
1059
  "toml/keys-order": "error",
1060
+ "toml/key-spacing": "error",
1061
+ "toml/quoted-keys": "error",
1062
+ "toml/comma-style": "error",
1063
+ "toml/tables-order": "error",
1047
1064
  "toml/no-space-dots": "error",
1048
- "toml/no-unreadable-number-separator": "error",
1049
- "toml/precision-of-fractional-seconds": "error",
1065
+ "toml/spaced-comment": "error",
1050
1066
  "toml/precision-of-integer": "error",
1051
- "toml/tables-order": "error",
1052
- "toml/indent": ["error", 2],
1053
- "toml/vue-custom-block/no-parsing-error": "error",
1067
+ "toml/table-bracket-spacing": "error",
1054
1068
  "toml/array-bracket-newline": "error",
1055
- "toml/array-bracket-spacing": ["error", "never"],
1056
- "toml/array-element-newline": ["error", "never"],
1057
1069
  "toml/inline-table-curly-spacing": "error",
1058
- "toml/key-spacing": "error",
1059
1070
  "toml/padding-line-between-pairs": "error",
1060
1071
  "toml/padding-line-between-tables": "error",
1061
- "toml/quoted-keys": "error",
1062
- "toml/spaced-comment": "error",
1063
- "toml/table-bracket-spacing": "error",
1072
+ "toml/no-unreadable-number-separator": "error",
1073
+ "toml/precision-of-fractional-seconds": "error",
1074
+ "toml/vue-custom-block/no-parsing-error": "error",
1075
+ "toml/indent": ["error", 2],
1076
+ "toml/array-bracket-spacing": ["error", "never"],
1077
+ "toml/array-element-newline": ["error", "never"],
1064
1078
  // Overrides rules
1065
1079
  ...options.overrides
1066
1080
  }
@@ -1116,6 +1130,13 @@ var antfu = (options = {}) => [
1116
1130
  ];
1117
1131
 
1118
1132
  // src/configs/jsdoc.ts
1133
+ var typescriptRules = {
1134
+ "jsdoc/no-undefined-types": "off",
1135
+ "jsdoc/require-param-type": "off",
1136
+ "jsdoc/require-property-type": "off",
1137
+ "jsdoc/require-returns-type": "off",
1138
+ "jsdoc/no-types": "error"
1139
+ };
1119
1140
  var jsdoc = (options = {}) => [
1120
1141
  {
1121
1142
  name: "ntnyq/jsdoc",
@@ -1123,23 +1144,204 @@ var jsdoc = (options = {}) => [
1123
1144
  jsdoc: import_eslint_plugin_jsdoc.default
1124
1145
  },
1125
1146
  rules: {
1147
+ // Disabled rules
1148
+ "jsdoc/tag-lines": "off",
1149
+ // Use `jsdoc/sort-tags`
1150
+ "jsdoc/text-escaping": "off",
1151
+ // No need
1152
+ // Fixable rules
1153
+ "jsdoc/check-alignment": "error",
1154
+ "jsdoc/check-line-alignment": "error",
1155
+ "jsdoc/check-param-names": "error",
1156
+ "jsdoc/check-property-names": "error",
1157
+ "jsdoc/check-tag-names": "error",
1158
+ "jsdoc/check-types": "error",
1159
+ "jsdoc/empty-tags": "error",
1160
+ "jsdoc/multiline-blocks": "error",
1161
+ "jsdoc/no-bad-blocks": "error",
1162
+ "jsdoc/no-blank-block-descriptions": "error",
1163
+ "jsdoc/no-blank-blocks": "error",
1164
+ "jsdoc/no-defaults": "error",
1165
+ "jsdoc/no-multi-asterisks": "error",
1166
+ "jsdoc/require-asterisk-prefix": "error",
1167
+ "jsdoc/require-hyphen-before-param-description": "error",
1168
+ // TODO: this after investigate
1169
+ // 'jsdoc/sort-tags': [
1170
+ // 'error',
1171
+ // {
1172
+ // tagSequence: [
1173
+ // {
1174
+ // // Module/file-level
1175
+ // tags: ['module', 'exports', 'file', 'fileoverview', 'overview', 'import'],
1176
+ // },
1177
+ // {
1178
+ // // Identifying (name, type)
1179
+ // tags: [
1180
+ // 'typedef',
1181
+ // 'interface',
1182
+ // 'record',
1183
+ // 'template',
1184
+ // 'name',
1185
+ // 'kind',
1186
+ // 'type',
1187
+ // 'alias',
1188
+ // 'external',
1189
+ // 'host',
1190
+ // 'callback',
1191
+ // 'func',
1192
+ // 'function',
1193
+ // 'method',
1194
+ // 'class',
1195
+ // 'constructor',
1196
+ // ],
1197
+ // },
1198
+ // {
1199
+ // // Relationships
1200
+ // tags: [
1201
+ // 'modifies',
1202
+ // 'mixes',
1203
+ // 'mixin',
1204
+ // 'mixinClass',
1205
+ // 'mixinFunction',
1206
+ // 'namespace',
1207
+ // 'borrows',
1208
+ // 'constructs',
1209
+ // 'lends',
1210
+ // 'implements',
1211
+ // 'requires',
1212
+ // ],
1213
+ // },
1214
+ // {
1215
+ // // Long descriptions
1216
+ // tags: ['desc', 'description', 'classdesc', 'tutorial', 'copyright', 'license'],
1217
+ // },
1218
+ // {
1219
+ // // Simple annotations
1220
+ // tags: [
1221
+ // 'const',
1222
+ // 'constant',
1223
+ // 'final',
1224
+ // 'global',
1225
+ // 'readonly',
1226
+ // 'abstract',
1227
+ // 'virtual',
1228
+ // 'var',
1229
+ // 'member',
1230
+ // 'memberof',
1231
+ // 'memberof!',
1232
+ // 'inner',
1233
+ // 'instance',
1234
+ // 'inheritdoc',
1235
+ // 'inheritDoc',
1236
+ // 'override',
1237
+ // 'hideconstructor',
1238
+ // ],
1239
+ // },
1240
+ // {
1241
+ // // Core function/object inf
1242
+ // tags: ['param', 'arg', 'argument', 'prop', 'property', 'return', 'returns'],
1243
+ // },
1244
+ // {
1245
+ // // Important behavior details
1246
+ // tags: [
1247
+ // 'async',
1248
+ // 'generator',
1249
+ // 'default',
1250
+ // 'defaultvalue',
1251
+ // 'enum',
1252
+ // 'augments',
1253
+ // 'extends',
1254
+ // 'throws',
1255
+ // 'exception',
1256
+ // 'yield',
1257
+ // 'yields',
1258
+ // 'event',
1259
+ // 'fires',
1260
+ // 'emits',
1261
+ // 'listens',
1262
+ // 'this',
1263
+ // ],
1264
+ // },
1265
+ // {
1266
+ // // Access
1267
+ // tags: ['static', 'private', 'protected', 'public', 'access', 'internal', 'package'],
1268
+ // },
1269
+ // {
1270
+ // // Other/unknown
1271
+ // tags: ['-other'],
1272
+ // },
1273
+ // {
1274
+ // // Supplementary descriptions
1275
+ // tags: ['see', 'example'],
1276
+ // },
1277
+ // {
1278
+ // // Other Closure (undocumented) metadata
1279
+ // tags: [
1280
+ // 'closurePrimitive',
1281
+ // 'customElement',
1282
+ // 'expose',
1283
+ // 'hidden',
1284
+ // 'idGenerator',
1285
+ // 'meaning',
1286
+ // 'ngInject',
1287
+ // 'owner',
1288
+ // 'wizaction',
1289
+ // ],
1290
+ // },
1291
+ // {
1292
+ // // Other Closure (documented) metadata
1293
+ // tags: [
1294
+ // 'define',
1295
+ // 'dict',
1296
+ // 'export',
1297
+ // 'externs',
1298
+ // 'implicitCast',
1299
+ // 'noalias',
1300
+ // 'nocollapse',
1301
+ // 'nocompile',
1302
+ // 'noinline',
1303
+ // 'nosideeffects',
1304
+ // 'polymer',
1305
+ // 'polymerBehavior',
1306
+ // 'preserve',
1307
+ // 'struct',
1308
+ // 'suppress',
1309
+ // 'unrestricted',
1310
+ // ],
1311
+ // },
1312
+ // {
1313
+ // // Metadata
1314
+ // tags: ['category'],
1315
+ // },
1316
+ // {
1317
+ // // Non-Closure metadata
1318
+ // tags: [
1319
+ // 'ignore',
1320
+ // 'author',
1321
+ // 'version',
1322
+ // 'variation',
1323
+ // 'since',
1324
+ // 'deprecated',
1325
+ // 'compatibility',
1326
+ // 'todo',
1327
+ // ],
1328
+ // },
1329
+ // ],
1330
+ // alphabetizeExtras: true,
1331
+ // linesBetween: 1,
1332
+ // },
1333
+ // ],
1126
1334
  "jsdoc/check-access": "warn",
1127
- "jsdoc/check-param-names": "warn",
1128
- "jsdoc/check-property-names": "warn",
1129
- "jsdoc/check-types": "warn",
1130
- "jsdoc/empty-tags": "warn",
1131
1335
  "jsdoc/implements-on-classes": "warn",
1132
- "jsdoc/no-defaults": "warn",
1133
- "jsdoc/no-multi-asterisks": "warn",
1134
1336
  "jsdoc/require-param-name": "warn",
1135
1337
  "jsdoc/require-property": "warn",
1136
- "jsdoc/require-property-description": "warn",
1137
1338
  "jsdoc/require-property-name": "warn",
1339
+ "jsdoc/require-property-description": "warn",
1138
1340
  "jsdoc/require-returns-check": "warn",
1139
1341
  "jsdoc/require-returns-description": "warn",
1140
1342
  "jsdoc/require-yields-check": "warn",
1141
- "jsdoc/check-alignment": "warn",
1142
- "jsdoc/multiline-blocks": "warn",
1343
+ // TypeScript rules overrides
1344
+ ...options.typescript ? typescriptRules : {},
1143
1345
  // Overrides rules
1144
1346
  ...options.overrides
1145
1347
  }
@@ -1159,10 +1361,12 @@ var jsonc = (options = {}) => [
1159
1361
  },
1160
1362
  rules: {
1161
1363
  ...import_eslint_plugin_jsonc.default.configs["recommended-with-jsonc"].rules,
1162
- "jsonc/array-bracket-spacing": ["error", "never"],
1163
- "jsonc/comma-dangle": ["error", "never"],
1164
- "jsonc/comma-style": ["error", "last"],
1364
+ "jsonc/no-octal-escape": "error",
1165
1365
  "jsonc/indent": ["error", 2],
1366
+ "jsonc/comma-style": ["error", "last"],
1367
+ "jsonc/comma-dangle": ["error", "never"],
1368
+ "jsonc/object-curly-spacing": ["error", "always"],
1369
+ "jsonc/array-bracket-spacing": ["error", "never"],
1166
1370
  "jsonc/key-spacing": [
1167
1371
  "error",
1168
1372
  {
@@ -1170,7 +1374,6 @@ var jsonc = (options = {}) => [
1170
1374
  afterColon: true
1171
1375
  }
1172
1376
  ],
1173
- "jsonc/no-octal-escape": "error",
1174
1377
  "jsonc/object-curly-newline": [
1175
1378
  "error",
1176
1379
  {
@@ -1178,7 +1381,6 @@ var jsonc = (options = {}) => [
1178
1381
  consistent: true
1179
1382
  }
1180
1383
  ],
1181
- "jsonc/object-curly-spacing": ["error", "always"],
1182
1384
  "jsonc/object-property-newline": [
1183
1385
  "error",
1184
1386
  {
@@ -1208,23 +1410,23 @@ var ntnyq = (options = {}) => [
1208
1410
 
1209
1411
  // src/configs/regexp.ts
1210
1412
  var regexp = (options = {}) => {
1211
- const config = pluginRegexp.configs["flat/recommended"];
1212
- const rules = {
1213
- ...config.rules
1413
+ const recommendedConfig = pluginRegexp.configs["flat/recommended"];
1414
+ const recommendedRules2 = {
1415
+ ...recommendedConfig.rules
1214
1416
  };
1215
1417
  if (options.level === "warn") {
1216
- for (const key in rules) {
1217
- if (rules[key] === "error") {
1218
- rules[key] = "warn";
1418
+ for (const key in recommendedRules2) {
1419
+ if (recommendedRules2[key] === "error") {
1420
+ recommendedRules2[key] = "warn";
1219
1421
  }
1220
1422
  }
1221
1423
  }
1222
1424
  return [
1223
1425
  {
1224
- ...config,
1426
+ ...recommendedConfig,
1225
1427
  name: "ntnyq/regexp",
1226
1428
  rules: {
1227
- ...rules,
1429
+ ...recommendedRules2,
1228
1430
  // Overrides rules
1229
1431
  ...options.overrides
1230
1432
  }
@@ -1250,51 +1452,51 @@ var unocss = (options = {}) => [
1250
1452
 
1251
1453
  // src/constants.ts
1252
1454
  var DEFAULT_PRETTIER_OPTIONS = {
1253
- // Maximum line length
1254
- printWidth: 100,
1255
1455
  // Specify the number of spaces per indentation-level
1256
1456
  tabWidth: 2,
1257
- // Indent lines with tabs instead of spaces
1258
- useTabs: false,
1259
1457
  // Use semicolons or not
1260
1458
  semi: false,
1459
+ // Format only a segment of a file.
1460
+ rangeStart: 0,
1461
+ // Indent lines with tabs instead of spaces
1462
+ useTabs: false,
1463
+ // Maximum line length
1464
+ printWidth: 100,
1465
+ // End of line
1466
+ endOfLine: "lf",
1261
1467
  // Use single quotes instead of double quotes
1262
1468
  singleQuote: true,
1263
- // Change when properties in objects are quoted
1264
- quoteProps: "as-needed",
1469
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1470
+ insertPragma: false,
1265
1471
  // Use single quotes instead of double quotes in JSX
1266
1472
  jsxSingleQuote: true,
1267
1473
  // Print trailing commas wherever possible when multi-line
1268
1474
  trailingComma: "all",
1269
1475
  // Print spaces between brackets in object literals.
1270
1476
  bracketSpacing: true,
1271
- // Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements)
1272
- bracketSameLine: false,
1273
1477
  // Include parentheses around a sole arrow function parameter
1274
1478
  arrowParens: "avoid",
1275
- // Format only a segment of a file.
1276
- rangeStart: 0,
1277
- rangeEnd: Number.POSITIVE_INFINITY,
1479
+ // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1480
+ requirePragma: false,
1278
1481
  // Specify which parser to use.
1279
1482
  // parser: undefined,
1280
1483
  // Specify the file name to use to infer which parser to use.
1281
1484
  // filepath: undefined,
1282
- // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1283
- requirePragma: false,
1284
- // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1285
- insertPragma: false,
1286
1485
  // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1287
1486
  proseWrap: "preserve",
1288
- // Specify the global whitespace sensitivity for HTML files
1289
- htmlWhitespaceSensitivity: "css",
1487
+ // Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements)
1488
+ bracketSameLine: false,
1489
+ // Change when properties in objects are quoted
1490
+ quoteProps: "as-needed",
1491
+ // Enforce single attribute per line in HTML, Vue and JSX
1492
+ singleAttributePerLine: true,
1290
1493
  // Whether or not to indent the code inside <script> and <style> tags in Vue files
1291
1494
  vueIndentScriptAndStyle: false,
1292
- // End of line
1293
- endOfLine: "lf",
1495
+ // Specify the global whitespace sensitivity for HTML files
1496
+ htmlWhitespaceSensitivity: "css",
1497
+ rangeEnd: Number.POSITIVE_INFINITY,
1294
1498
  // Control whether Prettier formats quoted code embedded in the file
1295
- embeddedLanguageFormatting: "auto",
1296
- // Enforce single attribute per line in HTML, Vue and JSX
1297
- singleAttributePerLine: true
1499
+ embeddedLanguageFormatting: "auto"
1298
1500
  };
1299
1501
 
1300
1502
  // src/utils/env.ts
@@ -1499,8 +1701,8 @@ var imports = (options = {}) => [
1499
1701
  // src/configs/unicorn.ts
1500
1702
  var disabledRules2 = {
1501
1703
  "unicorn/better-regex": "off",
1502
- "unicorn/prefer-top-level-await": "off",
1503
1704
  "unicorn/explicit-length-check": "off",
1705
+ "unicorn/prefer-top-level-await": "off",
1504
1706
  "unicorn/no-array-callback-reference": "off",
1505
1707
  /**
1506
1708
  * @see https://caniuse.com/?search=globalThis
@@ -1514,37 +1716,37 @@ var unicorn = (options = {}) => [
1514
1716
  unicorn: import_eslint_plugin_unicorn.default
1515
1717
  },
1516
1718
  rules: {
1517
- "unicorn/error-message": "error",
1518
1719
  "unicorn/escape-case": "error",
1720
+ "unicorn/no-for-loop": "error",
1721
+ "unicorn/no-lonely-if": "error",
1722
+ "unicorn/error-message": "error",
1519
1723
  "unicorn/no-new-buffer": "error",
1520
- "unicorn/number-literal-case": "error",
1724
+ "unicorn/no-hex-escape": "error",
1725
+ "unicorn/throw-new-error": "error",
1521
1726
  "unicorn/prefer-includes": "error",
1727
+ "unicorn/new-for-builtins": "error",
1522
1728
  "unicorn/prefer-type-error": "error",
1523
- "unicorn/throw-new-error": "error",
1524
- "unicorn/no-unnecessary-await": "error",
1525
- "unicorn/switch-case-braces": ["error", "avoid"],
1526
- "unicorn/no-typeof-undefined": "error",
1729
+ "unicorn/prefer-math-trunc": "error",
1730
+ "unicorn/no-console-spaces": "error",
1731
+ "unicorn/no-zero-fractions": "error",
1527
1732
  "unicorn/prefer-regexp-test": "error",
1733
+ "unicorn/number-literal-case": "error",
1734
+ "unicorn/no-typeof-undefined": "error",
1735
+ "unicorn/prefer-math-min-max": "error",
1736
+ "unicorn/prefer-node-protocol": "error",
1737
+ "unicorn/no-unnecessary-await": "error",
1528
1738
  "unicorn/no-static-only-class": "error",
1529
- "unicorn/no-zero-fractions": "error",
1739
+ "unicorn/prefer-reflect-apply": "error",
1740
+ "unicorn/prefer-negative-index": "error",
1741
+ "unicorn/prefer-structured-clone": "error",
1530
1742
  "unicorn/custom-error-definition": "error",
1531
1743
  "unicorn/prefer-modern-math-apis": "error",
1532
- "unicorn/new-for-builtins": "error",
1533
- "unicorn/no-console-spaces": "error",
1534
- "unicorn/no-for-loop": "error",
1535
- "unicorn/no-hex-escape": "error",
1536
- "unicorn/no-lonely-if": "error",
1537
- "unicorn/prefer-keyboard-event-key": "error",
1538
- "unicorn/prefer-math-trunc": "error",
1539
- "unicorn/prefer-negative-index": "error",
1540
- "unicorn/prefer-node-protocol": "error",
1541
1744
  "unicorn/prefer-number-properties": "error",
1542
- "unicorn/prefer-optional-catch-binding": "error",
1543
1745
  "unicorn/prefer-prototype-methods": "error",
1544
- "unicorn/prefer-reflect-apply": "error",
1545
- "unicorn/prefer-math-min-max": "error",
1546
- "unicorn/prefer-structured-clone": "error",
1746
+ "unicorn/prefer-keyboard-event-key": "error",
1747
+ "unicorn/prefer-optional-catch-binding": "error",
1547
1748
  "unicorn/consistent-existence-index-check": "error",
1749
+ "unicorn/switch-case-braces": ["error", "avoid"],
1548
1750
  "unicorn/catch-error-name": [
1549
1751
  "error",
1550
1752
  {
@@ -1559,24 +1761,24 @@ var unicorn = (options = {}) => [
1559
1761
  "unicorn/prefer-string-trim-start-end": "error",
1560
1762
  "unicorn/prefer-string-starts-ends-with": "error",
1561
1763
  // DOM
1562
- "unicorn/prefer-add-event-listener": "error",
1563
- "unicorn/no-invalid-remove-event-listener": "error",
1564
1764
  "unicorn/prefer-query-selector": "error",
1565
1765
  "unicorn/prefer-modern-dom-apis": "error",
1766
+ "unicorn/prefer-dom-node-remove": "error",
1566
1767
  "unicorn/prefer-dom-node-append": "error",
1567
1768
  "unicorn/prefer-dom-node-dataset": "error",
1568
- "unicorn/prefer-dom-node-remove": "error",
1769
+ "unicorn/prefer-add-event-listener": "error",
1569
1770
  "unicorn/prefer-dom-node-text-content": "error",
1771
+ "unicorn/no-invalid-remove-event-listener": "error",
1570
1772
  // Array
1571
1773
  "unicorn/no-new-array": "error",
1572
- "unicorn/no-instanceof-array": "error",
1573
1774
  "unicorn/no-array-push-push": "error",
1574
- "unicorn/no-array-method-this-argument": "error",
1575
1775
  "unicorn/prefer-array-find": "error",
1576
1776
  "unicorn/prefer-array-some": "error",
1777
+ "unicorn/no-instanceof-array": "error",
1577
1778
  "unicorn/prefer-array-flat-map": "error",
1578
1779
  "unicorn/prefer-array-index-of": "error",
1579
1780
  "unicorn/require-array-join-separator": "error",
1781
+ "unicorn/no-array-method-this-argument": "error",
1580
1782
  // Set
1581
1783
  "unicorn/prefer-set-has": "error",
1582
1784
  "unicorn/prefer-set-size": "error",
@@ -1589,13 +1791,15 @@ var unicorn = (options = {}) => [
1589
1791
 
1590
1792
  // src/configs/specials.ts
1591
1793
  var import_globals = __toESM(require("globals"), 1);
1592
- var specials = () => [
1794
+ var specials = (options = {}) => [
1593
1795
  {
1594
1796
  name: "ntnyq/specials/scripts",
1595
1797
  files: [`**/scripts/${GLOB_SRC}`],
1596
1798
  rules: {
1597
1799
  "no-console": "off",
1598
- "@typescript-eslint/explicit-function-return-type": "off"
1800
+ "@typescript-eslint/explicit-function-return-type": "off",
1801
+ // Overrides rules
1802
+ ...options.overridesScriptsRules
1599
1803
  }
1600
1804
  },
1601
1805
  {
@@ -1603,7 +1807,9 @@ var specials = () => [
1603
1807
  files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
1604
1808
  rules: {
1605
1809
  "no-console": "off",
1606
- "@typescript-eslint/explicit-function-return-type": "off"
1810
+ "@typescript-eslint/explicit-function-return-type": "off",
1811
+ // Overrides rules
1812
+ ...options.overridesCliRules
1607
1813
  }
1608
1814
  },
1609
1815
  {
@@ -1620,9 +1826,35 @@ var specials = () => [
1620
1826
  {
1621
1827
  allow: ["^GM_.+"]
1622
1828
  }
1623
- ]
1829
+ ],
1830
+ // Overrides rules
1831
+ ...options.overridesUserScriptsRules
1624
1832
  }
1625
- }
1833
+ },
1834
+ {
1835
+ name: "ntnyq/specials/config-file",
1836
+ files: [`**/*.config*.${GLOB_SRC_EXT}`],
1837
+ plugins: {
1838
+ import: import_eslint_plugin_import_x.default,
1839
+ perfectionist: import_eslint_plugin_perfectionist.default
1840
+ },
1841
+ rules: {
1842
+ "no-console": "off",
1843
+ "import/no-default-export": "off",
1844
+ "@typescript-eslint/explicit-function-return-type": "off",
1845
+ "perfectionist/sort-objects": [
1846
+ "error",
1847
+ {
1848
+ type: "line-length",
1849
+ order: "asc"
1850
+ }
1851
+ ],
1852
+ ...options.overridesConfigFileRules
1853
+ }
1854
+ },
1855
+ // More special case configs
1856
+ // So don't need to append configs to composer
1857
+ ...options.specialCaseConfigs ? options.specialCaseConfigs : []
1626
1858
  ];
1627
1859
 
1628
1860
  // src/configs/comments.ts
@@ -1713,6 +1945,7 @@ var markdown = (options = {}) => {
1713
1945
  var prettier = (options = {}) => {
1714
1946
  const {
1715
1947
  disabledFiles = [GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
1948
+ // User defined disabled files
1716
1949
  userDisabledFiles = []
1717
1950
  } = options;
1718
1951
  return [
@@ -2228,7 +2461,7 @@ var typescript = (options = {}) => {
2228
2461
  ] : [],
2229
2462
  {
2230
2463
  name: "ntnyq/ts/types",
2231
- files: [GLOB_DTS, "**/types/**/*.ts"],
2464
+ files: [...GLOB_TYPES],
2232
2465
  rules: {
2233
2466
  "no-use-before-define": "off",
2234
2467
  "no-restricted-syntax": "off",
@@ -2257,90 +2490,228 @@ var githubAction = (options = {}) => [
2257
2490
  ];
2258
2491
 
2259
2492
  // src/configs/perfectionist.ts
2260
- var perfectionist = (options = {}) => [
2261
- {
2262
- name: "ntnyq/perfectionist",
2263
- plugins: {
2264
- perfectionist: import_eslint_plugin_perfectionist.default
2265
- },
2266
- rules: {
2267
- "perfectionist/sort-imports": [
2268
- "error",
2269
- {
2270
- groups: [
2271
- // Side effect style imports (e.g. 'normalize.css')
2272
- "side-effect-style",
2273
- // Styles (e.g. *.{css,scss,less})
2274
- "style",
2275
- // Node.js built-in modules. (e.g. fs, path)
2276
- "builtin",
2277
- // External modules installed in the project (e.g. vue, lodash)
2278
- "external",
2279
- // Internal modules (e.g. @/utils, @/components)
2280
- "internal",
2281
- // Modules from parent directory (e.g. ../utils)
2282
- "parent",
2283
- // Modules from the same directory (e.g. ./utils)
2284
- "sibling",
2285
- // Main file from the current directory (e.g. ./index)
2286
- "index",
2287
- // TypeScript object-imports (e.g. import log = console.log)
2288
- "object",
2289
- // Side effect imports (e.g. import 'babel-polyfill')
2290
- "side-effect",
2291
- /**
2292
- * Type import at the end
2293
- */
2294
- "builtin-type",
2295
- "external-type",
2296
- "internal-type",
2297
- "parent-type",
2298
- "sibling-type",
2299
- "index-type",
2300
- "type",
2301
- /**
2302
- * Imports that don’t fit into any other group
2303
- */
2304
- "unknown"
2305
- ],
2306
- order: options.imports?.order || "asc",
2307
- type: options.imports?.type || "natural",
2308
- ignoreCase: true,
2309
- internalPattern: ["^~/.+", "^@/.+", "^#.+"],
2310
- newlinesBetween: "ignore"
2311
- }
2312
- ],
2313
- "perfectionist/sort-exports": [
2314
- "error",
2315
- {
2316
- order: options.exports?.order || "asc",
2317
- type: options.exports?.type || "line-length"
2318
- }
2319
- ],
2320
- "perfectionist/sort-named-exports": [
2321
- "error",
2322
- {
2323
- type: options.namedExports?.type || "alphabetical",
2324
- order: options.namedExports?.order || "asc",
2325
- ignoreCase: true,
2326
- groupKind: "values-first"
2327
- }
2328
- ],
2329
- "perfectionist/sort-named-imports": [
2330
- "error",
2331
- {
2332
- type: options.namedImports?.type || "alphabetical",
2333
- order: options.namedImports?.order || "asc",
2334
- ignoreCase: true,
2335
- ignoreAlias: false,
2336
- groupKind: "values-first"
2337
- }
2338
- ],
2339
- // Overrides rules
2340
- ...options.overrides
2493
+ var perfectionist = (options = {}) => {
2494
+ const {
2495
+ sortEnums: enableSortEnums = true,
2496
+ sortTypes: enableSortTypes = true,
2497
+ sortConstants: enableSortConstants = true
2498
+ } = options;
2499
+ const configs2 = [
2500
+ {
2501
+ name: "ntnyq/perfectionist/common",
2502
+ plugins: {
2503
+ perfectionist: import_eslint_plugin_perfectionist.default
2504
+ },
2505
+ rules: {
2506
+ "perfectionist/sort-imports": [
2507
+ "error",
2508
+ {
2509
+ groups: [
2510
+ // Side effect style imports (e.g. 'normalize.css')
2511
+ "side-effect-style",
2512
+ // Styles (e.g. *.{css,scss,less})
2513
+ "style",
2514
+ // Node.js built-in modules. (e.g. fs, path)
2515
+ "builtin",
2516
+ // External modules installed in the project (e.g. vue, lodash)
2517
+ "external",
2518
+ // Internal modules (e.g. @/utils, @/components)
2519
+ "internal",
2520
+ // Modules from parent directory (e.g. ../utils)
2521
+ "parent",
2522
+ // Modules from the same directory (e.g. ./utils)
2523
+ "sibling",
2524
+ // Main file from the current directory (e.g. ./index)
2525
+ "index",
2526
+ // TypeScript object-imports (e.g. import log = console.log)
2527
+ "object",
2528
+ // Side effect imports (e.g. import 'babel-polyfill')
2529
+ "side-effect",
2530
+ /**
2531
+ * Type import at the end
2532
+ */
2533
+ "builtin-type",
2534
+ "external-type",
2535
+ "internal-type",
2536
+ "parent-type",
2537
+ "sibling-type",
2538
+ "index-type",
2539
+ "type",
2540
+ /**
2541
+ * Imports that don’t fit into any other group
2542
+ */
2543
+ "unknown"
2544
+ ],
2545
+ order: "asc",
2546
+ type: "natural",
2547
+ ignoreCase: true,
2548
+ internalPattern: ["^~/.+", "^@/.+", "^#.+"],
2549
+ newlinesBetween: "ignore"
2550
+ }
2551
+ ],
2552
+ "perfectionist/sort-exports": [
2553
+ "error",
2554
+ {
2555
+ order: "asc",
2556
+ type: "line-length"
2557
+ }
2558
+ ],
2559
+ "perfectionist/sort-named-exports": [
2560
+ "error",
2561
+ {
2562
+ type: "alphabetical",
2563
+ order: "asc",
2564
+ ignoreCase: true,
2565
+ groupKind: "values-first"
2566
+ }
2567
+ ],
2568
+ "perfectionist/sort-named-imports": [
2569
+ "error",
2570
+ {
2571
+ type: "alphabetical",
2572
+ order: "asc",
2573
+ ignoreCase: true,
2574
+ ignoreAlias: false,
2575
+ groupKind: "values-first"
2576
+ }
2577
+ ],
2578
+ // Overrides rules
2579
+ ...options.overrides
2580
+ }
2341
2581
  }
2582
+ ];
2583
+ if (enableSortEnums) {
2584
+ configs2.push({
2585
+ name: "ntnyq/perfectionist/enums",
2586
+ files: [`**/enums/${GLOB_SRC}`, `**/enums.${GLOB_SRC_EXT}`],
2587
+ plugins: {
2588
+ perfectionist: import_eslint_plugin_perfectionist.default
2589
+ },
2590
+ rules: {
2591
+ "perfectionist/sort-enums": [
2592
+ "error",
2593
+ {
2594
+ type: "line-length",
2595
+ order: "asc"
2596
+ }
2597
+ ],
2598
+ "perfectionist/sort-modules": [
2599
+ "error",
2600
+ {
2601
+ type: "line-length",
2602
+ order: "asc"
2603
+ }
2604
+ ],
2605
+ // Overrides rules
2606
+ ...options.overridesEnumsRules
2607
+ }
2608
+ });
2342
2609
  }
2343
- ];
2610
+ if (enableSortTypes) {
2611
+ configs2.push({
2612
+ name: "ntnyq/perfectionist/types",
2613
+ files: [...GLOB_TYPES],
2614
+ plugins: {
2615
+ perfectionist: import_eslint_plugin_perfectionist.default
2616
+ },
2617
+ rules: {
2618
+ "perfectionist/sort-heritage-clauses": [
2619
+ "error",
2620
+ {
2621
+ type: "alphabetical",
2622
+ order: "asc"
2623
+ }
2624
+ ],
2625
+ // 'perfectionist/sort-interfaces': [
2626
+ // 'error',
2627
+ // {
2628
+ // type: 'alphabetical',
2629
+ // order: 'asc',
2630
+ // },
2631
+ // ],
2632
+ "perfectionist/sort-intersection-types": [
2633
+ "error",
2634
+ {
2635
+ type: "alphabetical",
2636
+ order: "asc",
2637
+ groups: [
2638
+ "intersection",
2639
+ "named",
2640
+ "conditional",
2641
+ "function",
2642
+ "import",
2643
+ "keyword",
2644
+ "literal",
2645
+ "object",
2646
+ "operator",
2647
+ "tuple",
2648
+ "union",
2649
+ "nullish"
2650
+ ]
2651
+ }
2652
+ ],
2653
+ "perfectionist/sort-modules": [
2654
+ "error",
2655
+ {
2656
+ type: "line-length",
2657
+ order: "asc"
2658
+ }
2659
+ ],
2660
+ "perfectionist/sort-object-types": [
2661
+ "error",
2662
+ {
2663
+ type: "alphabetical",
2664
+ order: "asc"
2665
+ }
2666
+ ],
2667
+ "perfectionist/sort-union-types": [
2668
+ "error",
2669
+ {
2670
+ type: "line-length",
2671
+ order: "asc"
2672
+ }
2673
+ ],
2674
+ // Overrides rules
2675
+ ...options.overridesTypesRules
2676
+ }
2677
+ });
2678
+ }
2679
+ if (enableSortConstants) {
2680
+ configs2.push({
2681
+ name: "ntnyq/perfectionist/constants",
2682
+ files: [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`],
2683
+ plugins: {
2684
+ perfectionist: import_eslint_plugin_perfectionist.default
2685
+ },
2686
+ rules: {
2687
+ "perfectionist/sort-maps": [
2688
+ "error",
2689
+ {
2690
+ type: "alphabetical",
2691
+ order: "asc"
2692
+ }
2693
+ ],
2694
+ "perfectionist/sort-objects": [
2695
+ "error",
2696
+ {
2697
+ type: "line-length",
2698
+ order: "asc"
2699
+ }
2700
+ ],
2701
+ "perfectionist/sort-sets": [
2702
+ "error",
2703
+ {
2704
+ type: "line-length",
2705
+ order: "asc"
2706
+ }
2707
+ ],
2708
+ // Overrides rules
2709
+ ...options.overridesConstantsRules
2710
+ }
2711
+ });
2712
+ }
2713
+ return configs2;
2714
+ };
2344
2715
 
2345
2716
  // src/configs/unusedImports.ts
2346
2717
  var unusedImports = (options = {}) => [
@@ -2372,16 +2743,37 @@ var unusedImports = (options = {}) => [
2372
2743
  ];
2373
2744
 
2374
2745
  // src/core.ts
2375
- async function defineESLintConfig(options = {}, ...userConfigs) {
2376
- const configs2 = [];
2746
+ function defineESLintConfig(options = {}, ...userConfigs) {
2377
2747
  const {
2378
- markdown: enableMarkdown = true,
2379
- gitignore: enableGitIgnore = true,
2748
+ /**
2749
+ * Shared options
2750
+ */
2751
+ extensions: supportedExtensions = [],
2752
+ /**
2753
+ * Conditional by deps
2754
+ */
2380
2755
  vue: enableVue = hasVue,
2756
+ test: enableTest = hasVitest,
2381
2757
  unocss: enableUnoCSS = hasUnoCSS,
2382
2758
  typescript: enableTypeScript = hasTypeScript,
2383
- extensions: supportedExtensions = []
2759
+ /**
2760
+ * Enabled by default
2761
+ */
2762
+ yml: enableYML = true,
2763
+ sort: enableSort = true,
2764
+ toml: enableTOML = true,
2765
+ jsonc: enableJSONC = true,
2766
+ antfu: enableAntfu = true,
2767
+ regexp: enableRegexp = true,
2768
+ unicorn: enableUnicorn = true,
2769
+ prettier: enablePrettier = true,
2770
+ markdown: enableMarkdown = true,
2771
+ stylistic: enableStylistic = true,
2772
+ gitignore: enableGitIgnore = true,
2773
+ githubAction: enableGitHubAction = true,
2774
+ perfectionist: enablePerfectionist = true
2384
2775
  } = options;
2776
+ const configs2 = [];
2385
2777
  if (enableVue) {
2386
2778
  supportedExtensions.push("vue");
2387
2779
  }
@@ -2405,6 +2797,7 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
2405
2797
  overrides: getOverrides(options, "imports")
2406
2798
  }),
2407
2799
  ...jsdoc({
2800
+ typescript: !!enableTypeScript,
2408
2801
  overrides: getOverrides(options, "jsdoc")
2409
2802
  }),
2410
2803
  ...comments({
@@ -2415,7 +2808,7 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
2415
2808
  overrides: getOverrides(options, "javascript")
2416
2809
  })
2417
2810
  );
2418
- if (options.perfectionist ?? true) {
2811
+ if (enablePerfectionist) {
2419
2812
  configs2.push(
2420
2813
  ...perfectionist({
2421
2814
  ...resolveSubOptions(options, "perfectionist"),
@@ -2423,14 +2816,14 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
2423
2816
  })
2424
2817
  );
2425
2818
  }
2426
- if (options.unicorn ?? true) {
2819
+ if (enableUnicorn) {
2427
2820
  configs2.push(
2428
2821
  ...unicorn({
2429
2822
  overrides: getOverrides(options, "unicorn")
2430
2823
  })
2431
2824
  );
2432
2825
  }
2433
- if (options.regexp ?? true) {
2826
+ if (enableRegexp) {
2434
2827
  configs2.push(
2435
2828
  ...regexp({
2436
2829
  ...resolveSubOptions(options, "regexp"),
@@ -2456,35 +2849,35 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
2456
2849
  })
2457
2850
  );
2458
2851
  }
2459
- if (options.yml ?? true) {
2852
+ if (enableYML) {
2460
2853
  configs2.push(
2461
2854
  ...yml({
2462
2855
  overrides: getOverrides(options, "yml")
2463
2856
  })
2464
2857
  );
2465
2858
  }
2466
- if (options.toml ?? true) {
2859
+ if (enableTOML) {
2467
2860
  configs2.push(
2468
2861
  ...toml({
2469
2862
  overrides: getOverrides(options, "toml")
2470
2863
  })
2471
2864
  );
2472
2865
  }
2473
- if (options.jsonc ?? true) {
2866
+ if (enableJSONC) {
2474
2867
  configs2.push(
2475
2868
  ...jsonc({
2476
2869
  overrides: getOverrides(options, "jsonc")
2477
2870
  })
2478
2871
  );
2479
2872
  }
2480
- if (options.sort ?? true) {
2873
+ if (enableSort) {
2481
2874
  configs2.push(
2482
2875
  ...sort({
2483
2876
  ...resolveSubOptions(options, "sort")
2484
2877
  })
2485
2878
  );
2486
2879
  }
2487
- if (options.test ?? hasVitest) {
2880
+ if (enableTest) {
2488
2881
  configs2.push(
2489
2882
  ...test({
2490
2883
  overrides: getOverrides(options, "test")
@@ -2509,34 +2902,35 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
2509
2902
  })
2510
2903
  );
2511
2904
  }
2512
- if (options.antfu ?? true) {
2905
+ if (enableAntfu) {
2513
2906
  configs2.push(
2514
2907
  ...antfu({
2515
2908
  overrides: getOverrides(options, "antfu")
2516
2909
  })
2517
2910
  );
2518
2911
  }
2519
- if (options.stylistic ?? true) {
2912
+ if (enableStylistic) {
2520
2913
  configs2.push(
2521
2914
  ...stylistic({
2522
2915
  overrides: getOverrides(options, "stylistic")
2523
2916
  })
2524
2917
  );
2525
2918
  }
2526
- if (options.githubAction ?? true) {
2919
+ if (enableGitHubAction) {
2527
2920
  configs2.push(
2528
2921
  ...githubAction({
2529
2922
  overrides: getOverrides(options, "githubAction")
2530
2923
  })
2531
2924
  );
2532
2925
  }
2533
- const configSpecials = specials();
2534
- const configPrettier = options.prettier ?? true ? prettier({
2926
+ const configSpecials = specials({
2927
+ ...resolveSubOptions(options, "specials")
2928
+ });
2929
+ const configPrettier = enablePrettier ? prettier({
2535
2930
  ...resolveSubOptions(options, "prettier"),
2536
2931
  overrides: getOverrides(options, "prettier")
2537
2932
  }) : [];
2538
- const composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2539
- await composer.append(
2933
+ const composer = new import_eslint_flat_config_utils.FlatConfigComposer(
2540
2934
  ...configs2,
2541
2935
  ...userConfigs,
2542
2936
  ...configSpecials,
@@ -2577,6 +2971,7 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
2577
2971
  GLOB_TOML,
2578
2972
  GLOB_TS,
2579
2973
  GLOB_TSX,
2974
+ GLOB_TYPES,
2580
2975
  GLOB_VUE,
2581
2976
  GLOB_YAML,
2582
2977
  antfu,