@ntnyq/eslint-config 3.2.1 → 3.3.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.js CHANGED
@@ -1,6 +1,71 @@
1
1
  // src/core.ts
2
2
  import { FlatConfigComposer } from "eslint-flat-config-utils";
3
3
 
4
+ // src/configs/vue.ts
5
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
6
+
7
+ // src/eslint/utils.ts
8
+ import { config } from "typescript-eslint";
9
+
10
+ // src/eslint/parsers.ts
11
+ import tseslint from "typescript-eslint";
12
+ import * as parserVue from "vue-eslint-parser";
13
+ import * as parserToml from "toml-eslint-parser";
14
+ import * as parserYaml from "yaml-eslint-parser";
15
+ import * as parserJsonc from "jsonc-eslint-parser";
16
+ var parserTypeScript = tseslint.parser;
17
+ var parserPlain = {
18
+ meta: {
19
+ name: "plain-eslint-parser"
20
+ },
21
+ parseForESLint: (code) => ({
22
+ ast: {
23
+ body: [],
24
+ comments: [],
25
+ loc: { start: 0, end: code.length },
26
+ range: [0, code.length],
27
+ tokens: [],
28
+ type: "Program"
29
+ },
30
+ scopeManager: null,
31
+ services: { isPlain: true },
32
+ visitorKeys: {
33
+ Program: []
34
+ }
35
+ })
36
+ };
37
+
38
+ // src/eslint/plugins.ts
39
+ import * as pluginRegexp from "eslint-plugin-regexp";
40
+ import { default as default2 } from "eslint-plugin-n";
41
+ import { default as default3 } from "eslint-plugin-vue";
42
+ import { default as default4 } from "eslint-plugin-yml";
43
+ import { default as default5 } from "eslint-plugin-toml";
44
+ import { default as default6 } from "eslint-plugin-ntnyq";
45
+ import { default as default7 } from "@eslint/markdown";
46
+ import { default as default8 } from "eslint-plugin-antfu";
47
+ import { default as default9 } from "eslint-plugin-jsdoc";
48
+ import { default as default10 } from "eslint-plugin-jsonc";
49
+ import { plugin } from "typescript-eslint";
50
+ import { default as default11 } from "eslint-plugin-format";
51
+ import { default as default12 } from "@unocss/eslint-plugin";
52
+ import { default as default13 } from "@vitest/eslint-plugin";
53
+ import { default as default14 } from "eslint-plugin-import-x";
54
+ import { default as default15 } from "eslint-plugin-unicorn";
55
+ import { default as default16 } from "eslint-plugin-prettier";
56
+ import { default as default17 } from "eslint-plugin-github-action";
57
+ import { default as default18 } from "eslint-plugin-perfectionist";
58
+ import { default as default19 } from "eslint-plugin-unused-imports";
59
+ import { default as default20 } from "@eslint-community/eslint-plugin-eslint-comments";
60
+
61
+ // src/eslint/configs.ts
62
+ import { configs } from "typescript-eslint";
63
+
64
+ // src/eslint/processors.ts
65
+ import { mergeProcessors } from "eslint-merge-processors";
66
+ import { processorPassThrough } from "eslint-merge-processors";
67
+ import { default as default21 } from "eslint-processor-vue-blocks";
68
+
4
69
  // src/globs.ts
5
70
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
6
71
  var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
@@ -19,6 +84,7 @@ var GLOB_STYLE = "**/*.{c,le,sc}ss";
19
84
  var GLOB_CSS = "**/*.css";
20
85
  var GLOB_LESS = "**/*.less";
21
86
  var GLOB_SCSS = "**/*.scss";
87
+ var GLOB_POSTCSS = "**/*.{p,post}css";
22
88
  var GLOB_JSON = "**/*.json";
23
89
  var GLOB_JSON5 = "**/*.json5";
24
90
  var GLOB_JSONC = "**/*.jsonc";
@@ -42,6 +108,7 @@ var GLOB_ALL_SRC = [
42
108
  GLOB_HTML,
43
109
  GLOB_MARKDOWN
44
110
  ];
111
+ var GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
45
112
  var GLOB_NODE_MODULES = "**/node_modules/**";
46
113
  var GLOB_DIST = "**/dist/**";
47
114
  var GLOB_LOCKFILE = [
@@ -96,41 +163,16 @@ var GLOB_EXCLUDE = [
96
163
  "**/.yarnrc"
97
164
  ];
98
165
 
99
- // src/plugins.ts
100
- import tseslint from "typescript-eslint";
101
- import * as parserVue from "vue-eslint-parser";
102
- import * as parserToml from "toml-eslint-parser";
103
- import * as parserYaml from "yaml-eslint-parser";
104
- import * as parserJsonc from "jsonc-eslint-parser";
105
- import * as pluginRegexp from "eslint-plugin-regexp";
106
- import { default as default2 } from "eslint-plugin-n";
107
- import { default as default3 } from "eslint-plugin-vue";
108
- import { default as default4 } from "eslint-plugin-yml";
109
- import { default as default5 } from "eslint-plugin-toml";
110
- import { default as default6 } from "eslint-plugin-ntnyq";
111
- import { default as default7 } from "@eslint/markdown";
112
- import { default as default8 } from "eslint-plugin-antfu";
113
- import { default as default9 } from "eslint-plugin-jsdoc";
114
- import { default as default10 } from "eslint-plugin-jsonc";
115
- import { default as default11 } from "@unocss/eslint-plugin";
116
- import { default as default12 } from "@vitest/eslint-plugin";
117
- import { default as default13 } from "eslint-plugin-import-x";
118
- import { default as default14 } from "eslint-plugin-unicorn";
119
- import { default as default15 } from "eslint-plugin-prettier";
120
- import { default as default16 } from "eslint-plugin-perfectionist";
121
- import { default as default17 } from "eslint-plugin-unused-imports";
122
- import { default as default18 } from "@eslint-community/eslint-plugin-eslint-comments";
123
-
124
166
  // src/configs/typescript.ts
125
167
  import process from "node:process";
126
168
  var typescriptCore = (options = {}) => {
127
169
  const isTypeAware = !!options.tsconfigPath;
128
- const configs = tseslint.config({
170
+ const configs2 = config({
129
171
  name: "ntnyq/ts/core",
130
- extends: [...tseslint.configs.recommended],
172
+ extends: [...configs.recommended],
131
173
  files: [GLOB_TS, GLOB_TSX],
132
174
  languageOptions: {
133
- parser: tseslint.parser,
175
+ parser: parserTypeScript,
134
176
  parserOptions: {
135
177
  sourceType: "module",
136
178
  ...isTypeAware ? {
@@ -224,7 +266,7 @@ var typescriptCore = (options = {}) => {
224
266
  ...options.overrides
225
267
  }
226
268
  });
227
- return configs;
269
+ return configs2;
228
270
  };
229
271
  var typescript = (options = {}) => [
230
272
  ...typescriptCore(options),
@@ -318,29 +360,76 @@ var extensionRules = {
318
360
  ]
319
361
  };
320
362
  var unCategorizedRules = {
363
+ "vue/no-v-text": "error",
321
364
  "vue/no-useless-v-bind": "error",
322
365
  "vue/valid-define-options": "error",
323
366
  "vue/prefer-define-options": "error",
367
+ "vue/prefer-use-template-ref": "error",
324
368
  "vue/no-irregular-whitespace": "error",
325
369
  "vue/no-use-v-else-with-v-for": "error",
326
370
  "vue/no-deprecated-delete-set": "error",
371
+ "vue/no-empty-component-block": "error",
327
372
  "vue/require-typed-object-prop": "error",
328
373
  "vue/no-unused-emit-declarations": "error",
329
374
  "vue/padding-line-between-blocks": "error",
330
- "vue/no-ref-object-reactivity-loss": "error",
375
+ "vue/no-multiple-objects-in-class": "error",
331
376
  "vue/prefer-separate-static-class": "error",
377
+ "vue/no-ref-object-reactivity-loss": "error",
378
+ "vue/no-duplicate-attr-inheritance": "error",
379
+ "vue/prefer-prop-type-boolean-first": "error",
380
+ "vue/html-comment-indent": ["error", 2],
332
381
  "vue/next-tick-style": ["error", "promise"],
382
+ "vue/v-for-delimiter-style": ["error", "in"],
333
383
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
334
384
  "vue/custom-event-name-casing": ["error", "camelCase"],
385
+ "vue/define-props-declaration": ["error", "type-based"],
335
386
  "vue/define-emits-declaration": ["error", "type-literal"],
336
387
  "vue/prefer-true-attribute-shorthand": ["error", "always"],
337
388
  "vue/component-options-name-casing": ["error", "PascalCase"],
389
+ "vue/component-api-style": ["error", ["script-setup", "composition"]],
390
+ "vue/html-button-has-type": [
391
+ "error",
392
+ {
393
+ button: true,
394
+ submit: true,
395
+ reset: true
396
+ }
397
+ ],
338
398
  "vue/block-order": [
339
399
  "error",
340
400
  {
341
401
  order: ["script", "template", "style"]
342
402
  }
343
403
  ],
404
+ "vue/enforce-style-attribute": [
405
+ "error",
406
+ {
407
+ allow: ["scoped", "plain"]
408
+ }
409
+ ],
410
+ "vue/block-tag-newline": [
411
+ "error",
412
+ {
413
+ singleline: "always",
414
+ multiline: "always"
415
+ }
416
+ ],
417
+ "vue/no-required-prop-with-default": [
418
+ "error",
419
+ {
420
+ autofix: true
421
+ }
422
+ ],
423
+ "vue/html-comment-content-newline": [
424
+ "error",
425
+ {
426
+ singleline: "ignore",
427
+ multiline: "always"
428
+ },
429
+ {
430
+ exceptions: ["*"]
431
+ }
432
+ ],
344
433
  "vue/no-static-inline-styles": [
345
434
  "error",
346
435
  {
@@ -375,35 +464,61 @@ var unCategorizedRules = {
375
464
  {
376
465
  exceptions: ["-"]
377
466
  }
467
+ ],
468
+ "vue/require-macro-variable-name": [
469
+ "error",
470
+ {
471
+ defineProps: "props",
472
+ defineEmits: "emits",
473
+ defineSlots: "slots",
474
+ useSlots: "slots",
475
+ useAttrs: "attrs"
476
+ }
378
477
  ]
379
478
  };
380
479
  var vue = (options = {}) => {
381
480
  const isVue3 = options.vueVersion !== 2;
481
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
382
482
  return [
383
- ...tseslint.config({
483
+ ...config({
384
484
  name: "ntnyq/vue/ts",
385
485
  files: [GLOB_VUE],
386
486
  extends: typescriptCore()
387
487
  }),
388
488
  {
389
- name: "ntnyq/vue/core",
390
- files: [GLOB_VUE],
489
+ name: "ntnyq/vue/setup",
391
490
  plugins: {
392
491
  vue: default3,
393
- "@typescript-eslint": tseslint.plugin
492
+ "@typescript-eslint": plugin
394
493
  },
395
494
  languageOptions: {
396
- parser: parserVue,
397
495
  parserOptions: {
398
- parser: "@typescript-eslint/parser",
399
496
  sourceType: "module",
497
+ ecmaVersion: "latest",
400
498
  extraFileExtensions: [".vue"],
499
+ parser: "@typescript-eslint/parser",
401
500
  ecmaFeatures: {
402
501
  jsx: true
403
502
  }
404
503
  }
504
+ }
505
+ },
506
+ {
507
+ name: "ntnyq/vue/rules",
508
+ files: [GLOB_VUE],
509
+ languageOptions: {
510
+ parser: parserVue
405
511
  },
406
- processor: default3.processors[".vue"],
512
+ processor: sfcBlocks === false ? default3.processors[".vue"] : mergeProcessors2([
513
+ default3.processors[".vue"],
514
+ default21({
515
+ ...sfcBlocks,
516
+ blocks: {
517
+ styles: true,
518
+ ...sfcBlocks.blocks
519
+ }
520
+ })
521
+ ]),
407
522
  rules: {
408
523
  ...isVue3 ? vue3Rules : vue2Rules,
409
524
  "vue/html-self-closing": [
@@ -418,13 +533,6 @@ var vue = (options = {}) => {
418
533
  math: "always"
419
534
  }
420
535
  ],
421
- "vue/block-tag-newline": [
422
- "error",
423
- {
424
- singleline: "always",
425
- multiline: "always"
426
- }
427
- ],
428
536
  "vue/this-in-template": ["error", "never"],
429
537
  "vue/prop-name-casing": ["error", "camelCase"],
430
538
  "vue/attributes-order": [
@@ -567,9 +675,9 @@ var node = (options = {}) => [
567
675
 
568
676
  // src/configs/sort.ts
569
677
  var sort = (options = {}) => {
570
- const configs = [];
678
+ const configs2 = [];
571
679
  if (options.tsconfig ?? true) {
572
- configs.push({
680
+ configs2.push({
573
681
  name: "ntnyq/sort/tsconfig",
574
682
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
575
683
  rules: {
@@ -685,7 +793,7 @@ var sort = (options = {}) => {
685
793
  });
686
794
  }
687
795
  if (options.packageJson ?? true) {
688
- configs.push({
796
+ configs2.push({
689
797
  name: "ntnyq/sort/package-json",
690
798
  files: ["**/package.json"],
691
799
  rules: {
@@ -817,7 +925,7 @@ var sort = (options = {}) => {
817
925
  });
818
926
  }
819
927
  if (options.i18nLocale ?? true) {
820
- configs.push(
928
+ configs2.push(
821
929
  {
822
930
  name: "ntnyq/sort/i18n-locale/json",
823
931
  files: ["**/{locales,i18n}/*.json"],
@@ -847,7 +955,7 @@ var sort = (options = {}) => {
847
955
  );
848
956
  }
849
957
  if (options.pnpmWorkspace ?? true) {
850
- configs.push({
958
+ configs2.push({
851
959
  name: "ntnyq/sort/pnpm-workspace",
852
960
  files: ["**/pnpm-workspace.yaml"],
853
961
  rules: {
@@ -861,7 +969,7 @@ var sort = (options = {}) => {
861
969
  }
862
970
  });
863
971
  }
864
- return configs;
972
+ return configs2;
865
973
  };
866
974
 
867
975
  // src/configs/toml.ts
@@ -918,11 +1026,11 @@ var vitest = (options = {}) => [
918
1026
  {
919
1027
  name: "ntnyq/vitest",
920
1028
  plugins: {
921
- vitest: default12
1029
+ vitest: default13
922
1030
  },
923
1031
  files: [...GLOB_TEST],
924
1032
  rules: {
925
- ...default12.configs.recommended.rules,
1033
+ ...default13.configs.recommended.rules,
926
1034
  // Overrides rules
927
1035
  ...options.overridesVitestRules
928
1036
  }
@@ -940,7 +1048,9 @@ var antfu = (options = {}) => [
940
1048
  // required `object-curly-newline` to be disabled
941
1049
  // 'antfu/consistent-list-newline': 'error',
942
1050
  "antfu/import-dedupe": "error",
943
- "antfu/top-level-function": "error",
1051
+ "antfu/no-import-dist": "error",
1052
+ "antfu/indent-unindent": "error",
1053
+ "antfu/no-import-node-modules-by-path": "error",
944
1054
  // Overrides rules
945
1055
  ...options.overrides
946
1056
  }
@@ -1040,9 +1150,9 @@ var ntnyq = (options = {}) => [
1040
1150
 
1041
1151
  // src/configs/regexp.ts
1042
1152
  var regexp = (options = {}) => {
1043
- const config = pluginRegexp.configs["flat/recommended"];
1153
+ const config2 = pluginRegexp.configs["flat/recommended"];
1044
1154
  const rules = {
1045
- ...config.rules
1155
+ ...config2.rules
1046
1156
  };
1047
1157
  if (options.level === "warn") {
1048
1158
  for (const key in rules) {
@@ -1053,7 +1163,7 @@ var regexp = (options = {}) => {
1053
1163
  }
1054
1164
  return [
1055
1165
  {
1056
- ...config,
1166
+ ...config2,
1057
1167
  name: "ntnyq/regexp",
1058
1168
  rules: {
1059
1169
  ...rules,
@@ -1069,7 +1179,7 @@ var unocss = (options = {}) => [
1069
1179
  {
1070
1180
  name: "ntnyq/unocss",
1071
1181
  plugins: {
1072
- unocss: default11
1182
+ unocss: default12
1073
1183
  },
1074
1184
  rules: {
1075
1185
  "unocss/order": "error",
@@ -1081,6 +1191,202 @@ var unocss = (options = {}) => [
1081
1191
  }
1082
1192
  ];
1083
1193
 
1194
+ // src/constants.ts
1195
+ var DEFAULT_PRETTIER_OPTIONS = {
1196
+ // Maximum line length
1197
+ printWidth: 100,
1198
+ // Specify the number of spaces per indentation-level
1199
+ tabWidth: 2,
1200
+ // Indent lines with tabs instead of spaces
1201
+ useTabs: false,
1202
+ // Use semicolons or not
1203
+ semi: false,
1204
+ // Use single quotes instead of double quotes
1205
+ singleQuote: true,
1206
+ // Change when properties in objects are quoted
1207
+ quoteProps: "as-needed",
1208
+ // Use single quotes instead of double quotes in JSX
1209
+ jsxSingleQuote: true,
1210
+ // Print trailing commas wherever possible when multi-line
1211
+ trailingComma: "all",
1212
+ // Print spaces between brackets in object literals.
1213
+ bracketSpacing: true,
1214
+ // 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)
1215
+ bracketSameLine: false,
1216
+ // Include parentheses around a sole arrow function parameter
1217
+ arrowParens: "avoid",
1218
+ // Format only a segment of a file.
1219
+ rangeStart: 0,
1220
+ rangeEnd: Number.POSITIVE_INFINITY,
1221
+ // Specify which parser to use.
1222
+ // parser: undefined,
1223
+ // Specify the file name to use to infer which parser to use.
1224
+ // filepath: undefined,
1225
+ // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1226
+ requirePragma: false,
1227
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1228
+ insertPragma: false,
1229
+ // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1230
+ proseWrap: "preserve",
1231
+ // Specify the global whitespace sensitivity for HTML files
1232
+ htmlWhitespaceSensitivity: "css",
1233
+ // Whether or not to indent the code inside <script> and <style> tags in Vue files
1234
+ vueIndentScriptAndStyle: false,
1235
+ // End of line
1236
+ endOfLine: "lf",
1237
+ // Control whether Prettier formats quoted code embedded in the file
1238
+ embeddedLanguageFormatting: "auto",
1239
+ // Enforce single attribute per line in HTML, Vue and JSX
1240
+ singleAttributePerLine: true
1241
+ };
1242
+
1243
+ // src/utils/env.ts
1244
+ import { resolve } from "node:path";
1245
+ import process2 from "node:process";
1246
+ import { isPackageExists } from "local-pkg";
1247
+ var hasTypeScript = isPackageExists("typescript");
1248
+ var hasVitest = isPackageExists("vitest");
1249
+ var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
1250
+ paths: [resolve(process2.cwd(), "playground")]
1251
+ });
1252
+ var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
1253
+
1254
+ // src/utils/toArray.ts
1255
+ function toArray(val) {
1256
+ val = val ?? [];
1257
+ return Array.isArray(val) ? val : [val];
1258
+ }
1259
+
1260
+ // src/utils/interopDefault.ts
1261
+ async function interopDefault(mod) {
1262
+ const resolved = await mod;
1263
+ return resolved.default || resolved;
1264
+ }
1265
+
1266
+ // src/utils/loadPlugin.ts
1267
+ async function loadPlugin(name) {
1268
+ const mod = await import(name).catch((err) => {
1269
+ console.error(err);
1270
+ throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
1271
+ });
1272
+ return interopDefault(mod);
1273
+ }
1274
+
1275
+ // src/utils/resolveSubOptions.ts
1276
+ function resolveSubOptions(options, key) {
1277
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1278
+ }
1279
+
1280
+ // src/utils/getOverrides.ts
1281
+ function getOverrides(options, key) {
1282
+ const sub = resolveSubOptions(options, key);
1283
+ return "overrides" in sub && sub.overrides ? sub.overrides : {};
1284
+ }
1285
+
1286
+ // src/utils/mergePrettierOptions.ts
1287
+ function mergePrettierOptions(options = {}, overrides = {}) {
1288
+ const result = {
1289
+ ...options,
1290
+ ...overrides,
1291
+ plugins: [
1292
+ // built-in plugins
1293
+ ...options.plugins || [],
1294
+ // custom plugins
1295
+ ...overrides.plugins || []
1296
+ ]
1297
+ };
1298
+ return result;
1299
+ }
1300
+
1301
+ // src/configs/format.ts
1302
+ var format = (options = {}) => {
1303
+ const {
1304
+ css: enableCSS = true,
1305
+ html: enableHTML = true,
1306
+ // user custom options
1307
+ prettierOptions = {}
1308
+ } = options;
1309
+ const sharedPrettierOptions = {
1310
+ ...DEFAULT_PRETTIER_OPTIONS,
1311
+ ...prettierOptions
1312
+ };
1313
+ const configs2 = [
1314
+ {
1315
+ name: "ntnyq/format/setup",
1316
+ plugins: {
1317
+ format: default11
1318
+ }
1319
+ }
1320
+ ];
1321
+ if (enableCSS) {
1322
+ configs2.push(
1323
+ {
1324
+ name: "ntnyq/format/css",
1325
+ files: [GLOB_CSS, GLOB_POSTCSS],
1326
+ languageOptions: {
1327
+ parser: parserPlain
1328
+ },
1329
+ rules: {
1330
+ "format/prettier": [
1331
+ "error",
1332
+ mergePrettierOptions(sharedPrettierOptions, {
1333
+ parser: "css"
1334
+ })
1335
+ ]
1336
+ }
1337
+ },
1338
+ {
1339
+ name: "ntnyq/format/scss",
1340
+ files: [GLOB_SCSS],
1341
+ languageOptions: {
1342
+ parser: parserPlain
1343
+ },
1344
+ rules: {
1345
+ "format/prettier": [
1346
+ "error",
1347
+ mergePrettierOptions(sharedPrettierOptions, {
1348
+ parser: "scss"
1349
+ })
1350
+ ]
1351
+ }
1352
+ },
1353
+ {
1354
+ name: "ntnyq/format/less",
1355
+ files: [GLOB_LESS],
1356
+ languageOptions: {
1357
+ parser: parserPlain
1358
+ },
1359
+ rules: {
1360
+ "format/prettier": [
1361
+ "error",
1362
+ mergePrettierOptions(sharedPrettierOptions, {
1363
+ parser: "less"
1364
+ })
1365
+ ]
1366
+ }
1367
+ }
1368
+ );
1369
+ }
1370
+ if (enableHTML) {
1371
+ configs2.push({
1372
+ name: "ntnyq/format/html",
1373
+ files: [GLOB_HTML],
1374
+ languageOptions: {
1375
+ parser: parserPlain
1376
+ },
1377
+ rules: {
1378
+ "format/prettier": [
1379
+ "error",
1380
+ mergePrettierOptions(sharedPrettierOptions, {
1381
+ parser: "html"
1382
+ })
1383
+ ]
1384
+ }
1385
+ });
1386
+ }
1387
+ return configs2;
1388
+ };
1389
+
1084
1390
  // src/configs/command.ts
1085
1391
  import createCommandConfig from "eslint-plugin-command/config";
1086
1392
  var command = (options = {}) => [
@@ -1107,7 +1413,7 @@ var imports = (options = {}) => [
1107
1413
  {
1108
1414
  name: "ntnyq/imports",
1109
1415
  plugins: {
1110
- import: default13
1416
+ import: default14
1111
1417
  },
1112
1418
  settings: {
1113
1419
  "import/resolver": {
@@ -1134,22 +1440,23 @@ var imports = (options = {}) => [
1134
1440
  ];
1135
1441
 
1136
1442
  // src/configs/unicorn.ts
1443
+ var disabledRules2 = {
1444
+ "unicorn/better-regex": "off",
1445
+ "unicorn/prefer-top-level-await": "off",
1446
+ "unicorn/explicit-length-check": "off",
1447
+ "unicorn/no-array-callback-reference": "off",
1448
+ /**
1449
+ * @see https://caniuse.com/?search=globalThis
1450
+ */
1451
+ "unicorn/prefer-global-this": "off"
1452
+ };
1137
1453
  var unicorn = (options = {}) => [
1138
1454
  {
1139
1455
  name: "ntnyq/unicorn",
1140
1456
  plugins: {
1141
- unicorn: default14
1457
+ unicorn: default15
1142
1458
  },
1143
1459
  rules: {
1144
- // Disabled for now
1145
- "unicorn/better-regex": "off",
1146
- "unicorn/prefer-top-level-await": "off",
1147
- "unicorn/explicit-length-check": "off",
1148
- "unicorn/no-array-callback-reference": "off",
1149
- /**
1150
- * @see https://caniuse.com/?search=globalThis
1151
- */
1152
- "unicorn/prefer-global-this": "off",
1153
1460
  "unicorn/error-message": "error",
1154
1461
  "unicorn/escape-case": "error",
1155
1462
  "unicorn/no-new-buffer": "error",
@@ -1160,7 +1467,6 @@ var unicorn = (options = {}) => [
1160
1467
  "unicorn/no-unnecessary-await": "error",
1161
1468
  "unicorn/switch-case-braces": ["error", "avoid"],
1162
1469
  "unicorn/no-typeof-undefined": "error",
1163
- "unicorn/prefer-set-size": "error",
1164
1470
  "unicorn/prefer-regexp-test": "error",
1165
1471
  "unicorn/no-static-only-class": "error",
1166
1472
  "unicorn/no-zero-fractions": "error",
@@ -1180,6 +1486,7 @@ var unicorn = (options = {}) => [
1180
1486
  "unicorn/prefer-prototype-methods": "error",
1181
1487
  "unicorn/prefer-reflect-apply": "error",
1182
1488
  "unicorn/prefer-math-min-max": "error",
1489
+ "unicorn/prefer-structured-clone": "error",
1183
1490
  "unicorn/consistent-existence-index-check": "error",
1184
1491
  "unicorn/catch-error-name": [
1185
1492
  "error",
@@ -1190,6 +1497,7 @@ var unicorn = (options = {}) => [
1190
1497
  ],
1191
1498
  "unicorn/prefer-date-now": "error",
1192
1499
  // String
1500
+ "unicorn/prefer-code-point": "error",
1193
1501
  "unicorn/prefer-string-slice": "error",
1194
1502
  "unicorn/prefer-string-trim-start-end": "error",
1195
1503
  "unicorn/prefer-string-starts-ends-with": "error",
@@ -1211,6 +1519,11 @@ var unicorn = (options = {}) => [
1211
1519
  "unicorn/prefer-array-some": "error",
1212
1520
  "unicorn/prefer-array-flat-map": "error",
1213
1521
  "unicorn/prefer-array-index-of": "error",
1522
+ "unicorn/require-array-join-separator": "error",
1523
+ // Set
1524
+ "unicorn/prefer-set-has": "error",
1525
+ "unicorn/prefer-set-size": "error",
1526
+ ...disabledRules2,
1214
1527
  // Overrides rules
1215
1528
  ...options.overrides
1216
1529
  }
@@ -1260,10 +1573,10 @@ var comments = (options = {}) => [
1260
1573
  {
1261
1574
  name: "ntnyq/eslint-comments",
1262
1575
  plugins: {
1263
- "@eslint-community/eslint-comments": default18
1576
+ "@eslint-community/eslint-comments": default20
1264
1577
  },
1265
1578
  rules: {
1266
- ...default18.configs.recommended.rules,
1579
+ ...default20.configs.recommended.rules,
1267
1580
  "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
1268
1581
  // Overrides rules
1269
1582
  ...options.overrides
@@ -1275,9 +1588,9 @@ var comments = (options = {}) => [
1275
1588
  var markdown = (options = {}) => {
1276
1589
  if (!Array.isArray(default7.configs?.processor)) return [];
1277
1590
  return [
1278
- ...default7.configs.processor.map((config) => ({
1279
- ...config,
1280
- name: `ntnyq/${config.name}`
1591
+ ...default7.configs.processor.map((config2) => ({
1592
+ ...config2,
1593
+ name: `ntnyq/${config2.name}`
1281
1594
  })),
1282
1595
  {
1283
1596
  name: "ntnyq/markdown/disabled/code-blocks",
@@ -1320,7 +1633,7 @@ var prettier = (options = {}) => {
1320
1633
  {
1321
1634
  name: "ntnyq/prettier",
1322
1635
  plugins: {
1323
- prettier: default15
1636
+ prettier: default16
1324
1637
  },
1325
1638
  rules: {
1326
1639
  "vue/array-bracket-newline": "off",
@@ -1360,7 +1673,7 @@ var prettier = (options = {}) => {
1360
1673
  "vue/space-infix-ops": "off",
1361
1674
  "vue/space-unary-ops": "off",
1362
1675
  "vue/template-curly-spacing": "off",
1363
- ...default15.configs.recommended.rules,
1676
+ ...default16.configs.recommended.rules,
1364
1677
  "prettier/prettier": options.level || "warn",
1365
1678
  // Overrides rules
1366
1679
  ...options.overrides
@@ -1373,7 +1686,7 @@ var prettier = (options = {}) => {
1373
1686
  name: "ntnyq/prettier/disabled",
1374
1687
  files: [...disabledFiles, ...userDisabledFiles],
1375
1688
  plugins: {
1376
- prettier: default15
1689
+ prettier: default16
1377
1690
  },
1378
1691
  rules: {
1379
1692
  "prettier/prettier": "off"
@@ -1627,12 +1940,28 @@ var jsx = () => [
1627
1940
  }
1628
1941
  ];
1629
1942
 
1943
+ // src/configs/githubAction.ts
1944
+ var githubAction = (options = {}) => [
1945
+ {
1946
+ name: "ntnyq/github-action",
1947
+ files: [GLOB_GITHUB_ACTION],
1948
+ plugins: {
1949
+ "github-action": default17
1950
+ },
1951
+ rules: {
1952
+ "github-action/require-action-name": "error",
1953
+ // Overrides rules
1954
+ ...options.overrides
1955
+ }
1956
+ }
1957
+ ];
1958
+
1630
1959
  // src/configs/perfectionist.ts
1631
1960
  var perfectionist = (options = {}) => [
1632
1961
  {
1633
1962
  name: "ntnyq/perfectionist",
1634
1963
  plugins: {
1635
- perfectionist: default16
1964
+ perfectionist: default18
1636
1965
  },
1637
1966
  rules: {
1638
1967
  "perfectionist/sort-imports": [
@@ -1677,7 +2006,7 @@ var perfectionist = (options = {}) => [
1677
2006
  order: options.imports?.order || "asc",
1678
2007
  type: options.imports?.type || "natural",
1679
2008
  ignoreCase: true,
1680
- internalPattern: ["~/**", "@/**", "#**"],
2009
+ internalPattern: ["^~/.+", "^@/.+", "^#.+"],
1681
2010
  newlinesBetween: "ignore"
1682
2011
  }
1683
2012
  ],
@@ -1718,7 +2047,7 @@ var unusedImports = (options = {}) => [
1718
2047
  {
1719
2048
  name: "ntnyq/unused-imports",
1720
2049
  plugins: {
1721
- "unused-imports": default17
2050
+ "unused-imports": default19
1722
2051
  },
1723
2052
  rules: {
1724
2053
  "@typescript-eslint/no-unused-vars": "off",
@@ -1742,60 +2071,17 @@ var unusedImports = (options = {}) => [
1742
2071
  }
1743
2072
  ];
1744
2073
 
1745
- // src/utils/env.ts
1746
- import { resolve } from "node:path";
1747
- import process2 from "node:process";
1748
- import { isPackageExists } from "local-pkg";
1749
- var hasTypeScript = isPackageExists("typescript");
1750
- var hasVitest = isPackageExists("vitest");
1751
- var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
1752
- paths: [resolve(process2.cwd(), "playground")]
1753
- });
1754
- var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
1755
-
1756
- // src/utils/toArray.ts
1757
- function toArray(val) {
1758
- val = val ?? [];
1759
- return Array.isArray(val) ? val : [val];
1760
- }
1761
-
1762
- // src/utils/interopDefault.ts
1763
- async function interopDefault(mod) {
1764
- const resolved = await mod;
1765
- return resolved.default || resolved;
1766
- }
1767
-
1768
- // src/utils/loadPlugin.ts
1769
- async function loadPlugin(name) {
1770
- const mod = await import(name).catch((err) => {
1771
- console.error(err);
1772
- throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
1773
- });
1774
- return interopDefault(mod);
1775
- }
1776
-
1777
- // src/utils/resolveSubOptions.ts
1778
- function resolveSubOptions(options, key) {
1779
- return typeof options[key] === "boolean" ? {} : options[key] || {};
1780
- }
1781
-
1782
- // src/utils/getOverrides.ts
1783
- function getOverrides(options, key) {
1784
- const sub = resolveSubOptions(options, key);
1785
- return "overrides" in sub && sub.overrides ? sub.overrides : {};
1786
- }
1787
-
1788
2074
  // src/core.ts
1789
2075
  function defineESLintConfig(options = {}, userConfigs = []) {
1790
- const configs = [];
2076
+ const configs2 = [];
1791
2077
  if (options.gitignore ?? true) {
1792
- configs.push(
2078
+ configs2.push(
1793
2079
  ...gitignore({
1794
2080
  ...resolveSubOptions(options, "gitignore")
1795
2081
  })
1796
2082
  );
1797
2083
  }
1798
- configs.push(
2084
+ configs2.push(
1799
2085
  ...ignores(options.ignores),
1800
2086
  ...jsx(),
1801
2087
  ...node({
@@ -1810,7 +2096,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1810
2096
  })
1811
2097
  );
1812
2098
  if (options.perfectionist ?? true) {
1813
- configs.push(
2099
+ configs2.push(
1814
2100
  ...perfectionist({
1815
2101
  ...resolveSubOptions(options, "perfectionist"),
1816
2102
  overrides: getOverrides(options, "perfectionist")
@@ -1818,14 +2104,14 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1818
2104
  );
1819
2105
  }
1820
2106
  if (options.unicorn ?? true) {
1821
- configs.push(
2107
+ configs2.push(
1822
2108
  ...unicorn({
1823
2109
  overrides: getOverrides(options, "unicorn")
1824
2110
  })
1825
2111
  );
1826
2112
  }
1827
2113
  if (options.regexp ?? true) {
1828
- configs.push(
2114
+ configs2.push(
1829
2115
  ...regexp({
1830
2116
  ...resolveSubOptions(options, "regexp"),
1831
2117
  overrides: getOverrides(options, "regexp")
@@ -1833,21 +2119,21 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1833
2119
  );
1834
2120
  }
1835
2121
  if (options.jsdoc ?? true) {
1836
- configs.push(
2122
+ configs2.push(
1837
2123
  ...jsdoc({
1838
2124
  overrides: getOverrides(options, "jsdoc")
1839
2125
  })
1840
2126
  );
1841
2127
  }
1842
2128
  if (options.comments ?? true) {
1843
- configs.push(
2129
+ configs2.push(
1844
2130
  ...comments({
1845
2131
  overrides: getOverrides(options, "comments")
1846
2132
  })
1847
2133
  );
1848
2134
  }
1849
2135
  if (options.typescript ?? hasTypeScript) {
1850
- configs.push(
2136
+ configs2.push(
1851
2137
  ...typescript({
1852
2138
  ...resolveSubOptions(options, "typescript"),
1853
2139
  overrides: getOverrides(options, "typescript")
@@ -1855,35 +2141,35 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1855
2141
  );
1856
2142
  }
1857
2143
  if (options.yml ?? true) {
1858
- configs.push(
2144
+ configs2.push(
1859
2145
  ...yml({
1860
2146
  overrides: getOverrides(options, "yml")
1861
2147
  })
1862
2148
  );
1863
2149
  }
1864
2150
  if (options.toml ?? true) {
1865
- configs.push(
2151
+ configs2.push(
1866
2152
  ...toml({
1867
2153
  overrides: getOverrides(options, "toml")
1868
2154
  })
1869
2155
  );
1870
2156
  }
1871
2157
  if (options.jsonc ?? true) {
1872
- configs.push(
2158
+ configs2.push(
1873
2159
  ...jsonc({
1874
2160
  overrides: getOverrides(options, "jsonc")
1875
2161
  })
1876
2162
  );
1877
2163
  }
1878
2164
  if (options.sort ?? true) {
1879
- configs.push(
2165
+ configs2.push(
1880
2166
  ...sort({
1881
2167
  ...resolveSubOptions(options, "sort")
1882
2168
  })
1883
2169
  );
1884
2170
  }
1885
2171
  if (options.vue ?? hasVue) {
1886
- configs.push(
2172
+ configs2.push(
1887
2173
  ...vue({
1888
2174
  ...resolveSubOptions(options, "vue"),
1889
2175
  overrides: getOverrides(options, "vue")
@@ -1891,7 +2177,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1891
2177
  );
1892
2178
  }
1893
2179
  if (options.test ?? hasVitest) {
1894
- configs.push(
2180
+ configs2.push(
1895
2181
  ...test({
1896
2182
  overrides: getOverrides(options, "test")
1897
2183
  }),
@@ -1901,26 +2187,40 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1901
2187
  );
1902
2188
  }
1903
2189
  if (options.unocss ?? hasUnoCSS) {
1904
- configs.push(
2190
+ configs2.push(
1905
2191
  ...unocss({
1906
2192
  overrides: getOverrides(options, "unocss")
1907
2193
  })
1908
2194
  );
1909
2195
  }
1910
2196
  if (options.markdown ?? true) {
1911
- configs.push(
2197
+ configs2.push(
1912
2198
  ...markdown({
1913
2199
  overrides: getOverrides(options, "markdown")
1914
2200
  })
1915
2201
  );
1916
2202
  }
1917
2203
  if (options.command ?? true) {
1918
- configs.push(
2204
+ configs2.push(
1919
2205
  ...command({
1920
2206
  ...resolveSubOptions(options, "command")
1921
2207
  })
1922
2208
  );
1923
2209
  }
2210
+ if (options.antfu ?? true) {
2211
+ configs2.push(
2212
+ ...antfu({
2213
+ overrides: getOverrides(options, "antfu")
2214
+ })
2215
+ );
2216
+ }
2217
+ if (options.githubAction ?? true) {
2218
+ configs2.push(
2219
+ ...githubAction({
2220
+ overrides: getOverrides(options, "githubAction")
2221
+ })
2222
+ );
2223
+ }
1924
2224
  const configSpecials = specials();
1925
2225
  const configPrettier = options.prettier ?? true ? prettier({
1926
2226
  ...resolveSubOptions(options, "prettier"),
@@ -1928,7 +2228,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1928
2228
  }) : [];
1929
2229
  const composer = new FlatConfigComposer();
1930
2230
  composer.append(
1931
- ...configs,
2231
+ ...configs2,
1932
2232
  ...toArray(userConfigs),
1933
2233
  ...configSpecials,
1934
2234
  ...configPrettier
@@ -1936,12 +2236,14 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1936
2236
  return composer;
1937
2237
  }
1938
2238
  export {
2239
+ DEFAULT_PRETTIER_OPTIONS,
1939
2240
  GLOB_ALL_SRC,
1940
2241
  GLOB_ASTRO,
1941
2242
  GLOB_CSS,
1942
2243
  GLOB_DIST,
1943
2244
  GLOB_DTS,
1944
2245
  GLOB_EXCLUDE,
2246
+ GLOB_GITHUB_ACTION,
1945
2247
  GLOB_HTML,
1946
2248
  GLOB_JS,
1947
2249
  GLOB_JSON,
@@ -1954,6 +2256,7 @@ export {
1954
2256
  GLOB_MARKDOWN_CODE,
1955
2257
  GLOB_MARKDOWN_NESTED,
1956
2258
  GLOB_NODE_MODULES,
2259
+ GLOB_POSTCSS,
1957
2260
  GLOB_SCSS,
1958
2261
  GLOB_SRC,
1959
2262
  GLOB_SRC_EXT,
@@ -1968,8 +2271,11 @@ export {
1968
2271
  antfu,
1969
2272
  command,
1970
2273
  comments,
2274
+ config as createTypeScriptConfig,
1971
2275
  defineESLintConfig,
2276
+ format,
1972
2277
  getOverrides,
2278
+ githubAction,
1973
2279
  gitignore,
1974
2280
  hasTypeScript,
1975
2281
  hasUnoCSS,
@@ -1984,32 +2290,41 @@ export {
1984
2290
  jsx,
1985
2291
  loadPlugin,
1986
2292
  markdown,
2293
+ mergePrettierOptions,
2294
+ mergeProcessors,
1987
2295
  node,
1988
2296
  ntnyq,
1989
2297
  parserJsonc,
2298
+ parserPlain,
1990
2299
  parserToml,
2300
+ parserTypeScript,
1991
2301
  parserVue,
1992
2302
  parserYaml,
1993
2303
  perfectionist,
1994
2304
  default8 as pluginAntfu,
1995
- default18 as pluginComments,
1996
- default13 as pluginImport,
2305
+ default20 as pluginComments,
2306
+ default11 as pluginFormat,
2307
+ default17 as pluginGitHubAction,
2308
+ default14 as pluginImport,
1997
2309
  default9 as pluginJsdoc,
1998
2310
  default10 as pluginJsonc,
1999
2311
  default7 as pluginMarkdown,
2000
2312
  default2 as pluginNode,
2001
2313
  default6 as pluginNtnyq,
2002
- default16 as pluginPerfectionist,
2003
- default15 as pluginPrettier,
2314
+ default18 as pluginPerfectionist,
2315
+ default16 as pluginPrettier,
2004
2316
  pluginRegexp,
2005
2317
  default5 as pluginToml,
2006
- default14 as pluginUnicorn,
2007
- default11 as pluginUnoCSS,
2008
- default17 as pluginUnusedImports,
2009
- default12 as pluginVitest,
2318
+ plugin as pluginTypeScript,
2319
+ default15 as pluginUnicorn,
2320
+ default12 as pluginUnoCSS,
2321
+ default19 as pluginUnusedImports,
2322
+ default13 as pluginVitest,
2010
2323
  default3 as pluginVue,
2011
2324
  default4 as pluginYaml,
2012
2325
  prettier,
2326
+ processorPassThrough,
2327
+ default21 as processorVueBlocks,
2013
2328
  regexp,
2014
2329
  resolveSubOptions,
2015
2330
  sort,
@@ -2017,8 +2332,8 @@ export {
2017
2332
  test,
2018
2333
  toArray,
2019
2334
  toml,
2020
- tseslint,
2021
2335
  typescript,
2336
+ configs as typescriptConfigs,
2022
2337
  typescriptCore,
2023
2338
  unicorn,
2024
2339
  unocss,