@ntnyq/eslint-config 3.2.2 → 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.cjs CHANGED
@@ -30,12 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ DEFAULT_PRETTIER_OPTIONS: () => DEFAULT_PRETTIER_OPTIONS,
33
34
  GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
35
  GLOB_ASTRO: () => GLOB_ASTRO,
35
36
  GLOB_CSS: () => GLOB_CSS,
36
37
  GLOB_DIST: () => GLOB_DIST,
37
38
  GLOB_DTS: () => GLOB_DTS,
38
39
  GLOB_EXCLUDE: () => GLOB_EXCLUDE,
40
+ GLOB_GITHUB_ACTION: () => GLOB_GITHUB_ACTION,
39
41
  GLOB_HTML: () => GLOB_HTML,
40
42
  GLOB_JS: () => GLOB_JS,
41
43
  GLOB_JSON: () => GLOB_JSON,
@@ -48,6 +50,7 @@ __export(src_exports, {
48
50
  GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
49
51
  GLOB_MARKDOWN_NESTED: () => GLOB_MARKDOWN_NESTED,
50
52
  GLOB_NODE_MODULES: () => GLOB_NODE_MODULES,
53
+ GLOB_POSTCSS: () => GLOB_POSTCSS,
51
54
  GLOB_SCSS: () => GLOB_SCSS,
52
55
  GLOB_SRC: () => GLOB_SRC,
53
56
  GLOB_SRC_EXT: () => GLOB_SRC_EXT,
@@ -62,8 +65,11 @@ __export(src_exports, {
62
65
  antfu: () => antfu,
63
66
  command: () => command,
64
67
  comments: () => comments,
68
+ createTypeScriptConfig: () => import_typescript_eslint.config,
65
69
  defineESLintConfig: () => defineESLintConfig,
70
+ format: () => format,
66
71
  getOverrides: () => getOverrides,
72
+ githubAction: () => githubAction,
67
73
  gitignore: () => gitignore,
68
74
  hasTypeScript: () => hasTypeScript,
69
75
  hasUnoCSS: () => hasUnoCSS,
@@ -78,15 +84,21 @@ __export(src_exports, {
78
84
  jsx: () => jsx,
79
85
  loadPlugin: () => loadPlugin,
80
86
  markdown: () => markdown,
87
+ mergePrettierOptions: () => mergePrettierOptions,
88
+ mergeProcessors: () => import_eslint_merge_processors.mergeProcessors,
81
89
  node: () => node,
82
90
  ntnyq: () => ntnyq,
83
91
  parserJsonc: () => parserJsonc,
92
+ parserPlain: () => parserPlain,
84
93
  parserToml: () => parserToml,
94
+ parserTypeScript: () => parserTypeScript,
85
95
  parserVue: () => parserVue,
86
96
  parserYaml: () => parserYaml,
87
97
  perfectionist: () => perfectionist,
88
98
  pluginAntfu: () => import_eslint_plugin_antfu.default,
89
99
  pluginComments: () => import_eslint_plugin_eslint_comments.default,
100
+ pluginFormat: () => import_eslint_plugin_format.default,
101
+ pluginGitHubAction: () => import_eslint_plugin_github_action.default,
90
102
  pluginImport: () => import_eslint_plugin_import_x.default,
91
103
  pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
92
104
  pluginJsonc: () => import_eslint_plugin_jsonc.default,
@@ -97,6 +109,7 @@ __export(src_exports, {
97
109
  pluginPrettier: () => import_eslint_plugin_prettier.default,
98
110
  pluginRegexp: () => pluginRegexp,
99
111
  pluginToml: () => import_eslint_plugin_toml.default,
112
+ pluginTypeScript: () => import_typescript_eslint3.plugin,
100
113
  pluginUnicorn: () => import_eslint_plugin_unicorn.default,
101
114
  pluginUnoCSS: () => import_eslint_plugin.default,
102
115
  pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
@@ -104,6 +117,8 @@ __export(src_exports, {
104
117
  pluginVue: () => import_eslint_plugin_vue.default,
105
118
  pluginYaml: () => import_eslint_plugin_yml.default,
106
119
  prettier: () => prettier,
120
+ processorPassThrough: () => import_eslint_merge_processors2.processorPassThrough,
121
+ processorVueBlocks: () => import_eslint_processor_vue_blocks.default,
107
122
  regexp: () => regexp,
108
123
  resolveSubOptions: () => resolveSubOptions,
109
124
  sort: () => sort,
@@ -111,8 +126,8 @@ __export(src_exports, {
111
126
  test: () => test,
112
127
  toArray: () => toArray,
113
128
  toml: () => toml,
114
- tseslint: () => import_typescript_eslint.default,
115
129
  typescript: () => typescript,
130
+ typescriptConfigs: () => import_typescript_eslint4.configs,
116
131
  typescriptCore: () => typescriptCore,
117
132
  unicorn: () => unicorn,
118
133
  unocss: () => unocss,
@@ -126,6 +141,71 @@ module.exports = __toCommonJS(src_exports);
126
141
  // src/core.ts
127
142
  var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
128
143
 
144
+ // src/configs/vue.ts
145
+ var import_eslint_merge_processors3 = require("eslint-merge-processors");
146
+
147
+ // src/eslint/utils.ts
148
+ var import_typescript_eslint = require("typescript-eslint");
149
+
150
+ // src/eslint/parsers.ts
151
+ var import_typescript_eslint2 = __toESM(require("typescript-eslint"), 1);
152
+ var parserVue = __toESM(require("vue-eslint-parser"), 1);
153
+ var parserToml = __toESM(require("toml-eslint-parser"), 1);
154
+ var parserYaml = __toESM(require("yaml-eslint-parser"), 1);
155
+ var parserJsonc = __toESM(require("jsonc-eslint-parser"), 1);
156
+ var parserTypeScript = import_typescript_eslint2.default.parser;
157
+ var parserPlain = {
158
+ meta: {
159
+ name: "plain-eslint-parser"
160
+ },
161
+ parseForESLint: (code) => ({
162
+ ast: {
163
+ body: [],
164
+ comments: [],
165
+ loc: { start: 0, end: code.length },
166
+ range: [0, code.length],
167
+ tokens: [],
168
+ type: "Program"
169
+ },
170
+ scopeManager: null,
171
+ services: { isPlain: true },
172
+ visitorKeys: {
173
+ Program: []
174
+ }
175
+ })
176
+ };
177
+
178
+ // src/eslint/plugins.ts
179
+ var pluginRegexp = __toESM(require("eslint-plugin-regexp"), 1);
180
+ var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
181
+ var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
182
+ var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
183
+ var import_eslint_plugin_toml = __toESM(require("eslint-plugin-toml"), 1);
184
+ var import_eslint_plugin_ntnyq = __toESM(require("eslint-plugin-ntnyq"), 1);
185
+ var import_markdown = __toESM(require("@eslint/markdown"), 1);
186
+ var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
187
+ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
188
+ var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
189
+ var import_typescript_eslint3 = require("typescript-eslint");
190
+ var import_eslint_plugin_format = __toESM(require("eslint-plugin-format"), 1);
191
+ var import_eslint_plugin = __toESM(require("@unocss/eslint-plugin"), 1);
192
+ var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
193
+ var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
194
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
195
+ var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
196
+ var import_eslint_plugin_github_action = __toESM(require("eslint-plugin-github-action"), 1);
197
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
198
+ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
199
+ var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
200
+
201
+ // src/eslint/configs.ts
202
+ var import_typescript_eslint4 = require("typescript-eslint");
203
+
204
+ // src/eslint/processors.ts
205
+ var import_eslint_merge_processors = require("eslint-merge-processors");
206
+ var import_eslint_merge_processors2 = require("eslint-merge-processors");
207
+ var import_eslint_processor_vue_blocks = __toESM(require("eslint-processor-vue-blocks"), 1);
208
+
129
209
  // src/globs.ts
130
210
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
131
211
  var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
@@ -144,6 +224,7 @@ var GLOB_STYLE = "**/*.{c,le,sc}ss";
144
224
  var GLOB_CSS = "**/*.css";
145
225
  var GLOB_LESS = "**/*.less";
146
226
  var GLOB_SCSS = "**/*.scss";
227
+ var GLOB_POSTCSS = "**/*.{p,post}css";
147
228
  var GLOB_JSON = "**/*.json";
148
229
  var GLOB_JSON5 = "**/*.json5";
149
230
  var GLOB_JSONC = "**/*.jsonc";
@@ -167,6 +248,7 @@ var GLOB_ALL_SRC = [
167
248
  GLOB_HTML,
168
249
  GLOB_MARKDOWN
169
250
  ];
251
+ var GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
170
252
  var GLOB_NODE_MODULES = "**/node_modules/**";
171
253
  var GLOB_DIST = "**/dist/**";
172
254
  var GLOB_LOCKFILE = [
@@ -221,41 +303,16 @@ var GLOB_EXCLUDE = [
221
303
  "**/.yarnrc"
222
304
  ];
223
305
 
224
- // src/plugins.ts
225
- var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
226
- var parserVue = __toESM(require("vue-eslint-parser"), 1);
227
- var parserToml = __toESM(require("toml-eslint-parser"), 1);
228
- var parserYaml = __toESM(require("yaml-eslint-parser"), 1);
229
- var parserJsonc = __toESM(require("jsonc-eslint-parser"), 1);
230
- var pluginRegexp = __toESM(require("eslint-plugin-regexp"), 1);
231
- var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
232
- var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
233
- var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
234
- var import_eslint_plugin_toml = __toESM(require("eslint-plugin-toml"), 1);
235
- var import_eslint_plugin_ntnyq = __toESM(require("eslint-plugin-ntnyq"), 1);
236
- var import_markdown = __toESM(require("@eslint/markdown"), 1);
237
- var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
238
- var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
239
- var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
240
- var import_eslint_plugin = __toESM(require("@unocss/eslint-plugin"), 1);
241
- var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
242
- var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
243
- var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
244
- var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
245
- var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
246
- var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
247
- var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
248
-
249
306
  // src/configs/typescript.ts
250
307
  var import_node_process = __toESM(require("process"), 1);
251
308
  var typescriptCore = (options = {}) => {
252
309
  const isTypeAware = !!options.tsconfigPath;
253
- const configs = import_typescript_eslint.default.config({
310
+ const configs2 = (0, import_typescript_eslint.config)({
254
311
  name: "ntnyq/ts/core",
255
- extends: [...import_typescript_eslint.default.configs.recommended],
312
+ extends: [...import_typescript_eslint4.configs.recommended],
256
313
  files: [GLOB_TS, GLOB_TSX],
257
314
  languageOptions: {
258
- parser: import_typescript_eslint.default.parser,
315
+ parser: parserTypeScript,
259
316
  parserOptions: {
260
317
  sourceType: "module",
261
318
  ...isTypeAware ? {
@@ -349,7 +406,7 @@ var typescriptCore = (options = {}) => {
349
406
  ...options.overrides
350
407
  }
351
408
  });
352
- return configs;
409
+ return configs2;
353
410
  };
354
411
  var typescript = (options = {}) => [
355
412
  ...typescriptCore(options),
@@ -561,31 +618,47 @@ var unCategorizedRules = {
561
618
  };
562
619
  var vue = (options = {}) => {
563
620
  const isVue3 = options.vueVersion !== 2;
621
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
564
622
  return [
565
- ...import_typescript_eslint.default.config({
623
+ ...(0, import_typescript_eslint.config)({
566
624
  name: "ntnyq/vue/ts",
567
625
  files: [GLOB_VUE],
568
626
  extends: typescriptCore()
569
627
  }),
570
628
  {
571
- name: "ntnyq/vue/core",
572
- files: [GLOB_VUE],
629
+ name: "ntnyq/vue/setup",
573
630
  plugins: {
574
631
  vue: import_eslint_plugin_vue.default,
575
- "@typescript-eslint": import_typescript_eslint.default.plugin
632
+ "@typescript-eslint": import_typescript_eslint3.plugin
576
633
  },
577
634
  languageOptions: {
578
- parser: parserVue,
579
635
  parserOptions: {
580
- parser: "@typescript-eslint/parser",
581
636
  sourceType: "module",
637
+ ecmaVersion: "latest",
582
638
  extraFileExtensions: [".vue"],
639
+ parser: "@typescript-eslint/parser",
583
640
  ecmaFeatures: {
584
641
  jsx: true
585
642
  }
586
643
  }
644
+ }
645
+ },
646
+ {
647
+ name: "ntnyq/vue/rules",
648
+ files: [GLOB_VUE],
649
+ languageOptions: {
650
+ parser: parserVue
587
651
  },
588
- processor: import_eslint_plugin_vue.default.processors[".vue"],
652
+ processor: sfcBlocks === false ? import_eslint_plugin_vue.default.processors[".vue"] : (0, import_eslint_merge_processors3.mergeProcessors)([
653
+ import_eslint_plugin_vue.default.processors[".vue"],
654
+ (0, import_eslint_processor_vue_blocks.default)({
655
+ ...sfcBlocks,
656
+ blocks: {
657
+ styles: true,
658
+ ...sfcBlocks.blocks
659
+ }
660
+ })
661
+ ]),
589
662
  rules: {
590
663
  ...isVue3 ? vue3Rules : vue2Rules,
591
664
  "vue/html-self-closing": [
@@ -742,9 +815,9 @@ var node = (options = {}) => [
742
815
 
743
816
  // src/configs/sort.ts
744
817
  var sort = (options = {}) => {
745
- const configs = [];
818
+ const configs2 = [];
746
819
  if (options.tsconfig ?? true) {
747
- configs.push({
820
+ configs2.push({
748
821
  name: "ntnyq/sort/tsconfig",
749
822
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
750
823
  rules: {
@@ -860,7 +933,7 @@ var sort = (options = {}) => {
860
933
  });
861
934
  }
862
935
  if (options.packageJson ?? true) {
863
- configs.push({
936
+ configs2.push({
864
937
  name: "ntnyq/sort/package-json",
865
938
  files: ["**/package.json"],
866
939
  rules: {
@@ -992,7 +1065,7 @@ var sort = (options = {}) => {
992
1065
  });
993
1066
  }
994
1067
  if (options.i18nLocale ?? true) {
995
- configs.push(
1068
+ configs2.push(
996
1069
  {
997
1070
  name: "ntnyq/sort/i18n-locale/json",
998
1071
  files: ["**/{locales,i18n}/*.json"],
@@ -1022,7 +1095,7 @@ var sort = (options = {}) => {
1022
1095
  );
1023
1096
  }
1024
1097
  if (options.pnpmWorkspace ?? true) {
1025
- configs.push({
1098
+ configs2.push({
1026
1099
  name: "ntnyq/sort/pnpm-workspace",
1027
1100
  files: ["**/pnpm-workspace.yaml"],
1028
1101
  rules: {
@@ -1036,7 +1109,7 @@ var sort = (options = {}) => {
1036
1109
  }
1037
1110
  });
1038
1111
  }
1039
- return configs;
1112
+ return configs2;
1040
1113
  };
1041
1114
 
1042
1115
  // src/configs/toml.ts
@@ -1115,7 +1188,9 @@ var antfu = (options = {}) => [
1115
1188
  // required `object-curly-newline` to be disabled
1116
1189
  // 'antfu/consistent-list-newline': 'error',
1117
1190
  "antfu/import-dedupe": "error",
1118
- "antfu/top-level-function": "error",
1191
+ "antfu/no-import-dist": "error",
1192
+ "antfu/indent-unindent": "error",
1193
+ "antfu/no-import-node-modules-by-path": "error",
1119
1194
  // Overrides rules
1120
1195
  ...options.overrides
1121
1196
  }
@@ -1215,9 +1290,9 @@ var ntnyq = (options = {}) => [
1215
1290
 
1216
1291
  // src/configs/regexp.ts
1217
1292
  var regexp = (options = {}) => {
1218
- const config = pluginRegexp.configs["flat/recommended"];
1293
+ const config2 = pluginRegexp.configs["flat/recommended"];
1219
1294
  const rules = {
1220
- ...config.rules
1295
+ ...config2.rules
1221
1296
  };
1222
1297
  if (options.level === "warn") {
1223
1298
  for (const key in rules) {
@@ -1228,7 +1303,7 @@ var regexp = (options = {}) => {
1228
1303
  }
1229
1304
  return [
1230
1305
  {
1231
- ...config,
1306
+ ...config2,
1232
1307
  name: "ntnyq/regexp",
1233
1308
  rules: {
1234
1309
  ...rules,
@@ -1256,6 +1331,202 @@ var unocss = (options = {}) => [
1256
1331
  }
1257
1332
  ];
1258
1333
 
1334
+ // src/constants.ts
1335
+ var DEFAULT_PRETTIER_OPTIONS = {
1336
+ // Maximum line length
1337
+ printWidth: 100,
1338
+ // Specify the number of spaces per indentation-level
1339
+ tabWidth: 2,
1340
+ // Indent lines with tabs instead of spaces
1341
+ useTabs: false,
1342
+ // Use semicolons or not
1343
+ semi: false,
1344
+ // Use single quotes instead of double quotes
1345
+ singleQuote: true,
1346
+ // Change when properties in objects are quoted
1347
+ quoteProps: "as-needed",
1348
+ // Use single quotes instead of double quotes in JSX
1349
+ jsxSingleQuote: true,
1350
+ // Print trailing commas wherever possible when multi-line
1351
+ trailingComma: "all",
1352
+ // Print spaces between brackets in object literals.
1353
+ bracketSpacing: true,
1354
+ // 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)
1355
+ bracketSameLine: false,
1356
+ // Include parentheses around a sole arrow function parameter
1357
+ arrowParens: "avoid",
1358
+ // Format only a segment of a file.
1359
+ rangeStart: 0,
1360
+ rangeEnd: Number.POSITIVE_INFINITY,
1361
+ // Specify which parser to use.
1362
+ // parser: undefined,
1363
+ // Specify the file name to use to infer which parser to use.
1364
+ // filepath: undefined,
1365
+ // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1366
+ requirePragma: false,
1367
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1368
+ insertPragma: false,
1369
+ // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1370
+ proseWrap: "preserve",
1371
+ // Specify the global whitespace sensitivity for HTML files
1372
+ htmlWhitespaceSensitivity: "css",
1373
+ // Whether or not to indent the code inside <script> and <style> tags in Vue files
1374
+ vueIndentScriptAndStyle: false,
1375
+ // End of line
1376
+ endOfLine: "lf",
1377
+ // Control whether Prettier formats quoted code embedded in the file
1378
+ embeddedLanguageFormatting: "auto",
1379
+ // Enforce single attribute per line in HTML, Vue and JSX
1380
+ singleAttributePerLine: true
1381
+ };
1382
+
1383
+ // src/utils/env.ts
1384
+ var import_node_path = require("path");
1385
+ var import_node_process2 = __toESM(require("process"), 1);
1386
+ var import_local_pkg = require("local-pkg");
1387
+ var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
1388
+ var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
1389
+ var hasVue = (0, import_local_pkg.isPackageExists)("vue") || (0, import_local_pkg.isPackageExists)("nuxt") || (0, import_local_pkg.isPackageExists)("vitepress") || (0, import_local_pkg.isPackageExists)("@slidev/cli") || (0, import_local_pkg.isPackageExists)("vue", {
1390
+ paths: [(0, import_node_path.resolve)(import_node_process2.default.cwd(), "playground")]
1391
+ });
1392
+ var hasUnoCSS = (0, import_local_pkg.isPackageExists)("unocss") || (0, import_local_pkg.isPackageExists)("@unocss/postcss") || (0, import_local_pkg.isPackageExists)("@unocss/webpack") || (0, import_local_pkg.isPackageExists)("@unocss/nuxt");
1393
+
1394
+ // src/utils/toArray.ts
1395
+ function toArray(val) {
1396
+ val = val ?? [];
1397
+ return Array.isArray(val) ? val : [val];
1398
+ }
1399
+
1400
+ // src/utils/interopDefault.ts
1401
+ async function interopDefault(mod) {
1402
+ const resolved = await mod;
1403
+ return resolved.default || resolved;
1404
+ }
1405
+
1406
+ // src/utils/loadPlugin.ts
1407
+ async function loadPlugin(name) {
1408
+ const mod = await import(name).catch((err) => {
1409
+ console.error(err);
1410
+ throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
1411
+ });
1412
+ return interopDefault(mod);
1413
+ }
1414
+
1415
+ // src/utils/resolveSubOptions.ts
1416
+ function resolveSubOptions(options, key) {
1417
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1418
+ }
1419
+
1420
+ // src/utils/getOverrides.ts
1421
+ function getOverrides(options, key) {
1422
+ const sub = resolveSubOptions(options, key);
1423
+ return "overrides" in sub && sub.overrides ? sub.overrides : {};
1424
+ }
1425
+
1426
+ // src/utils/mergePrettierOptions.ts
1427
+ function mergePrettierOptions(options = {}, overrides = {}) {
1428
+ const result = {
1429
+ ...options,
1430
+ ...overrides,
1431
+ plugins: [
1432
+ // built-in plugins
1433
+ ...options.plugins || [],
1434
+ // custom plugins
1435
+ ...overrides.plugins || []
1436
+ ]
1437
+ };
1438
+ return result;
1439
+ }
1440
+
1441
+ // src/configs/format.ts
1442
+ var format = (options = {}) => {
1443
+ const {
1444
+ css: enableCSS = true,
1445
+ html: enableHTML = true,
1446
+ // user custom options
1447
+ prettierOptions = {}
1448
+ } = options;
1449
+ const sharedPrettierOptions = {
1450
+ ...DEFAULT_PRETTIER_OPTIONS,
1451
+ ...prettierOptions
1452
+ };
1453
+ const configs2 = [
1454
+ {
1455
+ name: "ntnyq/format/setup",
1456
+ plugins: {
1457
+ format: import_eslint_plugin_format.default
1458
+ }
1459
+ }
1460
+ ];
1461
+ if (enableCSS) {
1462
+ configs2.push(
1463
+ {
1464
+ name: "ntnyq/format/css",
1465
+ files: [GLOB_CSS, GLOB_POSTCSS],
1466
+ languageOptions: {
1467
+ parser: parserPlain
1468
+ },
1469
+ rules: {
1470
+ "format/prettier": [
1471
+ "error",
1472
+ mergePrettierOptions(sharedPrettierOptions, {
1473
+ parser: "css"
1474
+ })
1475
+ ]
1476
+ }
1477
+ },
1478
+ {
1479
+ name: "ntnyq/format/scss",
1480
+ files: [GLOB_SCSS],
1481
+ languageOptions: {
1482
+ parser: parserPlain
1483
+ },
1484
+ rules: {
1485
+ "format/prettier": [
1486
+ "error",
1487
+ mergePrettierOptions(sharedPrettierOptions, {
1488
+ parser: "scss"
1489
+ })
1490
+ ]
1491
+ }
1492
+ },
1493
+ {
1494
+ name: "ntnyq/format/less",
1495
+ files: [GLOB_LESS],
1496
+ languageOptions: {
1497
+ parser: parserPlain
1498
+ },
1499
+ rules: {
1500
+ "format/prettier": [
1501
+ "error",
1502
+ mergePrettierOptions(sharedPrettierOptions, {
1503
+ parser: "less"
1504
+ })
1505
+ ]
1506
+ }
1507
+ }
1508
+ );
1509
+ }
1510
+ if (enableHTML) {
1511
+ configs2.push({
1512
+ name: "ntnyq/format/html",
1513
+ files: [GLOB_HTML],
1514
+ languageOptions: {
1515
+ parser: parserPlain
1516
+ },
1517
+ rules: {
1518
+ "format/prettier": [
1519
+ "error",
1520
+ mergePrettierOptions(sharedPrettierOptions, {
1521
+ parser: "html"
1522
+ })
1523
+ ]
1524
+ }
1525
+ });
1526
+ }
1527
+ return configs2;
1528
+ };
1529
+
1259
1530
  // src/configs/command.ts
1260
1531
  var import_config = __toESM(require("eslint-plugin-command/config"), 1);
1261
1532
  var command = (options = {}) => [
@@ -1457,9 +1728,9 @@ var comments = (options = {}) => [
1457
1728
  var markdown = (options = {}) => {
1458
1729
  if (!Array.isArray(import_markdown.default.configs?.processor)) return [];
1459
1730
  return [
1460
- ...import_markdown.default.configs.processor.map((config) => ({
1461
- ...config,
1462
- name: `ntnyq/${config.name}`
1731
+ ...import_markdown.default.configs.processor.map((config2) => ({
1732
+ ...config2,
1733
+ name: `ntnyq/${config2.name}`
1463
1734
  })),
1464
1735
  {
1465
1736
  name: "ntnyq/markdown/disabled/code-blocks",
@@ -1809,6 +2080,22 @@ var jsx = () => [
1809
2080
  }
1810
2081
  ];
1811
2082
 
2083
+ // src/configs/githubAction.ts
2084
+ var githubAction = (options = {}) => [
2085
+ {
2086
+ name: "ntnyq/github-action",
2087
+ files: [GLOB_GITHUB_ACTION],
2088
+ plugins: {
2089
+ "github-action": import_eslint_plugin_github_action.default
2090
+ },
2091
+ rules: {
2092
+ "github-action/require-action-name": "error",
2093
+ // Overrides rules
2094
+ ...options.overrides
2095
+ }
2096
+ }
2097
+ ];
2098
+
1812
2099
  // src/configs/perfectionist.ts
1813
2100
  var perfectionist = (options = {}) => [
1814
2101
  {
@@ -1859,7 +2146,7 @@ var perfectionist = (options = {}) => [
1859
2146
  order: options.imports?.order || "asc",
1860
2147
  type: options.imports?.type || "natural",
1861
2148
  ignoreCase: true,
1862
- internalPattern: ["~/**", "@/**", "#**"],
2149
+ internalPattern: ["^~/.+", "^@/.+", "^#.+"],
1863
2150
  newlinesBetween: "ignore"
1864
2151
  }
1865
2152
  ],
@@ -1924,60 +2211,17 @@ var unusedImports = (options = {}) => [
1924
2211
  }
1925
2212
  ];
1926
2213
 
1927
- // src/utils/env.ts
1928
- var import_node_path = require("path");
1929
- var import_node_process2 = __toESM(require("process"), 1);
1930
- var import_local_pkg = require("local-pkg");
1931
- var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
1932
- var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
1933
- var hasVue = (0, import_local_pkg.isPackageExists)("vue") || (0, import_local_pkg.isPackageExists)("nuxt") || (0, import_local_pkg.isPackageExists)("vitepress") || (0, import_local_pkg.isPackageExists)("@slidev/cli") || (0, import_local_pkg.isPackageExists)("vue", {
1934
- paths: [(0, import_node_path.resolve)(import_node_process2.default.cwd(), "playground")]
1935
- });
1936
- var hasUnoCSS = (0, import_local_pkg.isPackageExists)("unocss") || (0, import_local_pkg.isPackageExists)("@unocss/postcss") || (0, import_local_pkg.isPackageExists)("@unocss/webpack") || (0, import_local_pkg.isPackageExists)("@unocss/nuxt");
1937
-
1938
- // src/utils/toArray.ts
1939
- function toArray(val) {
1940
- val = val ?? [];
1941
- return Array.isArray(val) ? val : [val];
1942
- }
1943
-
1944
- // src/utils/interopDefault.ts
1945
- async function interopDefault(mod) {
1946
- const resolved = await mod;
1947
- return resolved.default || resolved;
1948
- }
1949
-
1950
- // src/utils/loadPlugin.ts
1951
- async function loadPlugin(name) {
1952
- const mod = await import(name).catch((err) => {
1953
- console.error(err);
1954
- throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
1955
- });
1956
- return interopDefault(mod);
1957
- }
1958
-
1959
- // src/utils/resolveSubOptions.ts
1960
- function resolveSubOptions(options, key) {
1961
- return typeof options[key] === "boolean" ? {} : options[key] || {};
1962
- }
1963
-
1964
- // src/utils/getOverrides.ts
1965
- function getOverrides(options, key) {
1966
- const sub = resolveSubOptions(options, key);
1967
- return "overrides" in sub && sub.overrides ? sub.overrides : {};
1968
- }
1969
-
1970
2214
  // src/core.ts
1971
2215
  function defineESLintConfig(options = {}, userConfigs = []) {
1972
- const configs = [];
2216
+ const configs2 = [];
1973
2217
  if (options.gitignore ?? true) {
1974
- configs.push(
2218
+ configs2.push(
1975
2219
  ...gitignore({
1976
2220
  ...resolveSubOptions(options, "gitignore")
1977
2221
  })
1978
2222
  );
1979
2223
  }
1980
- configs.push(
2224
+ configs2.push(
1981
2225
  ...ignores(options.ignores),
1982
2226
  ...jsx(),
1983
2227
  ...node({
@@ -1992,7 +2236,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1992
2236
  })
1993
2237
  );
1994
2238
  if (options.perfectionist ?? true) {
1995
- configs.push(
2239
+ configs2.push(
1996
2240
  ...perfectionist({
1997
2241
  ...resolveSubOptions(options, "perfectionist"),
1998
2242
  overrides: getOverrides(options, "perfectionist")
@@ -2000,14 +2244,14 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2000
2244
  );
2001
2245
  }
2002
2246
  if (options.unicorn ?? true) {
2003
- configs.push(
2247
+ configs2.push(
2004
2248
  ...unicorn({
2005
2249
  overrides: getOverrides(options, "unicorn")
2006
2250
  })
2007
2251
  );
2008
2252
  }
2009
2253
  if (options.regexp ?? true) {
2010
- configs.push(
2254
+ configs2.push(
2011
2255
  ...regexp({
2012
2256
  ...resolveSubOptions(options, "regexp"),
2013
2257
  overrides: getOverrides(options, "regexp")
@@ -2015,21 +2259,21 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2015
2259
  );
2016
2260
  }
2017
2261
  if (options.jsdoc ?? true) {
2018
- configs.push(
2262
+ configs2.push(
2019
2263
  ...jsdoc({
2020
2264
  overrides: getOverrides(options, "jsdoc")
2021
2265
  })
2022
2266
  );
2023
2267
  }
2024
2268
  if (options.comments ?? true) {
2025
- configs.push(
2269
+ configs2.push(
2026
2270
  ...comments({
2027
2271
  overrides: getOverrides(options, "comments")
2028
2272
  })
2029
2273
  );
2030
2274
  }
2031
2275
  if (options.typescript ?? hasTypeScript) {
2032
- configs.push(
2276
+ configs2.push(
2033
2277
  ...typescript({
2034
2278
  ...resolveSubOptions(options, "typescript"),
2035
2279
  overrides: getOverrides(options, "typescript")
@@ -2037,35 +2281,35 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2037
2281
  );
2038
2282
  }
2039
2283
  if (options.yml ?? true) {
2040
- configs.push(
2284
+ configs2.push(
2041
2285
  ...yml({
2042
2286
  overrides: getOverrides(options, "yml")
2043
2287
  })
2044
2288
  );
2045
2289
  }
2046
2290
  if (options.toml ?? true) {
2047
- configs.push(
2291
+ configs2.push(
2048
2292
  ...toml({
2049
2293
  overrides: getOverrides(options, "toml")
2050
2294
  })
2051
2295
  );
2052
2296
  }
2053
2297
  if (options.jsonc ?? true) {
2054
- configs.push(
2298
+ configs2.push(
2055
2299
  ...jsonc({
2056
2300
  overrides: getOverrides(options, "jsonc")
2057
2301
  })
2058
2302
  );
2059
2303
  }
2060
2304
  if (options.sort ?? true) {
2061
- configs.push(
2305
+ configs2.push(
2062
2306
  ...sort({
2063
2307
  ...resolveSubOptions(options, "sort")
2064
2308
  })
2065
2309
  );
2066
2310
  }
2067
2311
  if (options.vue ?? hasVue) {
2068
- configs.push(
2312
+ configs2.push(
2069
2313
  ...vue({
2070
2314
  ...resolveSubOptions(options, "vue"),
2071
2315
  overrides: getOverrides(options, "vue")
@@ -2073,7 +2317,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2073
2317
  );
2074
2318
  }
2075
2319
  if (options.test ?? hasVitest) {
2076
- configs.push(
2320
+ configs2.push(
2077
2321
  ...test({
2078
2322
  overrides: getOverrides(options, "test")
2079
2323
  }),
@@ -2083,26 +2327,40 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2083
2327
  );
2084
2328
  }
2085
2329
  if (options.unocss ?? hasUnoCSS) {
2086
- configs.push(
2330
+ configs2.push(
2087
2331
  ...unocss({
2088
2332
  overrides: getOverrides(options, "unocss")
2089
2333
  })
2090
2334
  );
2091
2335
  }
2092
2336
  if (options.markdown ?? true) {
2093
- configs.push(
2337
+ configs2.push(
2094
2338
  ...markdown({
2095
2339
  overrides: getOverrides(options, "markdown")
2096
2340
  })
2097
2341
  );
2098
2342
  }
2099
2343
  if (options.command ?? true) {
2100
- configs.push(
2344
+ configs2.push(
2101
2345
  ...command({
2102
2346
  ...resolveSubOptions(options, "command")
2103
2347
  })
2104
2348
  );
2105
2349
  }
2350
+ if (options.antfu ?? true) {
2351
+ configs2.push(
2352
+ ...antfu({
2353
+ overrides: getOverrides(options, "antfu")
2354
+ })
2355
+ );
2356
+ }
2357
+ if (options.githubAction ?? true) {
2358
+ configs2.push(
2359
+ ...githubAction({
2360
+ overrides: getOverrides(options, "githubAction")
2361
+ })
2362
+ );
2363
+ }
2106
2364
  const configSpecials = specials();
2107
2365
  const configPrettier = options.prettier ?? true ? prettier({
2108
2366
  ...resolveSubOptions(options, "prettier"),
@@ -2110,7 +2368,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2110
2368
  }) : [];
2111
2369
  const composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2112
2370
  composer.append(
2113
- ...configs,
2371
+ ...configs2,
2114
2372
  ...toArray(userConfigs),
2115
2373
  ...configSpecials,
2116
2374
  ...configPrettier
@@ -2119,12 +2377,14 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2119
2377
  }
2120
2378
  // Annotate the CommonJS export names for ESM import in node:
2121
2379
  0 && (module.exports = {
2380
+ DEFAULT_PRETTIER_OPTIONS,
2122
2381
  GLOB_ALL_SRC,
2123
2382
  GLOB_ASTRO,
2124
2383
  GLOB_CSS,
2125
2384
  GLOB_DIST,
2126
2385
  GLOB_DTS,
2127
2386
  GLOB_EXCLUDE,
2387
+ GLOB_GITHUB_ACTION,
2128
2388
  GLOB_HTML,
2129
2389
  GLOB_JS,
2130
2390
  GLOB_JSON,
@@ -2137,6 +2397,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2137
2397
  GLOB_MARKDOWN_CODE,
2138
2398
  GLOB_MARKDOWN_NESTED,
2139
2399
  GLOB_NODE_MODULES,
2400
+ GLOB_POSTCSS,
2140
2401
  GLOB_SCSS,
2141
2402
  GLOB_SRC,
2142
2403
  GLOB_SRC_EXT,
@@ -2151,8 +2412,11 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2151
2412
  antfu,
2152
2413
  command,
2153
2414
  comments,
2415
+ createTypeScriptConfig,
2154
2416
  defineESLintConfig,
2417
+ format,
2155
2418
  getOverrides,
2419
+ githubAction,
2156
2420
  gitignore,
2157
2421
  hasTypeScript,
2158
2422
  hasUnoCSS,
@@ -2167,15 +2431,21 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2167
2431
  jsx,
2168
2432
  loadPlugin,
2169
2433
  markdown,
2434
+ mergePrettierOptions,
2435
+ mergeProcessors,
2170
2436
  node,
2171
2437
  ntnyq,
2172
2438
  parserJsonc,
2439
+ parserPlain,
2173
2440
  parserToml,
2441
+ parserTypeScript,
2174
2442
  parserVue,
2175
2443
  parserYaml,
2176
2444
  perfectionist,
2177
2445
  pluginAntfu,
2178
2446
  pluginComments,
2447
+ pluginFormat,
2448
+ pluginGitHubAction,
2179
2449
  pluginImport,
2180
2450
  pluginJsdoc,
2181
2451
  pluginJsonc,
@@ -2186,6 +2456,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2186
2456
  pluginPrettier,
2187
2457
  pluginRegexp,
2188
2458
  pluginToml,
2459
+ pluginTypeScript,
2189
2460
  pluginUnicorn,
2190
2461
  pluginUnoCSS,
2191
2462
  pluginUnusedImports,
@@ -2193,6 +2464,8 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2193
2464
  pluginVue,
2194
2465
  pluginYaml,
2195
2466
  prettier,
2467
+ processorPassThrough,
2468
+ processorVueBlocks,
2196
2469
  regexp,
2197
2470
  resolveSubOptions,
2198
2471
  sort,
@@ -2200,8 +2473,8 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2200
2473
  test,
2201
2474
  toArray,
2202
2475
  toml,
2203
- tseslint,
2204
2476
  typescript,
2477
+ typescriptConfigs,
2205
2478
  typescriptCore,
2206
2479
  unicorn,
2207
2480
  unocss,