@ntnyq/eslint-config 3.2.2 → 3.3.1

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,
@@ -96,7 +108,9 @@ __export(src_exports, {
96
108
  pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
97
109
  pluginPrettier: () => import_eslint_plugin_prettier.default,
98
110
  pluginRegexp: () => pluginRegexp,
111
+ pluginStylistic: () => import_eslint_plugin3.default,
99
112
  pluginToml: () => import_eslint_plugin_toml.default,
113
+ pluginTypeScript: () => import_typescript_eslint3.plugin,
100
114
  pluginUnicorn: () => import_eslint_plugin_unicorn.default,
101
115
  pluginUnoCSS: () => import_eslint_plugin.default,
102
116
  pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
@@ -104,15 +118,18 @@ __export(src_exports, {
104
118
  pluginVue: () => import_eslint_plugin_vue.default,
105
119
  pluginYaml: () => import_eslint_plugin_yml.default,
106
120
  prettier: () => prettier,
121
+ processorPassThrough: () => import_eslint_merge_processors2.processorPassThrough,
122
+ processorVueBlocks: () => import_eslint_processor_vue_blocks.default,
107
123
  regexp: () => regexp,
108
124
  resolveSubOptions: () => resolveSubOptions,
109
125
  sort: () => sort,
110
126
  specials: () => specials,
127
+ stylistic: () => stylistic,
111
128
  test: () => test,
112
129
  toArray: () => toArray,
113
130
  toml: () => toml,
114
- tseslint: () => import_typescript_eslint.default,
115
131
  typescript: () => typescript,
132
+ typescriptConfigs: () => import_typescript_eslint4.configs,
116
133
  typescriptCore: () => typescriptCore,
117
134
  unicorn: () => unicorn,
118
135
  unocss: () => unocss,
@@ -126,6 +143,72 @@ module.exports = __toCommonJS(src_exports);
126
143
  // src/core.ts
127
144
  var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
128
145
 
146
+ // src/configs/vue.ts
147
+ var import_eslint_merge_processors3 = require("eslint-merge-processors");
148
+
149
+ // src/eslint/utils.ts
150
+ var import_typescript_eslint = require("typescript-eslint");
151
+
152
+ // src/eslint/parsers.ts
153
+ var import_typescript_eslint2 = __toESM(require("typescript-eslint"), 1);
154
+ var parserVue = __toESM(require("vue-eslint-parser"), 1);
155
+ var parserToml = __toESM(require("toml-eslint-parser"), 1);
156
+ var parserYaml = __toESM(require("yaml-eslint-parser"), 1);
157
+ var parserJsonc = __toESM(require("jsonc-eslint-parser"), 1);
158
+ var parserTypeScript = import_typescript_eslint2.default.parser;
159
+ var parserPlain = {
160
+ meta: {
161
+ name: "plain-eslint-parser"
162
+ },
163
+ parseForESLint: (code) => ({
164
+ ast: {
165
+ body: [],
166
+ comments: [],
167
+ loc: { start: 0, end: code.length },
168
+ range: [0, code.length],
169
+ tokens: [],
170
+ type: "Program"
171
+ },
172
+ scopeManager: null,
173
+ services: { isPlain: true },
174
+ visitorKeys: {
175
+ Program: []
176
+ }
177
+ })
178
+ };
179
+
180
+ // src/eslint/plugins.ts
181
+ var pluginRegexp = __toESM(require("eslint-plugin-regexp"), 1);
182
+ var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
183
+ var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
184
+ var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
185
+ var import_eslint_plugin_toml = __toESM(require("eslint-plugin-toml"), 1);
186
+ var import_eslint_plugin_ntnyq = __toESM(require("eslint-plugin-ntnyq"), 1);
187
+ var import_markdown = __toESM(require("@eslint/markdown"), 1);
188
+ var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
189
+ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
190
+ var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
191
+ var import_typescript_eslint3 = require("typescript-eslint");
192
+ var import_eslint_plugin_format = __toESM(require("eslint-plugin-format"), 1);
193
+ var import_eslint_plugin = __toESM(require("@unocss/eslint-plugin"), 1);
194
+ var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
195
+ var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
196
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
197
+ var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
198
+ var import_eslint_plugin3 = __toESM(require("@stylistic/eslint-plugin"), 1);
199
+ var import_eslint_plugin_github_action = __toESM(require("eslint-plugin-github-action"), 1);
200
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
201
+ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
202
+ var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
203
+
204
+ // src/eslint/configs.ts
205
+ var import_typescript_eslint4 = require("typescript-eslint");
206
+
207
+ // src/eslint/processors.ts
208
+ var import_eslint_merge_processors = require("eslint-merge-processors");
209
+ var import_eslint_merge_processors2 = require("eslint-merge-processors");
210
+ var import_eslint_processor_vue_blocks = __toESM(require("eslint-processor-vue-blocks"), 1);
211
+
129
212
  // src/globs.ts
130
213
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
131
214
  var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
@@ -144,6 +227,7 @@ var GLOB_STYLE = "**/*.{c,le,sc}ss";
144
227
  var GLOB_CSS = "**/*.css";
145
228
  var GLOB_LESS = "**/*.less";
146
229
  var GLOB_SCSS = "**/*.scss";
230
+ var GLOB_POSTCSS = "**/*.{p,post}css";
147
231
  var GLOB_JSON = "**/*.json";
148
232
  var GLOB_JSON5 = "**/*.json5";
149
233
  var GLOB_JSONC = "**/*.jsonc";
@@ -167,6 +251,7 @@ var GLOB_ALL_SRC = [
167
251
  GLOB_HTML,
168
252
  GLOB_MARKDOWN
169
253
  ];
254
+ var GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
170
255
  var GLOB_NODE_MODULES = "**/node_modules/**";
171
256
  var GLOB_DIST = "**/dist/**";
172
257
  var GLOB_LOCKFILE = [
@@ -221,41 +306,16 @@ var GLOB_EXCLUDE = [
221
306
  "**/.yarnrc"
222
307
  ];
223
308
 
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
309
  // src/configs/typescript.ts
250
310
  var import_node_process = __toESM(require("process"), 1);
251
311
  var typescriptCore = (options = {}) => {
252
312
  const isTypeAware = !!options.tsconfigPath;
253
- const configs = import_typescript_eslint.default.config({
313
+ const configs2 = (0, import_typescript_eslint.config)({
254
314
  name: "ntnyq/ts/core",
255
- extends: [...import_typescript_eslint.default.configs.recommended],
315
+ extends: [...import_typescript_eslint4.configs.recommended],
256
316
  files: [GLOB_TS, GLOB_TSX],
257
317
  languageOptions: {
258
- parser: import_typescript_eslint.default.parser,
318
+ parser: parserTypeScript,
259
319
  parserOptions: {
260
320
  sourceType: "module",
261
321
  ...isTypeAware ? {
@@ -349,7 +409,7 @@ var typescriptCore = (options = {}) => {
349
409
  ...options.overrides
350
410
  }
351
411
  });
352
- return configs;
412
+ return configs2;
353
413
  };
354
414
  var typescript = (options = {}) => [
355
415
  ...typescriptCore(options),
@@ -561,31 +621,47 @@ var unCategorizedRules = {
561
621
  };
562
622
  var vue = (options = {}) => {
563
623
  const isVue3 = options.vueVersion !== 2;
624
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
564
625
  return [
565
- ...import_typescript_eslint.default.config({
626
+ ...(0, import_typescript_eslint.config)({
566
627
  name: "ntnyq/vue/ts",
567
628
  files: [GLOB_VUE],
568
629
  extends: typescriptCore()
569
630
  }),
570
631
  {
571
- name: "ntnyq/vue/core",
572
- files: [GLOB_VUE],
632
+ name: "ntnyq/vue/setup",
573
633
  plugins: {
574
634
  vue: import_eslint_plugin_vue.default,
575
- "@typescript-eslint": import_typescript_eslint.default.plugin
635
+ "@typescript-eslint": import_typescript_eslint3.plugin
576
636
  },
577
637
  languageOptions: {
578
- parser: parserVue,
579
638
  parserOptions: {
580
- parser: "@typescript-eslint/parser",
581
639
  sourceType: "module",
640
+ ecmaVersion: "latest",
582
641
  extraFileExtensions: [".vue"],
642
+ parser: "@typescript-eslint/parser",
583
643
  ecmaFeatures: {
584
644
  jsx: true
585
645
  }
586
646
  }
647
+ }
648
+ },
649
+ {
650
+ name: "ntnyq/vue/rules",
651
+ files: [GLOB_VUE],
652
+ languageOptions: {
653
+ parser: parserVue
587
654
  },
588
- processor: import_eslint_plugin_vue.default.processors[".vue"],
655
+ processor: sfcBlocks === false ? import_eslint_plugin_vue.default.processors[".vue"] : (0, import_eslint_merge_processors3.mergeProcessors)([
656
+ import_eslint_plugin_vue.default.processors[".vue"],
657
+ (0, import_eslint_processor_vue_blocks.default)({
658
+ ...sfcBlocks,
659
+ blocks: {
660
+ styles: true,
661
+ ...sfcBlocks.blocks
662
+ }
663
+ })
664
+ ]),
589
665
  rules: {
590
666
  ...isVue3 ? vue3Rules : vue2Rules,
591
667
  "vue/html-self-closing": [
@@ -742,9 +818,9 @@ var node = (options = {}) => [
742
818
 
743
819
  // src/configs/sort.ts
744
820
  var sort = (options = {}) => {
745
- const configs = [];
821
+ const configs2 = [];
746
822
  if (options.tsconfig ?? true) {
747
- configs.push({
823
+ configs2.push({
748
824
  name: "ntnyq/sort/tsconfig",
749
825
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
750
826
  rules: {
@@ -860,7 +936,7 @@ var sort = (options = {}) => {
860
936
  });
861
937
  }
862
938
  if (options.packageJson ?? true) {
863
- configs.push({
939
+ configs2.push({
864
940
  name: "ntnyq/sort/package-json",
865
941
  files: ["**/package.json"],
866
942
  rules: {
@@ -992,7 +1068,7 @@ var sort = (options = {}) => {
992
1068
  });
993
1069
  }
994
1070
  if (options.i18nLocale ?? true) {
995
- configs.push(
1071
+ configs2.push(
996
1072
  {
997
1073
  name: "ntnyq/sort/i18n-locale/json",
998
1074
  files: ["**/{locales,i18n}/*.json"],
@@ -1022,7 +1098,7 @@ var sort = (options = {}) => {
1022
1098
  );
1023
1099
  }
1024
1100
  if (options.pnpmWorkspace ?? true) {
1025
- configs.push({
1101
+ configs2.push({
1026
1102
  name: "ntnyq/sort/pnpm-workspace",
1027
1103
  files: ["**/pnpm-workspace.yaml"],
1028
1104
  rules: {
@@ -1036,7 +1112,7 @@ var sort = (options = {}) => {
1036
1112
  }
1037
1113
  });
1038
1114
  }
1039
- return configs;
1115
+ return configs2;
1040
1116
  };
1041
1117
 
1042
1118
  // src/configs/toml.ts
@@ -1115,7 +1191,9 @@ var antfu = (options = {}) => [
1115
1191
  // required `object-curly-newline` to be disabled
1116
1192
  // 'antfu/consistent-list-newline': 'error',
1117
1193
  "antfu/import-dedupe": "error",
1118
- "antfu/top-level-function": "error",
1194
+ "antfu/no-import-dist": "error",
1195
+ "antfu/indent-unindent": "error",
1196
+ "antfu/no-import-node-modules-by-path": "error",
1119
1197
  // Overrides rules
1120
1198
  ...options.overrides
1121
1199
  }
@@ -1215,9 +1293,9 @@ var ntnyq = (options = {}) => [
1215
1293
 
1216
1294
  // src/configs/regexp.ts
1217
1295
  var regexp = (options = {}) => {
1218
- const config = pluginRegexp.configs["flat/recommended"];
1296
+ const config2 = pluginRegexp.configs["flat/recommended"];
1219
1297
  const rules = {
1220
- ...config.rules
1298
+ ...config2.rules
1221
1299
  };
1222
1300
  if (options.level === "warn") {
1223
1301
  for (const key in rules) {
@@ -1228,7 +1306,7 @@ var regexp = (options = {}) => {
1228
1306
  }
1229
1307
  return [
1230
1308
  {
1231
- ...config,
1309
+ ...config2,
1232
1310
  name: "ntnyq/regexp",
1233
1311
  rules: {
1234
1312
  ...rules,
@@ -1256,6 +1334,202 @@ var unocss = (options = {}) => [
1256
1334
  }
1257
1335
  ];
1258
1336
 
1337
+ // src/constants.ts
1338
+ var DEFAULT_PRETTIER_OPTIONS = {
1339
+ // Maximum line length
1340
+ printWidth: 100,
1341
+ // Specify the number of spaces per indentation-level
1342
+ tabWidth: 2,
1343
+ // Indent lines with tabs instead of spaces
1344
+ useTabs: false,
1345
+ // Use semicolons or not
1346
+ semi: false,
1347
+ // Use single quotes instead of double quotes
1348
+ singleQuote: true,
1349
+ // Change when properties in objects are quoted
1350
+ quoteProps: "as-needed",
1351
+ // Use single quotes instead of double quotes in JSX
1352
+ jsxSingleQuote: true,
1353
+ // Print trailing commas wherever possible when multi-line
1354
+ trailingComma: "all",
1355
+ // Print spaces between brackets in object literals.
1356
+ bracketSpacing: true,
1357
+ // 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)
1358
+ bracketSameLine: false,
1359
+ // Include parentheses around a sole arrow function parameter
1360
+ arrowParens: "avoid",
1361
+ // Format only a segment of a file.
1362
+ rangeStart: 0,
1363
+ rangeEnd: Number.POSITIVE_INFINITY,
1364
+ // Specify which parser to use.
1365
+ // parser: undefined,
1366
+ // Specify the file name to use to infer which parser to use.
1367
+ // filepath: undefined,
1368
+ // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1369
+ requirePragma: false,
1370
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1371
+ insertPragma: false,
1372
+ // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1373
+ proseWrap: "preserve",
1374
+ // Specify the global whitespace sensitivity for HTML files
1375
+ htmlWhitespaceSensitivity: "css",
1376
+ // Whether or not to indent the code inside <script> and <style> tags in Vue files
1377
+ vueIndentScriptAndStyle: false,
1378
+ // End of line
1379
+ endOfLine: "lf",
1380
+ // Control whether Prettier formats quoted code embedded in the file
1381
+ embeddedLanguageFormatting: "auto",
1382
+ // Enforce single attribute per line in HTML, Vue and JSX
1383
+ singleAttributePerLine: true
1384
+ };
1385
+
1386
+ // src/utils/env.ts
1387
+ var import_node_path = require("path");
1388
+ var import_node_process2 = __toESM(require("process"), 1);
1389
+ var import_local_pkg = require("local-pkg");
1390
+ var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
1391
+ var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
1392
+ 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", {
1393
+ paths: [(0, import_node_path.resolve)(import_node_process2.default.cwd(), "playground")]
1394
+ });
1395
+ 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");
1396
+
1397
+ // src/utils/toArray.ts
1398
+ function toArray(val) {
1399
+ val = val ?? [];
1400
+ return Array.isArray(val) ? val : [val];
1401
+ }
1402
+
1403
+ // src/utils/interopDefault.ts
1404
+ async function interopDefault(mod) {
1405
+ const resolved = await mod;
1406
+ return resolved.default || resolved;
1407
+ }
1408
+
1409
+ // src/utils/loadPlugin.ts
1410
+ async function loadPlugin(name) {
1411
+ const mod = await import(name).catch((err) => {
1412
+ console.error(err);
1413
+ throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
1414
+ });
1415
+ return interopDefault(mod);
1416
+ }
1417
+
1418
+ // src/utils/resolveSubOptions.ts
1419
+ function resolveSubOptions(options, key) {
1420
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1421
+ }
1422
+
1423
+ // src/utils/getOverrides.ts
1424
+ function getOverrides(options, key) {
1425
+ const sub = resolveSubOptions(options, key);
1426
+ return "overrides" in sub && sub.overrides ? sub.overrides : {};
1427
+ }
1428
+
1429
+ // src/utils/mergePrettierOptions.ts
1430
+ function mergePrettierOptions(options = {}, overrides = {}) {
1431
+ const result = {
1432
+ ...options,
1433
+ ...overrides,
1434
+ plugins: [
1435
+ // built-in plugins
1436
+ ...options.plugins || [],
1437
+ // custom plugins
1438
+ ...overrides.plugins || []
1439
+ ]
1440
+ };
1441
+ return result;
1442
+ }
1443
+
1444
+ // src/configs/format.ts
1445
+ var format = (options = {}) => {
1446
+ const {
1447
+ css: enableCSS = true,
1448
+ html: enableHTML = true,
1449
+ // user custom options
1450
+ prettierOptions = {}
1451
+ } = options;
1452
+ const sharedPrettierOptions = {
1453
+ ...DEFAULT_PRETTIER_OPTIONS,
1454
+ ...prettierOptions
1455
+ };
1456
+ const configs2 = [
1457
+ {
1458
+ name: "ntnyq/format/setup",
1459
+ plugins: {
1460
+ format: import_eslint_plugin_format.default
1461
+ }
1462
+ }
1463
+ ];
1464
+ if (enableCSS) {
1465
+ configs2.push(
1466
+ {
1467
+ name: "ntnyq/format/css",
1468
+ files: [GLOB_CSS, GLOB_POSTCSS],
1469
+ languageOptions: {
1470
+ parser: parserPlain
1471
+ },
1472
+ rules: {
1473
+ "format/prettier": [
1474
+ "error",
1475
+ mergePrettierOptions(sharedPrettierOptions, {
1476
+ parser: "css"
1477
+ })
1478
+ ]
1479
+ }
1480
+ },
1481
+ {
1482
+ name: "ntnyq/format/scss",
1483
+ files: [GLOB_SCSS],
1484
+ languageOptions: {
1485
+ parser: parserPlain
1486
+ },
1487
+ rules: {
1488
+ "format/prettier": [
1489
+ "error",
1490
+ mergePrettierOptions(sharedPrettierOptions, {
1491
+ parser: "scss"
1492
+ })
1493
+ ]
1494
+ }
1495
+ },
1496
+ {
1497
+ name: "ntnyq/format/less",
1498
+ files: [GLOB_LESS],
1499
+ languageOptions: {
1500
+ parser: parserPlain
1501
+ },
1502
+ rules: {
1503
+ "format/prettier": [
1504
+ "error",
1505
+ mergePrettierOptions(sharedPrettierOptions, {
1506
+ parser: "less"
1507
+ })
1508
+ ]
1509
+ }
1510
+ }
1511
+ );
1512
+ }
1513
+ if (enableHTML) {
1514
+ configs2.push({
1515
+ name: "ntnyq/format/html",
1516
+ files: [GLOB_HTML],
1517
+ languageOptions: {
1518
+ parser: parserPlain
1519
+ },
1520
+ rules: {
1521
+ "format/prettier": [
1522
+ "error",
1523
+ mergePrettierOptions(sharedPrettierOptions, {
1524
+ parser: "html"
1525
+ })
1526
+ ]
1527
+ }
1528
+ });
1529
+ }
1530
+ return configs2;
1531
+ };
1532
+
1259
1533
  // src/configs/command.ts
1260
1534
  var import_config = __toESM(require("eslint-plugin-command/config"), 1);
1261
1535
  var command = (options = {}) => [
@@ -1457,9 +1731,9 @@ var comments = (options = {}) => [
1457
1731
  var markdown = (options = {}) => {
1458
1732
  if (!Array.isArray(import_markdown.default.configs?.processor)) return [];
1459
1733
  return [
1460
- ...import_markdown.default.configs.processor.map((config) => ({
1461
- ...config,
1462
- name: `ntnyq/${config.name}`
1734
+ ...import_markdown.default.configs.processor.map((config2) => ({
1735
+ ...config2,
1736
+ name: `ntnyq/${config2.name}`
1463
1737
  })),
1464
1738
  {
1465
1739
  name: "ntnyq/markdown/disabled/code-blocks",
@@ -1564,6 +1838,22 @@ var prettier = (options = {}) => {
1564
1838
  ];
1565
1839
  };
1566
1840
 
1841
+ // src/configs/stylistic.ts
1842
+ var stylistic = (options = {}) => [
1843
+ {
1844
+ name: "ntnyq/stylistic",
1845
+ plugins: {
1846
+ "@stylistic": import_eslint_plugin3.default
1847
+ },
1848
+ rules: {
1849
+ // Only rules are not conflicted with Prettier
1850
+ // Use stylistic config to provide type support
1851
+ // Overrides rules
1852
+ ...options.overrides
1853
+ }
1854
+ }
1855
+ ];
1856
+
1567
1857
  // src/configs/gitignore.ts
1568
1858
  var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
1569
1859
  var gitignore = (options = {}) => {
@@ -1809,6 +2099,22 @@ var jsx = () => [
1809
2099
  }
1810
2100
  ];
1811
2101
 
2102
+ // src/configs/githubAction.ts
2103
+ var githubAction = (options = {}) => [
2104
+ {
2105
+ name: "ntnyq/github-action",
2106
+ files: [GLOB_GITHUB_ACTION],
2107
+ plugins: {
2108
+ "github-action": import_eslint_plugin_github_action.default
2109
+ },
2110
+ rules: {
2111
+ "github-action/require-action-name": "error",
2112
+ // Overrides rules
2113
+ ...options.overrides
2114
+ }
2115
+ }
2116
+ ];
2117
+
1812
2118
  // src/configs/perfectionist.ts
1813
2119
  var perfectionist = (options = {}) => [
1814
2120
  {
@@ -1859,7 +2165,7 @@ var perfectionist = (options = {}) => [
1859
2165
  order: options.imports?.order || "asc",
1860
2166
  type: options.imports?.type || "natural",
1861
2167
  ignoreCase: true,
1862
- internalPattern: ["~/**", "@/**", "#**"],
2168
+ internalPattern: ["^~/.+", "^@/.+", "^#.+"],
1863
2169
  newlinesBetween: "ignore"
1864
2170
  }
1865
2171
  ],
@@ -1924,60 +2230,17 @@ var unusedImports = (options = {}) => [
1924
2230
  }
1925
2231
  ];
1926
2232
 
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
2233
  // src/core.ts
1971
2234
  function defineESLintConfig(options = {}, userConfigs = []) {
1972
- const configs = [];
2235
+ const configs2 = [];
1973
2236
  if (options.gitignore ?? true) {
1974
- configs.push(
2237
+ configs2.push(
1975
2238
  ...gitignore({
1976
2239
  ...resolveSubOptions(options, "gitignore")
1977
2240
  })
1978
2241
  );
1979
2242
  }
1980
- configs.push(
2243
+ configs2.push(
1981
2244
  ...ignores(options.ignores),
1982
2245
  ...jsx(),
1983
2246
  ...node({
@@ -1992,7 +2255,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
1992
2255
  })
1993
2256
  );
1994
2257
  if (options.perfectionist ?? true) {
1995
- configs.push(
2258
+ configs2.push(
1996
2259
  ...perfectionist({
1997
2260
  ...resolveSubOptions(options, "perfectionist"),
1998
2261
  overrides: getOverrides(options, "perfectionist")
@@ -2000,14 +2263,14 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2000
2263
  );
2001
2264
  }
2002
2265
  if (options.unicorn ?? true) {
2003
- configs.push(
2266
+ configs2.push(
2004
2267
  ...unicorn({
2005
2268
  overrides: getOverrides(options, "unicorn")
2006
2269
  })
2007
2270
  );
2008
2271
  }
2009
2272
  if (options.regexp ?? true) {
2010
- configs.push(
2273
+ configs2.push(
2011
2274
  ...regexp({
2012
2275
  ...resolveSubOptions(options, "regexp"),
2013
2276
  overrides: getOverrides(options, "regexp")
@@ -2015,21 +2278,21 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2015
2278
  );
2016
2279
  }
2017
2280
  if (options.jsdoc ?? true) {
2018
- configs.push(
2281
+ configs2.push(
2019
2282
  ...jsdoc({
2020
2283
  overrides: getOverrides(options, "jsdoc")
2021
2284
  })
2022
2285
  );
2023
2286
  }
2024
2287
  if (options.comments ?? true) {
2025
- configs.push(
2288
+ configs2.push(
2026
2289
  ...comments({
2027
2290
  overrides: getOverrides(options, "comments")
2028
2291
  })
2029
2292
  );
2030
2293
  }
2031
2294
  if (options.typescript ?? hasTypeScript) {
2032
- configs.push(
2295
+ configs2.push(
2033
2296
  ...typescript({
2034
2297
  ...resolveSubOptions(options, "typescript"),
2035
2298
  overrides: getOverrides(options, "typescript")
@@ -2037,35 +2300,35 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2037
2300
  );
2038
2301
  }
2039
2302
  if (options.yml ?? true) {
2040
- configs.push(
2303
+ configs2.push(
2041
2304
  ...yml({
2042
2305
  overrides: getOverrides(options, "yml")
2043
2306
  })
2044
2307
  );
2045
2308
  }
2046
2309
  if (options.toml ?? true) {
2047
- configs.push(
2310
+ configs2.push(
2048
2311
  ...toml({
2049
2312
  overrides: getOverrides(options, "toml")
2050
2313
  })
2051
2314
  );
2052
2315
  }
2053
2316
  if (options.jsonc ?? true) {
2054
- configs.push(
2317
+ configs2.push(
2055
2318
  ...jsonc({
2056
2319
  overrides: getOverrides(options, "jsonc")
2057
2320
  })
2058
2321
  );
2059
2322
  }
2060
2323
  if (options.sort ?? true) {
2061
- configs.push(
2324
+ configs2.push(
2062
2325
  ...sort({
2063
2326
  ...resolveSubOptions(options, "sort")
2064
2327
  })
2065
2328
  );
2066
2329
  }
2067
2330
  if (options.vue ?? hasVue) {
2068
- configs.push(
2331
+ configs2.push(
2069
2332
  ...vue({
2070
2333
  ...resolveSubOptions(options, "vue"),
2071
2334
  overrides: getOverrides(options, "vue")
@@ -2073,7 +2336,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2073
2336
  );
2074
2337
  }
2075
2338
  if (options.test ?? hasVitest) {
2076
- configs.push(
2339
+ configs2.push(
2077
2340
  ...test({
2078
2341
  overrides: getOverrides(options, "test")
2079
2342
  }),
@@ -2083,26 +2346,47 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2083
2346
  );
2084
2347
  }
2085
2348
  if (options.unocss ?? hasUnoCSS) {
2086
- configs.push(
2349
+ configs2.push(
2087
2350
  ...unocss({
2088
2351
  overrides: getOverrides(options, "unocss")
2089
2352
  })
2090
2353
  );
2091
2354
  }
2092
2355
  if (options.markdown ?? true) {
2093
- configs.push(
2356
+ configs2.push(
2094
2357
  ...markdown({
2095
2358
  overrides: getOverrides(options, "markdown")
2096
2359
  })
2097
2360
  );
2098
2361
  }
2099
2362
  if (options.command ?? true) {
2100
- configs.push(
2363
+ configs2.push(
2101
2364
  ...command({
2102
2365
  ...resolveSubOptions(options, "command")
2103
2366
  })
2104
2367
  );
2105
2368
  }
2369
+ if (options.antfu ?? true) {
2370
+ configs2.push(
2371
+ ...antfu({
2372
+ overrides: getOverrides(options, "antfu")
2373
+ })
2374
+ );
2375
+ }
2376
+ if (options.stylistic ?? true) {
2377
+ configs2.push(
2378
+ ...stylistic({
2379
+ overrides: getOverrides(options, "stylistic")
2380
+ })
2381
+ );
2382
+ }
2383
+ if (options.githubAction ?? true) {
2384
+ configs2.push(
2385
+ ...githubAction({
2386
+ overrides: getOverrides(options, "githubAction")
2387
+ })
2388
+ );
2389
+ }
2106
2390
  const configSpecials = specials();
2107
2391
  const configPrettier = options.prettier ?? true ? prettier({
2108
2392
  ...resolveSubOptions(options, "prettier"),
@@ -2110,7 +2394,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2110
2394
  }) : [];
2111
2395
  const composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2112
2396
  composer.append(
2113
- ...configs,
2397
+ ...configs2,
2114
2398
  ...toArray(userConfigs),
2115
2399
  ...configSpecials,
2116
2400
  ...configPrettier
@@ -2119,12 +2403,14 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2119
2403
  }
2120
2404
  // Annotate the CommonJS export names for ESM import in node:
2121
2405
  0 && (module.exports = {
2406
+ DEFAULT_PRETTIER_OPTIONS,
2122
2407
  GLOB_ALL_SRC,
2123
2408
  GLOB_ASTRO,
2124
2409
  GLOB_CSS,
2125
2410
  GLOB_DIST,
2126
2411
  GLOB_DTS,
2127
2412
  GLOB_EXCLUDE,
2413
+ GLOB_GITHUB_ACTION,
2128
2414
  GLOB_HTML,
2129
2415
  GLOB_JS,
2130
2416
  GLOB_JSON,
@@ -2137,6 +2423,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2137
2423
  GLOB_MARKDOWN_CODE,
2138
2424
  GLOB_MARKDOWN_NESTED,
2139
2425
  GLOB_NODE_MODULES,
2426
+ GLOB_POSTCSS,
2140
2427
  GLOB_SCSS,
2141
2428
  GLOB_SRC,
2142
2429
  GLOB_SRC_EXT,
@@ -2151,8 +2438,11 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2151
2438
  antfu,
2152
2439
  command,
2153
2440
  comments,
2441
+ createTypeScriptConfig,
2154
2442
  defineESLintConfig,
2443
+ format,
2155
2444
  getOverrides,
2445
+ githubAction,
2156
2446
  gitignore,
2157
2447
  hasTypeScript,
2158
2448
  hasUnoCSS,
@@ -2167,15 +2457,21 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2167
2457
  jsx,
2168
2458
  loadPlugin,
2169
2459
  markdown,
2460
+ mergePrettierOptions,
2461
+ mergeProcessors,
2170
2462
  node,
2171
2463
  ntnyq,
2172
2464
  parserJsonc,
2465
+ parserPlain,
2173
2466
  parserToml,
2467
+ parserTypeScript,
2174
2468
  parserVue,
2175
2469
  parserYaml,
2176
2470
  perfectionist,
2177
2471
  pluginAntfu,
2178
2472
  pluginComments,
2473
+ pluginFormat,
2474
+ pluginGitHubAction,
2179
2475
  pluginImport,
2180
2476
  pluginJsdoc,
2181
2477
  pluginJsonc,
@@ -2185,7 +2481,9 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2185
2481
  pluginPerfectionist,
2186
2482
  pluginPrettier,
2187
2483
  pluginRegexp,
2484
+ pluginStylistic,
2188
2485
  pluginToml,
2486
+ pluginTypeScript,
2189
2487
  pluginUnicorn,
2190
2488
  pluginUnoCSS,
2191
2489
  pluginUnusedImports,
@@ -2193,15 +2491,18 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2193
2491
  pluginVue,
2194
2492
  pluginYaml,
2195
2493
  prettier,
2494
+ processorPassThrough,
2495
+ processorVueBlocks,
2196
2496
  regexp,
2197
2497
  resolveSubOptions,
2198
2498
  sort,
2199
2499
  specials,
2500
+ stylistic,
2200
2501
  test,
2201
2502
  toArray,
2202
2503
  toml,
2203
- tseslint,
2204
2504
  typescript,
2505
+ typescriptConfigs,
2205
2506
  typescriptCore,
2206
2507
  unicorn,
2207
2508
  unocss,