@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.js CHANGED
@@ -4,9 +4,6 @@ import { FlatConfigComposer } from "eslint-flat-config-utils";
4
4
  // src/configs/vue.ts
5
5
  import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
6
6
 
7
- // src/eslint/utils.ts
8
- import { config } from "typescript-eslint";
9
-
10
7
  // src/eslint/parsers.ts
11
8
  import tseslint from "typescript-eslint";
12
9
  import * as parserVue from "vue-eslint-parser";
@@ -94,6 +91,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
94
91
  var GLOB_TOML = "**/*.toml";
95
92
  var GLOB_HTML = "**/*.htm?(l)";
96
93
  var GLOB_ASTRO = "**/*.astro";
94
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
97
95
  var GLOB_SVELTE = "**/*.svelte";
98
96
  var GLOB_MARKDOWN = "**/*.md";
99
97
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
@@ -164,126 +162,6 @@ var GLOB_EXCLUDE = [
164
162
  "**/.yarnrc"
165
163
  ];
166
164
 
167
- // src/configs/typescript.ts
168
- import process from "node:process";
169
- var typescriptCore = (options = {}) => {
170
- const isTypeAware = !!options.tsconfigPath;
171
- const configs2 = config({
172
- name: "ntnyq/ts/core",
173
- extends: [...configs.recommended],
174
- files: [GLOB_TS, GLOB_TSX],
175
- languageOptions: {
176
- parser: parserTypeScript,
177
- parserOptions: {
178
- sourceType: "module",
179
- ...isTypeAware ? {
180
- projectService: {
181
- defaultProject: options.tsconfigPath
182
- },
183
- tsconfigRootDir: process.cwd()
184
- } : {}
185
- }
186
- },
187
- rules: {
188
- // Disabled in favor of ts rules
189
- "no-redeclare": "off",
190
- "no-use-before-define": "off",
191
- "no-unused-vars": "off",
192
- "@typescript-eslint/no-redeclare": [
193
- "error",
194
- {
195
- builtinGlobals: false,
196
- ignoreDeclarationMerge: true
197
- }
198
- ],
199
- "@typescript-eslint/no-use-before-define": [
200
- "error",
201
- {
202
- functions: false,
203
- classes: false,
204
- variables: true,
205
- allowNamedExports: false,
206
- enums: true,
207
- typedefs: false,
208
- ignoreTypeReferences: false
209
- }
210
- ],
211
- "@typescript-eslint/no-unused-vars": [
212
- "error",
213
- {
214
- // Args after the last used will be reported
215
- args: "after-used",
216
- argsIgnorePattern: "^_",
217
- caughtErrors: "all",
218
- caughtErrorsIgnorePattern: "^_",
219
- destructuredArrayIgnorePattern: "^_",
220
- varsIgnorePattern: "^_",
221
- ignoreRestSiblings: true
222
- }
223
- ],
224
- "@typescript-eslint/no-unused-expressions": [
225
- "error",
226
- {
227
- allowShortCircuit: true,
228
- allowTernary: true,
229
- allowTaggedTemplates: true
230
- }
231
- ],
232
- "@typescript-eslint/consistent-type-imports": [
233
- "error",
234
- {
235
- prefer: "type-imports",
236
- fixStyle: "separate-type-imports",
237
- disallowTypeAnnotations: false
238
- }
239
- ],
240
- "@typescript-eslint/no-empty-object-type": [
241
- "error",
242
- {
243
- allowInterfaces: "always",
244
- allowObjectTypes: "always"
245
- }
246
- ],
247
- "@typescript-eslint/consistent-type-assertions": [
248
- "error",
249
- {
250
- assertionStyle: "as",
251
- objectLiteralTypeAssertions: "allow-as-parameter"
252
- }
253
- ],
254
- "@typescript-eslint/prefer-as-const": "warn",
255
- "@typescript-eslint/no-namespace": "off",
256
- "@typescript-eslint/ban-ts-comment": "off",
257
- "@typescript-eslint/no-explicit-any": "off",
258
- "@typescript-eslint/no-empty-function": "off",
259
- "@typescript-eslint/naming-convention": "off",
260
- "@typescript-eslint/no-non-null-assertion": "off",
261
- "@typescript-eslint/triple-slash-reference": "off",
262
- "@typescript-eslint/explicit-member-accessibility": "off",
263
- "@typescript-eslint/explicit-function-return-type": "off",
264
- "@typescript-eslint/explicit-module-boundary-types": "off",
265
- "@typescript-eslint/consistent-indexed-object-style": "off",
266
- // Overrides rules
267
- ...options.overrides
268
- }
269
- });
270
- return configs2;
271
- };
272
- var typescript = (options = {}) => [
273
- ...typescriptCore(options),
274
- {
275
- name: "ntnyq/ts/types",
276
- files: [GLOB_DTS, "**/types/**/*.ts"],
277
- rules: {
278
- "no-use-before-define": "off",
279
- "no-restricted-syntax": "off",
280
- "import/no-duplicates": "off",
281
- "import/newline-after-import": "off",
282
- "@typescript-eslint/no-use-before-define": "off"
283
- }
284
- }
285
- ];
286
-
287
165
  // src/configs/vue.ts
288
166
  var vue2Rules = {
289
167
  ...default3.configs.base.rules,
@@ -481,11 +359,6 @@ var vue = (options = {}) => {
481
359
  const isVue3 = options.vueVersion !== 2;
482
360
  const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
483
361
  return [
484
- ...config({
485
- name: "ntnyq/vue/ts",
486
- files: [GLOB_VUE],
487
- extends: typescriptCore()
488
- }),
489
362
  {
490
363
  name: "ntnyq/vue/setup",
491
364
  plugins: {
@@ -497,7 +370,7 @@ var vue = (options = {}) => {
497
370
  sourceType: "module",
498
371
  ecmaVersion: "latest",
499
372
  extraFileExtensions: [".vue"],
500
- parser: "@typescript-eslint/parser",
373
+ parser: parserTypeScript,
501
374
  ecmaFeatures: {
502
375
  jsx: true
503
376
  }
@@ -865,6 +738,16 @@ var sort = (options = {}) => {
865
738
  "activationEvents",
866
739
  "contributes",
867
740
  "categories",
741
+ "galleryBanner",
742
+ "badges",
743
+ "markdown",
744
+ "qna",
745
+ "sponsor",
746
+ "extensionPack",
747
+ "extensionDependencies",
748
+ "extensionKind",
749
+ "pricing",
750
+ "capabilities",
868
751
  /**
869
752
  * Package manager
870
753
  */
@@ -894,6 +777,20 @@ var sort = (options = {}) => {
894
777
  pathPattern: "^exports.*$",
895
778
  order: ["types", "import", "require", "default"]
896
779
  },
780
+ // VSCode extension
781
+ {
782
+ order: { type: "asc" },
783
+ pathPattern: "^contributes.*$"
784
+ },
785
+ /**
786
+ * pnpm publish config
787
+ * @see {@link https://pnpm.io/package_json#publishconfig}
788
+ */
789
+ {
790
+ order: { type: "asc" },
791
+ pathPattern: "^publishConfig.*$"
792
+ },
793
+ // npm scripts
897
794
  {
898
795
  pathPattern: "^scripts$",
899
796
  order: { type: "asc" }
@@ -920,6 +817,18 @@ var sort = (options = {}) => {
920
817
  {
921
818
  pathPattern: "^files$",
922
819
  order: { type: "asc" }
820
+ },
821
+ {
822
+ pathPattern: "^keywords$",
823
+ order: { type: "asc" }
824
+ },
825
+ {
826
+ pathPattern: "^activationEvents$",
827
+ order: { type: "asc" }
828
+ },
829
+ {
830
+ pathPattern: "^contributes.*$",
831
+ order: { type: "asc" }
923
832
  }
924
833
  ]
925
834
  }
@@ -1151,9 +1060,9 @@ var ntnyq = (options = {}) => [
1151
1060
 
1152
1061
  // src/configs/regexp.ts
1153
1062
  var regexp = (options = {}) => {
1154
- const config2 = pluginRegexp.configs["flat/recommended"];
1063
+ const config = pluginRegexp.configs["flat/recommended"];
1155
1064
  const rules = {
1156
- ...config2.rules
1065
+ ...config.rules
1157
1066
  };
1158
1067
  if (options.level === "warn") {
1159
1068
  for (const key in rules) {
@@ -1164,7 +1073,7 @@ var regexp = (options = {}) => {
1164
1073
  }
1165
1074
  return [
1166
1075
  {
1167
- ...config2,
1076
+ ...config,
1168
1077
  name: "ntnyq/regexp",
1169
1078
  rules: {
1170
1079
  ...rules,
@@ -1184,8 +1093,7 @@ var unocss = (options = {}) => [
1184
1093
  },
1185
1094
  rules: {
1186
1095
  "unocss/order": "error",
1187
- // We don't use this
1188
- "unocss/order-attributify": "off",
1096
+ "unocss/order-attributify": options.attributify ? "error" : "off",
1189
1097
  // Overrides rules
1190
1098
  ...options.overrides
1191
1099
  }
@@ -1243,12 +1151,12 @@ var DEFAULT_PRETTIER_OPTIONS = {
1243
1151
 
1244
1152
  // src/utils/env.ts
1245
1153
  import { resolve } from "node:path";
1246
- import process2 from "node:process";
1154
+ import process from "node:process";
1247
1155
  import { isPackageExists } from "local-pkg";
1248
1156
  var hasTypeScript = isPackageExists("typescript");
1249
1157
  var hasVitest = isPackageExists("vitest");
1250
1158
  var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
1251
- paths: [resolve(process2.cwd(), "playground")]
1159
+ paths: [resolve(process.cwd(), "playground")]
1252
1160
  });
1253
1161
  var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
1254
1162
 
@@ -1589,9 +1497,9 @@ var comments = (options = {}) => [
1589
1497
  var markdown = (options = {}) => {
1590
1498
  if (!Array.isArray(default7.configs?.processor)) return [];
1591
1499
  return [
1592
- ...default7.configs.processor.map((config2) => ({
1593
- ...config2,
1594
- name: `ntnyq/${config2.name}`
1500
+ ...default7.configs.processor.map((config) => ({
1501
+ ...config,
1502
+ name: `ntnyq/${config.name}`
1595
1503
  })),
1596
1504
  {
1597
1505
  name: "ntnyq/markdown/disabled/code-blocks",
@@ -1727,235 +1635,426 @@ var gitignore = (options = {}) => {
1727
1635
  // src/configs/javascript.ts
1728
1636
  import jsConfig from "@eslint/js";
1729
1637
  import globals2 from "globals";
1730
- var javascript = (options = {}) => {
1731
- const strictRules = {
1732
- complexity: ["error", { max: 30 }],
1733
- "max-params": ["error", { max: 5 }],
1734
- "max-depth": ["error", { max: 5 }],
1735
- "max-nested-callbacks": ["error", { max: 10 }],
1736
- "max-lines": [
1737
- "error",
1738
- {
1739
- max: 1e3,
1740
- skipComments: true,
1741
- skipBlankLines: true
1638
+ var strictRules = {
1639
+ complexity: ["error", { max: 30 }],
1640
+ "max-params": ["error", { max: 5 }],
1641
+ "max-depth": ["error", { max: 5 }],
1642
+ "max-nested-callbacks": ["error", { max: 10 }],
1643
+ "max-lines": [
1644
+ "error",
1645
+ {
1646
+ max: 1e3,
1647
+ skipComments: true,
1648
+ skipBlankLines: true
1649
+ }
1650
+ ],
1651
+ "max-lines-per-function": [
1652
+ "error",
1653
+ {
1654
+ max: 200,
1655
+ skipComments: true,
1656
+ skipBlankLines: true
1657
+ }
1658
+ ]
1659
+ };
1660
+ var javascript = (options = {}) => [
1661
+ {
1662
+ ...jsConfig.configs.recommended,
1663
+ name: "ntnyq/js/recommended"
1664
+ },
1665
+ {
1666
+ name: "ntnyq/js/core",
1667
+ languageOptions: {
1668
+ globals: {
1669
+ ...globals2.browser,
1670
+ ...globals2.es2021,
1671
+ ...globals2.node
1672
+ },
1673
+ sourceType: "module"
1674
+ },
1675
+ rules: {
1676
+ "require-await": "off",
1677
+ "no-return-assign": "off",
1678
+ "no-useless-escape": "off",
1679
+ "consistent-return": "off",
1680
+ // disabled in favor of `perfectionist/sort-named-imports`
1681
+ "sort-imports": "off",
1682
+ // standard v17.0.0
1683
+ "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
1684
+ camelcase: [
1685
+ "error",
1686
+ {
1687
+ allow: ["^UNSAFE_"],
1688
+ properties: "never",
1689
+ ignoreGlobals: true
1690
+ }
1691
+ ],
1692
+ "constructor-super": "error",
1693
+ curly: ["error", "multi-line"],
1694
+ "default-case-last": "error",
1695
+ "dot-notation": ["error", { allowKeywords: true }],
1696
+ "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
1697
+ "no-array-constructor": "error",
1698
+ "no-async-promise-executor": "error",
1699
+ "no-caller": "error",
1700
+ "no-class-assign": "error",
1701
+ "no-compare-neg-zero": "error",
1702
+ "no-cond-assign": "error",
1703
+ "no-const-assign": "error",
1704
+ "no-constant-condition": ["error", { checkLoops: false }],
1705
+ "no-control-regex": "error",
1706
+ "no-debugger": "error",
1707
+ "no-delete-var": "error",
1708
+ "no-dupe-args": "error",
1709
+ "no-dupe-class-members": "error",
1710
+ "no-dupe-keys": "error",
1711
+ "no-duplicate-case": "error",
1712
+ "no-useless-backreference": "error",
1713
+ "no-empty": ["error", { allowEmptyCatch: true }],
1714
+ "no-empty-character-class": "error",
1715
+ "no-empty-pattern": "error",
1716
+ "no-eval": "error",
1717
+ "no-ex-assign": "error",
1718
+ "no-extend-native": "error",
1719
+ "no-extra-bind": "error",
1720
+ "no-extra-boolean-cast": "error",
1721
+ "no-fallthrough": "error",
1722
+ "no-func-assign": "error",
1723
+ "no-global-assign": "error",
1724
+ "no-implied-eval": "error",
1725
+ "no-import-assign": "error",
1726
+ "no-invalid-regexp": "error",
1727
+ "no-irregular-whitespace": "error",
1728
+ "no-iterator": "error",
1729
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
1730
+ "no-lone-blocks": "error",
1731
+ "no-loss-of-precision": "error",
1732
+ "no-misleading-character-class": "error",
1733
+ "no-prototype-builtins": "error",
1734
+ "no-useless-catch": "error",
1735
+ "no-new": "error",
1736
+ "no-new-func": "error",
1737
+ "no-new-wrappers": "error",
1738
+ "no-obj-calls": "error",
1739
+ "no-octal": "error",
1740
+ "no-octal-escape": "error",
1741
+ "no-proto": "error",
1742
+ "no-redeclare": ["error", { builtinGlobals: false }],
1743
+ "no-regex-spaces": "error",
1744
+ "no-self-assign": ["error", { props: true }],
1745
+ "no-self-compare": "error",
1746
+ "no-sequences": "error",
1747
+ "no-shadow-restricted-names": "error",
1748
+ "no-sparse-arrays": "error",
1749
+ "no-template-curly-in-string": "error",
1750
+ "no-this-before-super": "error",
1751
+ "no-throw-literal": "error",
1752
+ "no-undef": "error",
1753
+ "no-undef-init": "error",
1754
+ "no-unexpected-multiline": "error",
1755
+ "no-unmodified-loop-condition": "error",
1756
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
1757
+ "no-unreachable": "error",
1758
+ "no-unreachable-loop": "error",
1759
+ "no-unsafe-finally": "error",
1760
+ "no-unsafe-negation": "error",
1761
+ "no-unused-expressions": [
1762
+ "error",
1763
+ {
1764
+ allowShortCircuit: true,
1765
+ allowTernary: true,
1766
+ allowTaggedTemplates: true
1767
+ }
1768
+ ],
1769
+ "no-unused-vars": [
1770
+ "error",
1771
+ {
1772
+ args: "none",
1773
+ caughtErrors: "none",
1774
+ ignoreRestSiblings: true,
1775
+ vars: "all"
1776
+ }
1777
+ ],
1778
+ "no-useless-call": "error",
1779
+ "no-useless-computed-key": "error",
1780
+ "no-useless-constructor": "error",
1781
+ "no-useless-rename": "error",
1782
+ "no-useless-return": "error",
1783
+ "prefer-promise-reject-errors": "error",
1784
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
1785
+ "symbol-description": "error",
1786
+ "unicode-bom": ["error", "never"],
1787
+ "use-isnan": [
1788
+ "error",
1789
+ {
1790
+ enforceForSwitchCase: true,
1791
+ enforceForIndexOf: true
1792
+ }
1793
+ ],
1794
+ "valid-typeof": ["error", { requireStringLiterals: true }],
1795
+ yoda: ["error", "never"],
1796
+ // es6+
1797
+ "no-var": "error",
1798
+ "prefer-rest-params": "error",
1799
+ "prefer-spread": "error",
1800
+ "prefer-template": "error",
1801
+ "no-empty-static-block": "error",
1802
+ "no-new-native-nonconstructor": "error",
1803
+ "prefer-const": [
1804
+ "error",
1805
+ {
1806
+ destructuring: "all",
1807
+ ignoreReadBeforeAssign: true
1808
+ }
1809
+ ],
1810
+ "prefer-arrow-callback": [
1811
+ "error",
1812
+ {
1813
+ allowNamedFunctions: false,
1814
+ allowUnboundThis: true
1815
+ }
1816
+ ],
1817
+ "object-shorthand": [
1818
+ "error",
1819
+ "always",
1820
+ {
1821
+ ignoreConstructors: false,
1822
+ avoidQuotes: true
1823
+ }
1824
+ ],
1825
+ // best-practice
1826
+ eqeqeq: ["error", "smart"],
1827
+ "array-callback-return": "error",
1828
+ "block-scoped-var": "error",
1829
+ "no-alert": "error",
1830
+ "no-case-declarations": "error",
1831
+ "no-multi-str": "error",
1832
+ "no-with": "error",
1833
+ "no-void": "error",
1834
+ "vars-on-top": "error",
1835
+ "one-var": ["error", "never"],
1836
+ "no-use-before-define": [
1837
+ "error",
1838
+ {
1839
+ functions: false,
1840
+ classes: false,
1841
+ variables: true,
1842
+ allowNamedExports: false
1843
+ }
1844
+ ],
1845
+ // Strict rules
1846
+ ...options.strict ? strictRules : {},
1847
+ // Overrides rules
1848
+ ...options.overrides
1849
+ }
1850
+ }
1851
+ ];
1852
+ var jsx = () => [
1853
+ {
1854
+ name: "ntnyq/jsx",
1855
+ files: ["**/*.jsx"],
1856
+ languageOptions: {
1857
+ parserOptions: {
1858
+ ecmaFeatures: {
1859
+ jsx: true
1860
+ }
1742
1861
  }
1743
- ],
1744
- "max-lines-per-function": [
1745
- "error",
1746
- {
1747
- max: 200,
1748
- skipComments: true,
1749
- skipBlankLines: true
1862
+ }
1863
+ }
1864
+ ];
1865
+
1866
+ // src/configs/typescript.ts
1867
+ import process2 from "node:process";
1868
+ var typeAwareRules = {
1869
+ "dot-notation": "off",
1870
+ "require-await": "off",
1871
+ "no-implied-eval": "off",
1872
+ "no-throw-literal": "off",
1873
+ // too strict
1874
+ "@typescript-eslint/strict-boolean-expressions": "off",
1875
+ "@typescript-eslint/require-await": "error",
1876
+ "@typescript-eslint/unbound-method": "error",
1877
+ "@typescript-eslint/no-unsafe-call": "error",
1878
+ "@typescript-eslint/await-thenable": "error",
1879
+ "@typescript-eslint/no-for-in-array": "error",
1880
+ "@typescript-eslint/no-implied-eval": "error",
1881
+ "@typescript-eslint/only-throw-error": "error",
1882
+ "@typescript-eslint/no-unsafe-return": "error",
1883
+ "@typescript-eslint/no-unsafe-argument": "error",
1884
+ "@typescript-eslint/no-misused-promises": "error",
1885
+ "@typescript-eslint/no-unsafe-assignment": "error",
1886
+ "@typescript-eslint/no-floating-promises": "error",
1887
+ "@typescript-eslint/promise-function-async": "error",
1888
+ "@typescript-eslint/restrict-plus-operands": "error",
1889
+ "@typescript-eslint/triple-slash-reference": "error",
1890
+ "@typescript-eslint/no-unsafe-member-access": "error",
1891
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
1892
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
1893
+ "@typescript-eslint/restrict-template-expressions": "error",
1894
+ "@typescript-eslint/no-redundant-type-constituents": "error",
1895
+ "@typescript-eslint/no-duplicate-type-constituents": "error",
1896
+ "@typescript-eslint/return-await": ["error", "in-try-catch"],
1897
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }]
1898
+ };
1899
+ var recommendedRules = configs.recommended.reduce((rules, config) => {
1900
+ return { ...rules, ...config.rules || {} };
1901
+ }, {});
1902
+ var typescript = (options = {}) => {
1903
+ const enableTypeAwareLint = !!options?.tsconfigPath;
1904
+ const {
1905
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
1906
+ ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`],
1907
+ overridesTypeAwareRules = {},
1908
+ parserOptions = {}
1909
+ } = options;
1910
+ function createParserConfig(enableTypeAware = false, files = [], ignores2 = []) {
1911
+ const typescriptParserOptions = {
1912
+ // extraFileExtensions: [''],
1913
+ sourceType: "module",
1914
+ ...enableTypeAware ? {
1915
+ projectService: {
1916
+ allowDefaultProject: ["./*.js"],
1917
+ defaultProject: options.tsconfigPath
1918
+ },
1919
+ tsconfigRootDir: process2.cwd()
1920
+ } : {},
1921
+ ...parserOptions
1922
+ };
1923
+ const parserConfig = {
1924
+ name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
1925
+ files,
1926
+ ignores: [...ignores2],
1927
+ languageOptions: {
1928
+ parser: parserTypeScript,
1929
+ parserOptions: typescriptParserOptions
1750
1930
  }
1751
- ]
1752
- };
1931
+ };
1932
+ return parserConfig;
1933
+ }
1753
1934
  return [
1754
1935
  {
1755
- ...jsConfig.configs.recommended,
1756
- name: "ntnyq/js/recommended"
1936
+ name: "ntnyq/ts/setup",
1937
+ plugins: {
1938
+ "@typescript-eslint": plugin,
1939
+ antfu: default8
1940
+ }
1757
1941
  },
1942
+ ...enableTypeAwareLint ? [
1943
+ createParserConfig(false, [GLOB_TS, GLOB_TSX]),
1944
+ createParserConfig(true, filesTypeAware, ignoresTypeAware)
1945
+ ] : [createParserConfig(false, [GLOB_TS, GLOB_TSX])],
1758
1946
  {
1759
- name: "ntnyq/js/core",
1760
- languageOptions: {
1761
- globals: {
1762
- ...globals2.browser,
1763
- ...globals2.es2021,
1764
- ...globals2.node
1765
- },
1766
- sourceType: "module"
1767
- },
1947
+ name: "ntnyq/ts/rules",
1948
+ files: [GLOB_TS, GLOB_TSX],
1768
1949
  rules: {
1769
- "require-await": "off",
1770
- "no-return-assign": "off",
1771
- "no-useless-escape": "off",
1772
- "consistent-return": "off",
1773
- // disabled in favor of `perfectionist/sort-named-imports`
1774
- "sort-imports": "off",
1775
- // standard v17.0.0
1776
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
1777
- camelcase: [
1778
- "error",
1779
- {
1780
- allow: ["^UNSAFE_"],
1781
- properties: "never",
1782
- ignoreGlobals: true
1783
- }
1784
- ],
1785
- "constructor-super": "error",
1786
- curly: ["error", "multi-line"],
1787
- "default-case-last": "error",
1788
- "dot-notation": ["error", { allowKeywords: true }],
1789
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
1790
- "no-array-constructor": "error",
1791
- "no-async-promise-executor": "error",
1792
- "no-caller": "error",
1793
- "no-class-assign": "error",
1794
- "no-compare-neg-zero": "error",
1795
- "no-cond-assign": "error",
1796
- "no-const-assign": "error",
1797
- "no-constant-condition": ["error", { checkLoops: false }],
1798
- "no-control-regex": "error",
1799
- "no-debugger": "error",
1800
- "no-delete-var": "error",
1801
- "no-dupe-args": "error",
1802
- "no-dupe-class-members": "error",
1803
- "no-dupe-keys": "error",
1804
- "no-duplicate-case": "error",
1805
- "no-useless-backreference": "error",
1806
- "no-empty": ["error", { allowEmptyCatch: true }],
1807
- "no-empty-character-class": "error",
1808
- "no-empty-pattern": "error",
1809
- "no-eval": "error",
1810
- "no-ex-assign": "error",
1811
- "no-extend-native": "error",
1812
- "no-extra-bind": "error",
1813
- "no-extra-boolean-cast": "error",
1814
- "no-fallthrough": "error",
1815
- "no-func-assign": "error",
1816
- "no-global-assign": "error",
1817
- "no-implied-eval": "error",
1818
- "no-import-assign": "error",
1819
- "no-invalid-regexp": "error",
1820
- "no-irregular-whitespace": "error",
1821
- "no-iterator": "error",
1822
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
1823
- "no-lone-blocks": "error",
1824
- "no-loss-of-precision": "error",
1825
- "no-misleading-character-class": "error",
1826
- "no-prototype-builtins": "error",
1827
- "no-useless-catch": "error",
1828
- "no-new": "error",
1829
- "no-new-func": "error",
1830
- "no-new-wrappers": "error",
1831
- "no-obj-calls": "error",
1832
- "no-octal": "error",
1833
- "no-octal-escape": "error",
1834
- "no-proto": "error",
1835
- "no-redeclare": ["error", { builtinGlobals: false }],
1836
- "no-regex-spaces": "error",
1837
- "no-self-assign": ["error", { props: true }],
1838
- "no-self-compare": "error",
1839
- "no-sequences": "error",
1840
- "no-shadow-restricted-names": "error",
1841
- "no-sparse-arrays": "error",
1842
- "no-template-curly-in-string": "error",
1843
- "no-this-before-super": "error",
1844
- "no-throw-literal": "error",
1845
- "no-undef": "error",
1846
- "no-undef-init": "error",
1847
- "no-unexpected-multiline": "error",
1848
- "no-unmodified-loop-condition": "error",
1849
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
1850
- "no-unreachable": "error",
1851
- "no-unreachable-loop": "error",
1852
- "no-unsafe-finally": "error",
1853
- "no-unsafe-negation": "error",
1854
- "no-unused-expressions": [
1950
+ ...recommendedRules,
1951
+ // Disabled in favor of ts rules
1952
+ "no-redeclare": "off",
1953
+ "no-use-before-define": "off",
1954
+ "no-unused-vars": "off",
1955
+ "@typescript-eslint/no-redeclare": [
1855
1956
  "error",
1856
1957
  {
1857
- allowShortCircuit: true,
1858
- allowTernary: true,
1859
- allowTaggedTemplates: true
1958
+ builtinGlobals: false,
1959
+ ignoreDeclarationMerge: true
1860
1960
  }
1861
1961
  ],
1862
- "no-unused-vars": [
1962
+ "@typescript-eslint/no-use-before-define": [
1863
1963
  "error",
1864
1964
  {
1865
- args: "none",
1866
- caughtErrors: "none",
1867
- ignoreRestSiblings: true,
1868
- vars: "all"
1965
+ functions: false,
1966
+ classes: false,
1967
+ variables: true,
1968
+ allowNamedExports: false,
1969
+ enums: true,
1970
+ typedefs: false,
1971
+ ignoreTypeReferences: false
1869
1972
  }
1870
1973
  ],
1871
- "no-useless-call": "error",
1872
- "no-useless-computed-key": "error",
1873
- "no-useless-constructor": "error",
1874
- "no-useless-rename": "error",
1875
- "no-useless-return": "error",
1876
- "prefer-promise-reject-errors": "error",
1877
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
1878
- "symbol-description": "error",
1879
- "unicode-bom": ["error", "never"],
1880
- "use-isnan": [
1974
+ "@typescript-eslint/no-unused-vars": [
1881
1975
  "error",
1882
1976
  {
1883
- enforceForSwitchCase: true,
1884
- enforceForIndexOf: true
1977
+ // Args after the last used will be reported
1978
+ args: "after-used",
1979
+ argsIgnorePattern: "^_",
1980
+ caughtErrors: "all",
1981
+ caughtErrorsIgnorePattern: "^_",
1982
+ destructuredArrayIgnorePattern: "^_",
1983
+ varsIgnorePattern: "^_",
1984
+ ignoreRestSiblings: true
1885
1985
  }
1886
1986
  ],
1887
- "valid-typeof": ["error", { requireStringLiterals: true }],
1888
- yoda: ["error", "never"],
1889
- // es6+
1890
- "no-var": "error",
1891
- "prefer-rest-params": "error",
1892
- "prefer-spread": "error",
1893
- "prefer-template": "error",
1894
- "no-empty-static-block": "error",
1895
- "no-new-native-nonconstructor": "error",
1896
- "prefer-const": [
1987
+ "@typescript-eslint/no-unused-expressions": [
1897
1988
  "error",
1898
1989
  {
1899
- destructuring: "all",
1900
- ignoreReadBeforeAssign: true
1990
+ allowShortCircuit: true,
1991
+ allowTernary: true,
1992
+ allowTaggedTemplates: true
1901
1993
  }
1902
1994
  ],
1903
- "prefer-arrow-callback": [
1995
+ "@typescript-eslint/consistent-type-imports": [
1904
1996
  "error",
1905
1997
  {
1906
- allowNamedFunctions: false,
1907
- allowUnboundThis: true
1998
+ prefer: "type-imports",
1999
+ fixStyle: "separate-type-imports",
2000
+ disallowTypeAnnotations: false
1908
2001
  }
1909
2002
  ],
1910
- "object-shorthand": [
2003
+ "@typescript-eslint/no-empty-object-type": [
1911
2004
  "error",
1912
- "always",
1913
2005
  {
1914
- ignoreConstructors: false,
1915
- avoidQuotes: true
2006
+ allowInterfaces: "always",
2007
+ allowObjectTypes: "always"
1916
2008
  }
1917
2009
  ],
1918
- // best-practice
1919
- eqeqeq: ["error", "smart"],
1920
- "array-callback-return": "error",
1921
- "block-scoped-var": "error",
1922
- "no-alert": "error",
1923
- "no-case-declarations": "error",
1924
- "no-multi-str": "error",
1925
- "no-with": "error",
1926
- "no-void": "error",
1927
- "vars-on-top": "error",
1928
- "one-var": ["error", "never"],
1929
- "no-use-before-define": [
2010
+ "@typescript-eslint/consistent-type-assertions": [
1930
2011
  "error",
1931
2012
  {
1932
- functions: false,
1933
- classes: false,
1934
- variables: true,
1935
- allowNamedExports: false
2013
+ assertionStyle: "as",
2014
+ objectLiteralTypeAssertions: "allow-as-parameter"
1936
2015
  }
1937
2016
  ],
1938
- // Strict rules
1939
- ...options.strict ? strictRules : {},
2017
+ "@typescript-eslint/prefer-as-const": "warn",
2018
+ "@typescript-eslint/no-namespace": "off",
2019
+ "@typescript-eslint/ban-ts-comment": "off",
2020
+ "@typescript-eslint/no-explicit-any": "off",
2021
+ "@typescript-eslint/no-empty-function": "off",
2022
+ "@typescript-eslint/naming-convention": "off",
2023
+ "@typescript-eslint/no-non-null-assertion": "off",
2024
+ "@typescript-eslint/triple-slash-reference": "off",
2025
+ "@typescript-eslint/explicit-member-accessibility": "off",
2026
+ "@typescript-eslint/explicit-function-return-type": "off",
2027
+ "@typescript-eslint/explicit-module-boundary-types": "off",
2028
+ "@typescript-eslint/consistent-indexed-object-style": "off",
1940
2029
  // Overrides rules
1941
2030
  ...options.overrides
1942
2031
  }
1943
- }
1944
- ];
1945
- };
1946
- var jsx = () => [
1947
- {
1948
- name: "ntnyq/jsx",
1949
- files: ["**/*.jsx"],
1950
- languageOptions: {
1951
- parserOptions: {
1952
- ecmaFeatures: {
1953
- jsx: true
2032
+ },
2033
+ ...enableTypeAwareLint ? [
2034
+ {
2035
+ name: "ntnyq/ts/rules/type-aware",
2036
+ files: [...filesTypeAware],
2037
+ ignores: [...ignoresTypeAware],
2038
+ rules: {
2039
+ ...typeAwareRules,
2040
+ // Overrides type aware rules
2041
+ ...overridesTypeAwareRules
1954
2042
  }
1955
2043
  }
2044
+ ] : [],
2045
+ {
2046
+ name: "ntnyq/ts/types",
2047
+ files: [GLOB_DTS, "**/types/**/*.ts"],
2048
+ rules: {
2049
+ "no-use-before-define": "off",
2050
+ "no-restricted-syntax": "off",
2051
+ "import/no-duplicates": "off",
2052
+ "import/newline-after-import": "off",
2053
+ "@typescript-eslint/no-use-before-define": "off"
2054
+ }
1956
2055
  }
1957
- }
1958
- ];
2056
+ ];
2057
+ };
1959
2058
 
1960
2059
  // src/configs/githubAction.ts
1961
2060
  var githubAction = (options = {}) => [
@@ -2089,7 +2188,7 @@ var unusedImports = (options = {}) => [
2089
2188
  ];
2090
2189
 
2091
2190
  // src/core.ts
2092
- function defineESLintConfig(options = {}, userConfigs = []) {
2191
+ async function defineESLintConfig(options = {}, ...userConfigs) {
2093
2192
  const configs2 = [];
2094
2193
  if (options.gitignore ?? true) {
2095
2194
  configs2.push(
@@ -2104,9 +2203,18 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2104
2203
  ...node({
2105
2204
  overrides: getOverrides(options, "node")
2106
2205
  }),
2206
+ ...command({
2207
+ ...resolveSubOptions(options, "command")
2208
+ }),
2107
2209
  ...imports({
2108
2210
  overrides: getOverrides(options, "imports")
2109
2211
  }),
2212
+ ...jsdoc({
2213
+ overrides: getOverrides(options, "jsdoc")
2214
+ }),
2215
+ ...comments({
2216
+ overrides: getOverrides(options, "comments")
2217
+ }),
2110
2218
  ...javascript({
2111
2219
  ...resolveSubOptions(options, "javascript"),
2112
2220
  overrides: getOverrides(options, "javascript")
@@ -2135,20 +2243,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2135
2243
  })
2136
2244
  );
2137
2245
  }
2138
- if (options.jsdoc ?? true) {
2139
- configs2.push(
2140
- ...jsdoc({
2141
- overrides: getOverrides(options, "jsdoc")
2142
- })
2143
- );
2144
- }
2145
- if (options.comments ?? true) {
2146
- configs2.push(
2147
- ...comments({
2148
- overrides: getOverrides(options, "comments")
2149
- })
2150
- );
2151
- }
2152
2246
  if (options.typescript ?? hasTypeScript) {
2153
2247
  configs2.push(
2154
2248
  ...typescript({
@@ -2217,13 +2311,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2217
2311
  })
2218
2312
  );
2219
2313
  }
2220
- if (options.command ?? true) {
2221
- configs2.push(
2222
- ...command({
2223
- ...resolveSubOptions(options, "command")
2224
- })
2225
- );
2226
- }
2227
2314
  if (options.antfu ?? true) {
2228
2315
  configs2.push(
2229
2316
  ...antfu({
@@ -2251,9 +2338,9 @@ function defineESLintConfig(options = {}, userConfigs = []) {
2251
2338
  overrides: getOverrides(options, "prettier")
2252
2339
  }) : [];
2253
2340
  const composer = new FlatConfigComposer();
2254
- composer.append(
2341
+ await composer.append(
2255
2342
  ...configs2,
2256
- ...toArray(userConfigs),
2343
+ ...userConfigs,
2257
2344
  ...configSpecials,
2258
2345
  ...configPrettier
2259
2346
  );
@@ -2263,6 +2350,7 @@ export {
2263
2350
  DEFAULT_PRETTIER_OPTIONS,
2264
2351
  GLOB_ALL_SRC,
2265
2352
  GLOB_ASTRO,
2353
+ GLOB_ASTRO_TS,
2266
2354
  GLOB_CSS,
2267
2355
  GLOB_DIST,
2268
2356
  GLOB_DTS,
@@ -2295,7 +2383,6 @@ export {
2295
2383
  antfu,
2296
2384
  command,
2297
2385
  comments,
2298
- config as createTypeScriptConfig,
2299
2386
  defineESLintConfig,
2300
2387
  format,
2301
2388
  getOverrides,
@@ -2360,7 +2447,6 @@ export {
2360
2447
  toml,
2361
2448
  typescript,
2362
2449
  configs as typescriptConfigs,
2363
- typescriptCore,
2364
2450
  unicorn,
2365
2451
  unocss,
2366
2452
  unusedImports,