@ntnyq/eslint-config 3.3.1 → 3.5.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
@@ -33,6 +33,7 @@ __export(src_exports, {
33
33
  DEFAULT_PRETTIER_OPTIONS: () => DEFAULT_PRETTIER_OPTIONS,
34
34
  GLOB_ALL_SRC: () => GLOB_ALL_SRC,
35
35
  GLOB_ASTRO: () => GLOB_ASTRO,
36
+ GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
36
37
  GLOB_CSS: () => GLOB_CSS,
37
38
  GLOB_DIST: () => GLOB_DIST,
38
39
  GLOB_DTS: () => GLOB_DTS,
@@ -65,7 +66,6 @@ __export(src_exports, {
65
66
  antfu: () => antfu,
66
67
  command: () => command,
67
68
  comments: () => comments,
68
- createTypeScriptConfig: () => import_typescript_eslint.config,
69
69
  defineESLintConfig: () => defineESLintConfig,
70
70
  format: () => format,
71
71
  getOverrides: () => getOverrides,
@@ -110,7 +110,7 @@ __export(src_exports, {
110
110
  pluginRegexp: () => pluginRegexp,
111
111
  pluginStylistic: () => import_eslint_plugin3.default,
112
112
  pluginToml: () => import_eslint_plugin_toml.default,
113
- pluginTypeScript: () => import_typescript_eslint3.plugin,
113
+ pluginTypeScript: () => import_typescript_eslint2.plugin,
114
114
  pluginUnicorn: () => import_eslint_plugin_unicorn.default,
115
115
  pluginUnoCSS: () => import_eslint_plugin.default,
116
116
  pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
@@ -129,8 +129,7 @@ __export(src_exports, {
129
129
  toArray: () => toArray,
130
130
  toml: () => toml,
131
131
  typescript: () => typescript,
132
- typescriptConfigs: () => import_typescript_eslint4.configs,
133
- typescriptCore: () => typescriptCore,
132
+ typescriptConfigs: () => import_typescript_eslint3.configs,
134
133
  unicorn: () => unicorn,
135
134
  unocss: () => unocss,
136
135
  unusedImports: () => unusedImports,
@@ -146,16 +145,13 @@ var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
146
145
  // src/configs/vue.ts
147
146
  var import_eslint_merge_processors3 = require("eslint-merge-processors");
148
147
 
149
- // src/eslint/utils.ts
150
- var import_typescript_eslint = require("typescript-eslint");
151
-
152
148
  // src/eslint/parsers.ts
153
- var import_typescript_eslint2 = __toESM(require("typescript-eslint"), 1);
149
+ var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
154
150
  var parserVue = __toESM(require("vue-eslint-parser"), 1);
155
151
  var parserToml = __toESM(require("toml-eslint-parser"), 1);
156
152
  var parserYaml = __toESM(require("yaml-eslint-parser"), 1);
157
153
  var parserJsonc = __toESM(require("jsonc-eslint-parser"), 1);
158
- var parserTypeScript = import_typescript_eslint2.default.parser;
154
+ var parserTypeScript = import_typescript_eslint.default.parser;
159
155
  var parserPlain = {
160
156
  meta: {
161
157
  name: "plain-eslint-parser"
@@ -188,7 +184,7 @@ var import_markdown = __toESM(require("@eslint/markdown"), 1);
188
184
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
189
185
  var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
190
186
  var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
191
- var import_typescript_eslint3 = require("typescript-eslint");
187
+ var import_typescript_eslint2 = require("typescript-eslint");
192
188
  var import_eslint_plugin_format = __toESM(require("eslint-plugin-format"), 1);
193
189
  var import_eslint_plugin = __toESM(require("@unocss/eslint-plugin"), 1);
194
190
  var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
@@ -202,7 +198,7 @@ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-
202
198
  var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
203
199
 
204
200
  // src/eslint/configs.ts
205
- var import_typescript_eslint4 = require("typescript-eslint");
201
+ var import_typescript_eslint3 = require("typescript-eslint");
206
202
 
207
203
  // src/eslint/processors.ts
208
204
  var import_eslint_merge_processors = require("eslint-merge-processors");
@@ -236,6 +232,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
236
232
  var GLOB_TOML = "**/*.toml";
237
233
  var GLOB_HTML = "**/*.htm?(l)";
238
234
  var GLOB_ASTRO = "**/*.astro";
235
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
239
236
  var GLOB_SVELTE = "**/*.svelte";
240
237
  var GLOB_MARKDOWN = "**/*.md";
241
238
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
@@ -306,126 +303,6 @@ var GLOB_EXCLUDE = [
306
303
  "**/.yarnrc"
307
304
  ];
308
305
 
309
- // src/configs/typescript.ts
310
- var import_node_process = __toESM(require("process"), 1);
311
- var typescriptCore = (options = {}) => {
312
- const isTypeAware = !!options.tsconfigPath;
313
- const configs2 = (0, import_typescript_eslint.config)({
314
- name: "ntnyq/ts/core",
315
- extends: [...import_typescript_eslint4.configs.recommended],
316
- files: [GLOB_TS, GLOB_TSX],
317
- languageOptions: {
318
- parser: parserTypeScript,
319
- parserOptions: {
320
- sourceType: "module",
321
- ...isTypeAware ? {
322
- projectService: {
323
- defaultProject: options.tsconfigPath
324
- },
325
- tsconfigRootDir: import_node_process.default.cwd()
326
- } : {}
327
- }
328
- },
329
- rules: {
330
- // Disabled in favor of ts rules
331
- "no-redeclare": "off",
332
- "no-use-before-define": "off",
333
- "no-unused-vars": "off",
334
- "@typescript-eslint/no-redeclare": [
335
- "error",
336
- {
337
- builtinGlobals: false,
338
- ignoreDeclarationMerge: true
339
- }
340
- ],
341
- "@typescript-eslint/no-use-before-define": [
342
- "error",
343
- {
344
- functions: false,
345
- classes: false,
346
- variables: true,
347
- allowNamedExports: false,
348
- enums: true,
349
- typedefs: false,
350
- ignoreTypeReferences: false
351
- }
352
- ],
353
- "@typescript-eslint/no-unused-vars": [
354
- "error",
355
- {
356
- // Args after the last used will be reported
357
- args: "after-used",
358
- argsIgnorePattern: "^_",
359
- caughtErrors: "all",
360
- caughtErrorsIgnorePattern: "^_",
361
- destructuredArrayIgnorePattern: "^_",
362
- varsIgnorePattern: "^_",
363
- ignoreRestSiblings: true
364
- }
365
- ],
366
- "@typescript-eslint/no-unused-expressions": [
367
- "error",
368
- {
369
- allowShortCircuit: true,
370
- allowTernary: true,
371
- allowTaggedTemplates: true
372
- }
373
- ],
374
- "@typescript-eslint/consistent-type-imports": [
375
- "error",
376
- {
377
- prefer: "type-imports",
378
- fixStyle: "separate-type-imports",
379
- disallowTypeAnnotations: false
380
- }
381
- ],
382
- "@typescript-eslint/no-empty-object-type": [
383
- "error",
384
- {
385
- allowInterfaces: "always",
386
- allowObjectTypes: "always"
387
- }
388
- ],
389
- "@typescript-eslint/consistent-type-assertions": [
390
- "error",
391
- {
392
- assertionStyle: "as",
393
- objectLiteralTypeAssertions: "allow-as-parameter"
394
- }
395
- ],
396
- "@typescript-eslint/prefer-as-const": "warn",
397
- "@typescript-eslint/no-namespace": "off",
398
- "@typescript-eslint/ban-ts-comment": "off",
399
- "@typescript-eslint/no-explicit-any": "off",
400
- "@typescript-eslint/no-empty-function": "off",
401
- "@typescript-eslint/naming-convention": "off",
402
- "@typescript-eslint/no-non-null-assertion": "off",
403
- "@typescript-eslint/triple-slash-reference": "off",
404
- "@typescript-eslint/explicit-member-accessibility": "off",
405
- "@typescript-eslint/explicit-function-return-type": "off",
406
- "@typescript-eslint/explicit-module-boundary-types": "off",
407
- "@typescript-eslint/consistent-indexed-object-style": "off",
408
- // Overrides rules
409
- ...options.overrides
410
- }
411
- });
412
- return configs2;
413
- };
414
- var typescript = (options = {}) => [
415
- ...typescriptCore(options),
416
- {
417
- name: "ntnyq/ts/types",
418
- files: [GLOB_DTS, "**/types/**/*.ts"],
419
- rules: {
420
- "no-use-before-define": "off",
421
- "no-restricted-syntax": "off",
422
- "import/no-duplicates": "off",
423
- "import/newline-after-import": "off",
424
- "@typescript-eslint/no-use-before-define": "off"
425
- }
426
- }
427
- ];
428
-
429
306
  // src/configs/vue.ts
430
307
  var vue2Rules = {
431
308
  ...import_eslint_plugin_vue.default.configs.base.rules,
@@ -623,23 +500,18 @@ var vue = (options = {}) => {
623
500
  const isVue3 = options.vueVersion !== 2;
624
501
  const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
625
502
  return [
626
- ...(0, import_typescript_eslint.config)({
627
- name: "ntnyq/vue/ts",
628
- files: [GLOB_VUE],
629
- extends: typescriptCore()
630
- }),
631
503
  {
632
504
  name: "ntnyq/vue/setup",
633
505
  plugins: {
634
506
  vue: import_eslint_plugin_vue.default,
635
- "@typescript-eslint": import_typescript_eslint3.plugin
507
+ "@typescript-eslint": import_typescript_eslint2.plugin
636
508
  },
637
509
  languageOptions: {
638
510
  parserOptions: {
639
511
  sourceType: "module",
640
512
  ecmaVersion: "latest",
641
513
  extraFileExtensions: [".vue"],
642
- parser: "@typescript-eslint/parser",
514
+ parser: parserTypeScript,
643
515
  ecmaFeatures: {
644
516
  jsx: true
645
517
  }
@@ -1007,6 +879,16 @@ var sort = (options = {}) => {
1007
879
  "activationEvents",
1008
880
  "contributes",
1009
881
  "categories",
882
+ "galleryBanner",
883
+ "badges",
884
+ "markdown",
885
+ "qna",
886
+ "sponsor",
887
+ "extensionPack",
888
+ "extensionDependencies",
889
+ "extensionKind",
890
+ "pricing",
891
+ "capabilities",
1010
892
  /**
1011
893
  * Package manager
1012
894
  */
@@ -1036,6 +918,20 @@ var sort = (options = {}) => {
1036
918
  pathPattern: "^exports.*$",
1037
919
  order: ["types", "import", "require", "default"]
1038
920
  },
921
+ // VSCode extension
922
+ {
923
+ order: { type: "asc" },
924
+ pathPattern: "^contributes.*$"
925
+ },
926
+ /**
927
+ * pnpm publish config
928
+ * @see {@link https://pnpm.io/package_json#publishconfig}
929
+ */
930
+ {
931
+ order: { type: "asc" },
932
+ pathPattern: "^publishConfig.*$"
933
+ },
934
+ // npm scripts
1039
935
  {
1040
936
  pathPattern: "^scripts$",
1041
937
  order: { type: "asc" }
@@ -1062,6 +958,18 @@ var sort = (options = {}) => {
1062
958
  {
1063
959
  pathPattern: "^files$",
1064
960
  order: { type: "asc" }
961
+ },
962
+ {
963
+ pathPattern: "^keywords$",
964
+ order: { type: "asc" }
965
+ },
966
+ {
967
+ pathPattern: "^activationEvents$",
968
+ order: { type: "asc" }
969
+ },
970
+ {
971
+ pathPattern: "^contributes.*$",
972
+ order: { type: "asc" }
1065
973
  }
1066
974
  ]
1067
975
  }
@@ -1293,9 +1201,9 @@ var ntnyq = (options = {}) => [
1293
1201
 
1294
1202
  // src/configs/regexp.ts
1295
1203
  var regexp = (options = {}) => {
1296
- const config2 = pluginRegexp.configs["flat/recommended"];
1204
+ const config = pluginRegexp.configs["flat/recommended"];
1297
1205
  const rules = {
1298
- ...config2.rules
1206
+ ...config.rules
1299
1207
  };
1300
1208
  if (options.level === "warn") {
1301
1209
  for (const key in rules) {
@@ -1306,7 +1214,7 @@ var regexp = (options = {}) => {
1306
1214
  }
1307
1215
  return [
1308
1216
  {
1309
- ...config2,
1217
+ ...config,
1310
1218
  name: "ntnyq/regexp",
1311
1219
  rules: {
1312
1220
  ...rules,
@@ -1326,8 +1234,7 @@ var unocss = (options = {}) => [
1326
1234
  },
1327
1235
  rules: {
1328
1236
  "unocss/order": "error",
1329
- // We don't use this
1330
- "unocss/order-attributify": "off",
1237
+ "unocss/order-attributify": options.attributify ? "error" : "off",
1331
1238
  // Overrides rules
1332
1239
  ...options.overrides
1333
1240
  }
@@ -1385,12 +1292,12 @@ var DEFAULT_PRETTIER_OPTIONS = {
1385
1292
 
1386
1293
  // src/utils/env.ts
1387
1294
  var import_node_path = require("path");
1388
- var import_node_process2 = __toESM(require("process"), 1);
1295
+ var import_node_process = __toESM(require("process"), 1);
1389
1296
  var import_local_pkg = require("local-pkg");
1390
1297
  var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
1391
1298
  var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
1392
1299
  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")]
1300
+ paths: [(0, import_node_path.resolve)(import_node_process.default.cwd(), "playground")]
1394
1301
  });
1395
1302
  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
1303
 
@@ -1731,9 +1638,9 @@ var comments = (options = {}) => [
1731
1638
  var markdown = (options = {}) => {
1732
1639
  if (!Array.isArray(import_markdown.default.configs?.processor)) return [];
1733
1640
  return [
1734
- ...import_markdown.default.configs.processor.map((config2) => ({
1735
- ...config2,
1736
- name: `ntnyq/${config2.name}`
1641
+ ...import_markdown.default.configs.processor.map((config) => ({
1642
+ ...config,
1643
+ name: `ntnyq/${config.name}`
1737
1644
  })),
1738
1645
  {
1739
1646
  name: "ntnyq/markdown/disabled/code-blocks",
@@ -1869,235 +1776,426 @@ var gitignore = (options = {}) => {
1869
1776
  // src/configs/javascript.ts
1870
1777
  var import_js = __toESM(require("@eslint/js"), 1);
1871
1778
  var import_globals2 = __toESM(require("globals"), 1);
1872
- var javascript = (options = {}) => {
1873
- const strictRules = {
1874
- complexity: ["error", { max: 30 }],
1875
- "max-params": ["error", { max: 5 }],
1876
- "max-depth": ["error", { max: 5 }],
1877
- "max-nested-callbacks": ["error", { max: 10 }],
1878
- "max-lines": [
1879
- "error",
1880
- {
1881
- max: 1e3,
1882
- skipComments: true,
1883
- skipBlankLines: true
1779
+ var strictRules = {
1780
+ complexity: ["error", { max: 30 }],
1781
+ "max-params": ["error", { max: 5 }],
1782
+ "max-depth": ["error", { max: 5 }],
1783
+ "max-nested-callbacks": ["error", { max: 10 }],
1784
+ "max-lines": [
1785
+ "error",
1786
+ {
1787
+ max: 1e3,
1788
+ skipComments: true,
1789
+ skipBlankLines: true
1790
+ }
1791
+ ],
1792
+ "max-lines-per-function": [
1793
+ "error",
1794
+ {
1795
+ max: 200,
1796
+ skipComments: true,
1797
+ skipBlankLines: true
1798
+ }
1799
+ ]
1800
+ };
1801
+ var javascript = (options = {}) => [
1802
+ {
1803
+ ...import_js.default.configs.recommended,
1804
+ name: "ntnyq/js/recommended"
1805
+ },
1806
+ {
1807
+ name: "ntnyq/js/core",
1808
+ languageOptions: {
1809
+ globals: {
1810
+ ...import_globals2.default.browser,
1811
+ ...import_globals2.default.es2021,
1812
+ ...import_globals2.default.node
1813
+ },
1814
+ sourceType: "module"
1815
+ },
1816
+ rules: {
1817
+ "require-await": "off",
1818
+ "no-return-assign": "off",
1819
+ "no-useless-escape": "off",
1820
+ "consistent-return": "off",
1821
+ // disabled in favor of `perfectionist/sort-named-imports`
1822
+ "sort-imports": "off",
1823
+ // standard v17.0.0
1824
+ "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
1825
+ camelcase: [
1826
+ "error",
1827
+ {
1828
+ allow: ["^UNSAFE_"],
1829
+ properties: "never",
1830
+ ignoreGlobals: true
1831
+ }
1832
+ ],
1833
+ "constructor-super": "error",
1834
+ curly: ["error", "multi-line"],
1835
+ "default-case-last": "error",
1836
+ "dot-notation": ["error", { allowKeywords: true }],
1837
+ "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
1838
+ "no-array-constructor": "error",
1839
+ "no-async-promise-executor": "error",
1840
+ "no-caller": "error",
1841
+ "no-class-assign": "error",
1842
+ "no-compare-neg-zero": "error",
1843
+ "no-cond-assign": "error",
1844
+ "no-const-assign": "error",
1845
+ "no-constant-condition": ["error", { checkLoops: false }],
1846
+ "no-control-regex": "error",
1847
+ "no-debugger": "error",
1848
+ "no-delete-var": "error",
1849
+ "no-dupe-args": "error",
1850
+ "no-dupe-class-members": "error",
1851
+ "no-dupe-keys": "error",
1852
+ "no-duplicate-case": "error",
1853
+ "no-useless-backreference": "error",
1854
+ "no-empty": ["error", { allowEmptyCatch: true }],
1855
+ "no-empty-character-class": "error",
1856
+ "no-empty-pattern": "error",
1857
+ "no-eval": "error",
1858
+ "no-ex-assign": "error",
1859
+ "no-extend-native": "error",
1860
+ "no-extra-bind": "error",
1861
+ "no-extra-boolean-cast": "error",
1862
+ "no-fallthrough": "error",
1863
+ "no-func-assign": "error",
1864
+ "no-global-assign": "error",
1865
+ "no-implied-eval": "error",
1866
+ "no-import-assign": "error",
1867
+ "no-invalid-regexp": "error",
1868
+ "no-irregular-whitespace": "error",
1869
+ "no-iterator": "error",
1870
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
1871
+ "no-lone-blocks": "error",
1872
+ "no-loss-of-precision": "error",
1873
+ "no-misleading-character-class": "error",
1874
+ "no-prototype-builtins": "error",
1875
+ "no-useless-catch": "error",
1876
+ "no-new": "error",
1877
+ "no-new-func": "error",
1878
+ "no-new-wrappers": "error",
1879
+ "no-obj-calls": "error",
1880
+ "no-octal": "error",
1881
+ "no-octal-escape": "error",
1882
+ "no-proto": "error",
1883
+ "no-redeclare": ["error", { builtinGlobals: false }],
1884
+ "no-regex-spaces": "error",
1885
+ "no-self-assign": ["error", { props: true }],
1886
+ "no-self-compare": "error",
1887
+ "no-sequences": "error",
1888
+ "no-shadow-restricted-names": "error",
1889
+ "no-sparse-arrays": "error",
1890
+ "no-template-curly-in-string": "error",
1891
+ "no-this-before-super": "error",
1892
+ "no-throw-literal": "error",
1893
+ "no-undef": "error",
1894
+ "no-undef-init": "error",
1895
+ "no-unexpected-multiline": "error",
1896
+ "no-unmodified-loop-condition": "error",
1897
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
1898
+ "no-unreachable": "error",
1899
+ "no-unreachable-loop": "error",
1900
+ "no-unsafe-finally": "error",
1901
+ "no-unsafe-negation": "error",
1902
+ "no-unused-expressions": [
1903
+ "error",
1904
+ {
1905
+ allowShortCircuit: true,
1906
+ allowTernary: true,
1907
+ allowTaggedTemplates: true
1908
+ }
1909
+ ],
1910
+ "no-unused-vars": [
1911
+ "error",
1912
+ {
1913
+ args: "none",
1914
+ caughtErrors: "none",
1915
+ ignoreRestSiblings: true,
1916
+ vars: "all"
1917
+ }
1918
+ ],
1919
+ "no-useless-call": "error",
1920
+ "no-useless-computed-key": "error",
1921
+ "no-useless-constructor": "error",
1922
+ "no-useless-rename": "error",
1923
+ "no-useless-return": "error",
1924
+ "prefer-promise-reject-errors": "error",
1925
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
1926
+ "symbol-description": "error",
1927
+ "unicode-bom": ["error", "never"],
1928
+ "use-isnan": [
1929
+ "error",
1930
+ {
1931
+ enforceForSwitchCase: true,
1932
+ enforceForIndexOf: true
1933
+ }
1934
+ ],
1935
+ "valid-typeof": ["error", { requireStringLiterals: true }],
1936
+ yoda: ["error", "never"],
1937
+ // es6+
1938
+ "no-var": "error",
1939
+ "prefer-rest-params": "error",
1940
+ "prefer-spread": "error",
1941
+ "prefer-template": "error",
1942
+ "no-empty-static-block": "error",
1943
+ "no-new-native-nonconstructor": "error",
1944
+ "prefer-const": [
1945
+ "error",
1946
+ {
1947
+ destructuring: "all",
1948
+ ignoreReadBeforeAssign: true
1949
+ }
1950
+ ],
1951
+ "prefer-arrow-callback": [
1952
+ "error",
1953
+ {
1954
+ allowNamedFunctions: false,
1955
+ allowUnboundThis: true
1956
+ }
1957
+ ],
1958
+ "object-shorthand": [
1959
+ "error",
1960
+ "always",
1961
+ {
1962
+ ignoreConstructors: false,
1963
+ avoidQuotes: true
1964
+ }
1965
+ ],
1966
+ // best-practice
1967
+ eqeqeq: ["error", "smart"],
1968
+ "array-callback-return": "error",
1969
+ "block-scoped-var": "error",
1970
+ "no-alert": "error",
1971
+ "no-case-declarations": "error",
1972
+ "no-multi-str": "error",
1973
+ "no-with": "error",
1974
+ "no-void": "error",
1975
+ "vars-on-top": "error",
1976
+ "one-var": ["error", "never"],
1977
+ "no-use-before-define": [
1978
+ "error",
1979
+ {
1980
+ functions: false,
1981
+ classes: false,
1982
+ variables: true,
1983
+ allowNamedExports: false
1984
+ }
1985
+ ],
1986
+ // Strict rules
1987
+ ...options.strict ? strictRules : {},
1988
+ // Overrides rules
1989
+ ...options.overrides
1990
+ }
1991
+ }
1992
+ ];
1993
+ var jsx = () => [
1994
+ {
1995
+ name: "ntnyq/jsx",
1996
+ files: ["**/*.jsx"],
1997
+ languageOptions: {
1998
+ parserOptions: {
1999
+ ecmaFeatures: {
2000
+ jsx: true
2001
+ }
1884
2002
  }
1885
- ],
1886
- "max-lines-per-function": [
1887
- "error",
1888
- {
1889
- max: 200,
1890
- skipComments: true,
1891
- skipBlankLines: true
2003
+ }
2004
+ }
2005
+ ];
2006
+
2007
+ // src/configs/typescript.ts
2008
+ var import_node_process2 = __toESM(require("process"), 1);
2009
+ var typeAwareRules = {
2010
+ "dot-notation": "off",
2011
+ "require-await": "off",
2012
+ "no-implied-eval": "off",
2013
+ "no-throw-literal": "off",
2014
+ // too strict
2015
+ "@typescript-eslint/strict-boolean-expressions": "off",
2016
+ "@typescript-eslint/require-await": "error",
2017
+ "@typescript-eslint/unbound-method": "error",
2018
+ "@typescript-eslint/no-unsafe-call": "error",
2019
+ "@typescript-eslint/await-thenable": "error",
2020
+ "@typescript-eslint/no-for-in-array": "error",
2021
+ "@typescript-eslint/no-implied-eval": "error",
2022
+ "@typescript-eslint/only-throw-error": "error",
2023
+ "@typescript-eslint/no-unsafe-return": "error",
2024
+ "@typescript-eslint/no-unsafe-argument": "error",
2025
+ "@typescript-eslint/no-misused-promises": "error",
2026
+ "@typescript-eslint/no-unsafe-assignment": "error",
2027
+ "@typescript-eslint/no-floating-promises": "error",
2028
+ "@typescript-eslint/promise-function-async": "error",
2029
+ "@typescript-eslint/restrict-plus-operands": "error",
2030
+ "@typescript-eslint/triple-slash-reference": "error",
2031
+ "@typescript-eslint/no-unsafe-member-access": "error",
2032
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
2033
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
2034
+ "@typescript-eslint/restrict-template-expressions": "error",
2035
+ "@typescript-eslint/no-redundant-type-constituents": "error",
2036
+ "@typescript-eslint/no-duplicate-type-constituents": "error",
2037
+ "@typescript-eslint/return-await": ["error", "in-try-catch"],
2038
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }]
2039
+ };
2040
+ var recommendedRules = import_typescript_eslint3.configs.recommended.reduce((rules, config) => {
2041
+ return { ...rules, ...config.rules || {} };
2042
+ }, {});
2043
+ var typescript = (options = {}) => {
2044
+ const enableTypeAwareLint = !!options?.tsconfigPath;
2045
+ const {
2046
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
2047
+ ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`],
2048
+ overridesTypeAwareRules = {},
2049
+ parserOptions = {}
2050
+ } = options;
2051
+ function createParserConfig(enableTypeAware = false, files = [], ignores2 = []) {
2052
+ const typescriptParserOptions = {
2053
+ // extraFileExtensions: [''],
2054
+ sourceType: "module",
2055
+ ...enableTypeAware ? {
2056
+ projectService: {
2057
+ allowDefaultProject: ["./*.js"],
2058
+ defaultProject: options.tsconfigPath
2059
+ },
2060
+ tsconfigRootDir: import_node_process2.default.cwd()
2061
+ } : {},
2062
+ ...parserOptions
2063
+ };
2064
+ const parserConfig = {
2065
+ name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
2066
+ files,
2067
+ ignores: [...ignores2],
2068
+ languageOptions: {
2069
+ parser: parserTypeScript,
2070
+ parserOptions: typescriptParserOptions
1892
2071
  }
1893
- ]
1894
- };
2072
+ };
2073
+ return parserConfig;
2074
+ }
1895
2075
  return [
1896
2076
  {
1897
- ...import_js.default.configs.recommended,
1898
- name: "ntnyq/js/recommended"
2077
+ name: "ntnyq/ts/setup",
2078
+ plugins: {
2079
+ "@typescript-eslint": import_typescript_eslint2.plugin,
2080
+ antfu: import_eslint_plugin_antfu.default
2081
+ }
1899
2082
  },
2083
+ ...enableTypeAwareLint ? [
2084
+ createParserConfig(false, [GLOB_TS, GLOB_TSX]),
2085
+ createParserConfig(true, filesTypeAware, ignoresTypeAware)
2086
+ ] : [createParserConfig(false, [GLOB_TS, GLOB_TSX])],
1900
2087
  {
1901
- name: "ntnyq/js/core",
1902
- languageOptions: {
1903
- globals: {
1904
- ...import_globals2.default.browser,
1905
- ...import_globals2.default.es2021,
1906
- ...import_globals2.default.node
1907
- },
1908
- sourceType: "module"
1909
- },
2088
+ name: "ntnyq/ts/rules",
2089
+ files: [GLOB_TS, GLOB_TSX],
1910
2090
  rules: {
1911
- "require-await": "off",
1912
- "no-return-assign": "off",
1913
- "no-useless-escape": "off",
1914
- "consistent-return": "off",
1915
- // disabled in favor of `perfectionist/sort-named-imports`
1916
- "sort-imports": "off",
1917
- // standard v17.0.0
1918
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
1919
- camelcase: [
1920
- "error",
1921
- {
1922
- allow: ["^UNSAFE_"],
1923
- properties: "never",
1924
- ignoreGlobals: true
1925
- }
1926
- ],
1927
- "constructor-super": "error",
1928
- curly: ["error", "multi-line"],
1929
- "default-case-last": "error",
1930
- "dot-notation": ["error", { allowKeywords: true }],
1931
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
1932
- "no-array-constructor": "error",
1933
- "no-async-promise-executor": "error",
1934
- "no-caller": "error",
1935
- "no-class-assign": "error",
1936
- "no-compare-neg-zero": "error",
1937
- "no-cond-assign": "error",
1938
- "no-const-assign": "error",
1939
- "no-constant-condition": ["error", { checkLoops: false }],
1940
- "no-control-regex": "error",
1941
- "no-debugger": "error",
1942
- "no-delete-var": "error",
1943
- "no-dupe-args": "error",
1944
- "no-dupe-class-members": "error",
1945
- "no-dupe-keys": "error",
1946
- "no-duplicate-case": "error",
1947
- "no-useless-backreference": "error",
1948
- "no-empty": ["error", { allowEmptyCatch: true }],
1949
- "no-empty-character-class": "error",
1950
- "no-empty-pattern": "error",
1951
- "no-eval": "error",
1952
- "no-ex-assign": "error",
1953
- "no-extend-native": "error",
1954
- "no-extra-bind": "error",
1955
- "no-extra-boolean-cast": "error",
1956
- "no-fallthrough": "error",
1957
- "no-func-assign": "error",
1958
- "no-global-assign": "error",
1959
- "no-implied-eval": "error",
1960
- "no-import-assign": "error",
1961
- "no-invalid-regexp": "error",
1962
- "no-irregular-whitespace": "error",
1963
- "no-iterator": "error",
1964
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
1965
- "no-lone-blocks": "error",
1966
- "no-loss-of-precision": "error",
1967
- "no-misleading-character-class": "error",
1968
- "no-prototype-builtins": "error",
1969
- "no-useless-catch": "error",
1970
- "no-new": "error",
1971
- "no-new-func": "error",
1972
- "no-new-wrappers": "error",
1973
- "no-obj-calls": "error",
1974
- "no-octal": "error",
1975
- "no-octal-escape": "error",
1976
- "no-proto": "error",
1977
- "no-redeclare": ["error", { builtinGlobals: false }],
1978
- "no-regex-spaces": "error",
1979
- "no-self-assign": ["error", { props: true }],
1980
- "no-self-compare": "error",
1981
- "no-sequences": "error",
1982
- "no-shadow-restricted-names": "error",
1983
- "no-sparse-arrays": "error",
1984
- "no-template-curly-in-string": "error",
1985
- "no-this-before-super": "error",
1986
- "no-throw-literal": "error",
1987
- "no-undef": "error",
1988
- "no-undef-init": "error",
1989
- "no-unexpected-multiline": "error",
1990
- "no-unmodified-loop-condition": "error",
1991
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
1992
- "no-unreachable": "error",
1993
- "no-unreachable-loop": "error",
1994
- "no-unsafe-finally": "error",
1995
- "no-unsafe-negation": "error",
1996
- "no-unused-expressions": [
2091
+ ...recommendedRules,
2092
+ // Disabled in favor of ts rules
2093
+ "no-redeclare": "off",
2094
+ "no-use-before-define": "off",
2095
+ "no-unused-vars": "off",
2096
+ "@typescript-eslint/no-redeclare": [
1997
2097
  "error",
1998
2098
  {
1999
- allowShortCircuit: true,
2000
- allowTernary: true,
2001
- allowTaggedTemplates: true
2099
+ builtinGlobals: false,
2100
+ ignoreDeclarationMerge: true
2002
2101
  }
2003
2102
  ],
2004
- "no-unused-vars": [
2103
+ "@typescript-eslint/no-use-before-define": [
2005
2104
  "error",
2006
2105
  {
2007
- args: "none",
2008
- caughtErrors: "none",
2009
- ignoreRestSiblings: true,
2010
- vars: "all"
2106
+ functions: false,
2107
+ classes: false,
2108
+ variables: true,
2109
+ allowNamedExports: false,
2110
+ enums: true,
2111
+ typedefs: false,
2112
+ ignoreTypeReferences: false
2011
2113
  }
2012
2114
  ],
2013
- "no-useless-call": "error",
2014
- "no-useless-computed-key": "error",
2015
- "no-useless-constructor": "error",
2016
- "no-useless-rename": "error",
2017
- "no-useless-return": "error",
2018
- "prefer-promise-reject-errors": "error",
2019
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
2020
- "symbol-description": "error",
2021
- "unicode-bom": ["error", "never"],
2022
- "use-isnan": [
2115
+ "@typescript-eslint/no-unused-vars": [
2023
2116
  "error",
2024
2117
  {
2025
- enforceForSwitchCase: true,
2026
- enforceForIndexOf: true
2118
+ // Args after the last used will be reported
2119
+ args: "after-used",
2120
+ argsIgnorePattern: "^_",
2121
+ caughtErrors: "all",
2122
+ caughtErrorsIgnorePattern: "^_",
2123
+ destructuredArrayIgnorePattern: "^_",
2124
+ varsIgnorePattern: "^_",
2125
+ ignoreRestSiblings: true
2027
2126
  }
2028
2127
  ],
2029
- "valid-typeof": ["error", { requireStringLiterals: true }],
2030
- yoda: ["error", "never"],
2031
- // es6+
2032
- "no-var": "error",
2033
- "prefer-rest-params": "error",
2034
- "prefer-spread": "error",
2035
- "prefer-template": "error",
2036
- "no-empty-static-block": "error",
2037
- "no-new-native-nonconstructor": "error",
2038
- "prefer-const": [
2128
+ "@typescript-eslint/no-unused-expressions": [
2039
2129
  "error",
2040
2130
  {
2041
- destructuring: "all",
2042
- ignoreReadBeforeAssign: true
2131
+ allowShortCircuit: true,
2132
+ allowTernary: true,
2133
+ allowTaggedTemplates: true
2043
2134
  }
2044
2135
  ],
2045
- "prefer-arrow-callback": [
2136
+ "@typescript-eslint/consistent-type-imports": [
2046
2137
  "error",
2047
2138
  {
2048
- allowNamedFunctions: false,
2049
- allowUnboundThis: true
2139
+ prefer: "type-imports",
2140
+ fixStyle: "separate-type-imports",
2141
+ disallowTypeAnnotations: false
2050
2142
  }
2051
2143
  ],
2052
- "object-shorthand": [
2144
+ "@typescript-eslint/no-empty-object-type": [
2053
2145
  "error",
2054
- "always",
2055
2146
  {
2056
- ignoreConstructors: false,
2057
- avoidQuotes: true
2147
+ allowInterfaces: "always",
2148
+ allowObjectTypes: "always"
2058
2149
  }
2059
2150
  ],
2060
- // best-practice
2061
- eqeqeq: ["error", "smart"],
2062
- "array-callback-return": "error",
2063
- "block-scoped-var": "error",
2064
- "no-alert": "error",
2065
- "no-case-declarations": "error",
2066
- "no-multi-str": "error",
2067
- "no-with": "error",
2068
- "no-void": "error",
2069
- "vars-on-top": "error",
2070
- "one-var": ["error", "never"],
2071
- "no-use-before-define": [
2151
+ "@typescript-eslint/consistent-type-assertions": [
2072
2152
  "error",
2073
2153
  {
2074
- functions: false,
2075
- classes: false,
2076
- variables: true,
2077
- allowNamedExports: false
2154
+ assertionStyle: "as",
2155
+ objectLiteralTypeAssertions: "allow-as-parameter"
2078
2156
  }
2079
2157
  ],
2080
- // Strict rules
2081
- ...options.strict ? strictRules : {},
2158
+ "@typescript-eslint/prefer-as-const": "warn",
2159
+ "@typescript-eslint/no-namespace": "off",
2160
+ "@typescript-eslint/ban-ts-comment": "off",
2161
+ "@typescript-eslint/no-explicit-any": "off",
2162
+ "@typescript-eslint/no-empty-function": "off",
2163
+ "@typescript-eslint/naming-convention": "off",
2164
+ "@typescript-eslint/no-non-null-assertion": "off",
2165
+ "@typescript-eslint/triple-slash-reference": "off",
2166
+ "@typescript-eslint/explicit-member-accessibility": "off",
2167
+ "@typescript-eslint/explicit-function-return-type": "off",
2168
+ "@typescript-eslint/explicit-module-boundary-types": "off",
2169
+ "@typescript-eslint/consistent-indexed-object-style": "off",
2082
2170
  // Overrides rules
2083
2171
  ...options.overrides
2084
2172
  }
2085
- }
2086
- ];
2087
- };
2088
- var jsx = () => [
2089
- {
2090
- name: "ntnyq/jsx",
2091
- files: ["**/*.jsx"],
2092
- languageOptions: {
2093
- parserOptions: {
2094
- ecmaFeatures: {
2095
- jsx: true
2173
+ },
2174
+ ...enableTypeAwareLint ? [
2175
+ {
2176
+ name: "ntnyq/ts/rules/type-aware",
2177
+ files: [...filesTypeAware],
2178
+ ignores: [...ignoresTypeAware],
2179
+ rules: {
2180
+ ...typeAwareRules,
2181
+ // Overrides type aware rules
2182
+ ...overridesTypeAwareRules
2096
2183
  }
2097
2184
  }
2185
+ ] : [],
2186
+ {
2187
+ name: "ntnyq/ts/types",
2188
+ files: [GLOB_DTS, "**/types/**/*.ts"],
2189
+ rules: {
2190
+ "no-use-before-define": "off",
2191
+ "no-restricted-syntax": "off",
2192
+ "import/no-duplicates": "off",
2193
+ "import/newline-after-import": "off",
2194
+ "@typescript-eslint/no-use-before-define": "off"
2195
+ }
2098
2196
  }
2099
- }
2100
- ];
2197
+ ];
2198
+ };
2101
2199
 
2102
2200
  // src/configs/githubAction.ts
2103
2201
  var githubAction = (options = {}) => [
@@ -2231,7 +2329,7 @@ var unusedImports = (options = {}) => [
2231
2329
  ];
2232
2330
 
2233
2331
  // src/core.ts
2234
- function defineESLintConfig(options = {}, userConfigs = []) {
2332
+ async function defineESLintConfig(options = {}, ...userConfigs) {
2235
2333
  const configs2 = [];
2236
2334
  if (options.gitignore ?? true) {
2237
2335
  configs2.push(
@@ -2246,9 +2344,18 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2246
2344
  ...node({
2247
2345
  overrides: getOverrides(options, "node")
2248
2346
  }),
2347
+ ...command({
2348
+ ...resolveSubOptions(options, "command")
2349
+ }),
2249
2350
  ...imports({
2250
2351
  overrides: getOverrides(options, "imports")
2251
2352
  }),
2353
+ ...jsdoc({
2354
+ overrides: getOverrides(options, "jsdoc")
2355
+ }),
2356
+ ...comments({
2357
+ overrides: getOverrides(options, "comments")
2358
+ }),
2252
2359
  ...javascript({
2253
2360
  ...resolveSubOptions(options, "javascript"),
2254
2361
  overrides: getOverrides(options, "javascript")
@@ -2277,20 +2384,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2277
2384
  })
2278
2385
  );
2279
2386
  }
2280
- if (options.jsdoc ?? true) {
2281
- configs2.push(
2282
- ...jsdoc({
2283
- overrides: getOverrides(options, "jsdoc")
2284
- })
2285
- );
2286
- }
2287
- if (options.comments ?? true) {
2288
- configs2.push(
2289
- ...comments({
2290
- overrides: getOverrides(options, "comments")
2291
- })
2292
- );
2293
- }
2294
2387
  if (options.typescript ?? hasTypeScript) {
2295
2388
  configs2.push(
2296
2389
  ...typescript({
@@ -2359,13 +2452,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2359
2452
  })
2360
2453
  );
2361
2454
  }
2362
- if (options.command ?? true) {
2363
- configs2.push(
2364
- ...command({
2365
- ...resolveSubOptions(options, "command")
2366
- })
2367
- );
2368
- }
2369
2455
  if (options.antfu ?? true) {
2370
2456
  configs2.push(
2371
2457
  ...antfu({
@@ -2393,9 +2479,9 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2393
2479
  overrides: getOverrides(options, "prettier")
2394
2480
  }) : [];
2395
2481
  const composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2396
- composer.append(
2482
+ await composer.append(
2397
2483
  ...configs2,
2398
- ...toArray(userConfigs),
2484
+ ...userConfigs,
2399
2485
  ...configSpecials,
2400
2486
  ...configPrettier
2401
2487
  );
@@ -2406,6 +2492,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2406
2492
  DEFAULT_PRETTIER_OPTIONS,
2407
2493
  GLOB_ALL_SRC,
2408
2494
  GLOB_ASTRO,
2495
+ GLOB_ASTRO_TS,
2409
2496
  GLOB_CSS,
2410
2497
  GLOB_DIST,
2411
2498
  GLOB_DTS,
@@ -2438,7 +2525,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2438
2525
  antfu,
2439
2526
  command,
2440
2527
  comments,
2441
- createTypeScriptConfig,
2442
2528
  defineESLintConfig,
2443
2529
  format,
2444
2530
  getOverrides,
@@ -2503,7 +2589,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2503
2589
  toml,
2504
2590
  typescript,
2505
2591
  typescriptConfigs,
2506
- typescriptCore,
2507
2592
  unicorn,
2508
2593
  unocss,
2509
2594
  unusedImports,