@ntnyq/eslint-config 3.3.0 → 3.4.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/README.md +12 -10
- package/dist/index.cjs +250 -171
- package/dist/index.d.cts +5639 -3830
- package/dist/index.d.ts +5639 -3830
- package/dist/index.js +256 -178
- package/package.json +8 -7
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";
|
|
@@ -53,10 +50,11 @@ import { default as default13 } from "@vitest/eslint-plugin";
|
|
|
53
50
|
import { default as default14 } from "eslint-plugin-import-x";
|
|
54
51
|
import { default as default15 } from "eslint-plugin-unicorn";
|
|
55
52
|
import { default as default16 } from "eslint-plugin-prettier";
|
|
56
|
-
import { default as default17 } from "eslint-plugin
|
|
57
|
-
import { default as default18 } from "eslint-plugin-
|
|
58
|
-
import { default as default19 } from "eslint-plugin-
|
|
59
|
-
import { default as default20 } from "
|
|
53
|
+
import { default as default17 } from "@stylistic/eslint-plugin";
|
|
54
|
+
import { default as default18 } from "eslint-plugin-github-action";
|
|
55
|
+
import { default as default19 } from "eslint-plugin-perfectionist";
|
|
56
|
+
import { default as default20 } from "eslint-plugin-unused-imports";
|
|
57
|
+
import { default as default21 } from "@eslint-community/eslint-plugin-eslint-comments";
|
|
60
58
|
|
|
61
59
|
// src/eslint/configs.ts
|
|
62
60
|
import { configs } from "typescript-eslint";
|
|
@@ -64,7 +62,7 @@ import { configs } from "typescript-eslint";
|
|
|
64
62
|
// src/eslint/processors.ts
|
|
65
63
|
import { mergeProcessors } from "eslint-merge-processors";
|
|
66
64
|
import { processorPassThrough } from "eslint-merge-processors";
|
|
67
|
-
import { default as
|
|
65
|
+
import { default as default22 } from "eslint-processor-vue-blocks";
|
|
68
66
|
|
|
69
67
|
// src/globs.ts
|
|
70
68
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -93,6 +91,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
|
|
|
93
91
|
var GLOB_TOML = "**/*.toml";
|
|
94
92
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
95
93
|
var GLOB_ASTRO = "**/*.astro";
|
|
94
|
+
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
96
95
|
var GLOB_SVELTE = "**/*.svelte";
|
|
97
96
|
var GLOB_MARKDOWN = "**/*.md";
|
|
98
97
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
@@ -163,126 +162,6 @@ var GLOB_EXCLUDE = [
|
|
|
163
162
|
"**/.yarnrc"
|
|
164
163
|
];
|
|
165
164
|
|
|
166
|
-
// src/configs/typescript.ts
|
|
167
|
-
import process from "node:process";
|
|
168
|
-
var typescriptCore = (options = {}) => {
|
|
169
|
-
const isTypeAware = !!options.tsconfigPath;
|
|
170
|
-
const configs2 = config({
|
|
171
|
-
name: "ntnyq/ts/core",
|
|
172
|
-
extends: [...configs.recommended],
|
|
173
|
-
files: [GLOB_TS, GLOB_TSX],
|
|
174
|
-
languageOptions: {
|
|
175
|
-
parser: parserTypeScript,
|
|
176
|
-
parserOptions: {
|
|
177
|
-
sourceType: "module",
|
|
178
|
-
...isTypeAware ? {
|
|
179
|
-
projectService: {
|
|
180
|
-
defaultProject: options.tsconfigPath
|
|
181
|
-
},
|
|
182
|
-
tsconfigRootDir: process.cwd()
|
|
183
|
-
} : {}
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
rules: {
|
|
187
|
-
// Disabled in favor of ts rules
|
|
188
|
-
"no-redeclare": "off",
|
|
189
|
-
"no-use-before-define": "off",
|
|
190
|
-
"no-unused-vars": "off",
|
|
191
|
-
"@typescript-eslint/no-redeclare": [
|
|
192
|
-
"error",
|
|
193
|
-
{
|
|
194
|
-
builtinGlobals: false,
|
|
195
|
-
ignoreDeclarationMerge: true
|
|
196
|
-
}
|
|
197
|
-
],
|
|
198
|
-
"@typescript-eslint/no-use-before-define": [
|
|
199
|
-
"error",
|
|
200
|
-
{
|
|
201
|
-
functions: false,
|
|
202
|
-
classes: false,
|
|
203
|
-
variables: true,
|
|
204
|
-
allowNamedExports: false,
|
|
205
|
-
enums: true,
|
|
206
|
-
typedefs: false,
|
|
207
|
-
ignoreTypeReferences: false
|
|
208
|
-
}
|
|
209
|
-
],
|
|
210
|
-
"@typescript-eslint/no-unused-vars": [
|
|
211
|
-
"error",
|
|
212
|
-
{
|
|
213
|
-
// Args after the last used will be reported
|
|
214
|
-
args: "after-used",
|
|
215
|
-
argsIgnorePattern: "^_",
|
|
216
|
-
caughtErrors: "all",
|
|
217
|
-
caughtErrorsIgnorePattern: "^_",
|
|
218
|
-
destructuredArrayIgnorePattern: "^_",
|
|
219
|
-
varsIgnorePattern: "^_",
|
|
220
|
-
ignoreRestSiblings: true
|
|
221
|
-
}
|
|
222
|
-
],
|
|
223
|
-
"@typescript-eslint/no-unused-expressions": [
|
|
224
|
-
"error",
|
|
225
|
-
{
|
|
226
|
-
allowShortCircuit: true,
|
|
227
|
-
allowTernary: true,
|
|
228
|
-
allowTaggedTemplates: true
|
|
229
|
-
}
|
|
230
|
-
],
|
|
231
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
232
|
-
"error",
|
|
233
|
-
{
|
|
234
|
-
prefer: "type-imports",
|
|
235
|
-
fixStyle: "separate-type-imports",
|
|
236
|
-
disallowTypeAnnotations: false
|
|
237
|
-
}
|
|
238
|
-
],
|
|
239
|
-
"@typescript-eslint/no-empty-object-type": [
|
|
240
|
-
"error",
|
|
241
|
-
{
|
|
242
|
-
allowInterfaces: "always",
|
|
243
|
-
allowObjectTypes: "always"
|
|
244
|
-
}
|
|
245
|
-
],
|
|
246
|
-
"@typescript-eslint/consistent-type-assertions": [
|
|
247
|
-
"error",
|
|
248
|
-
{
|
|
249
|
-
assertionStyle: "as",
|
|
250
|
-
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
251
|
-
}
|
|
252
|
-
],
|
|
253
|
-
"@typescript-eslint/prefer-as-const": "warn",
|
|
254
|
-
"@typescript-eslint/no-namespace": "off",
|
|
255
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
256
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
257
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
258
|
-
"@typescript-eslint/naming-convention": "off",
|
|
259
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
260
|
-
"@typescript-eslint/triple-slash-reference": "off",
|
|
261
|
-
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
262
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
263
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
264
|
-
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
265
|
-
// Overrides rules
|
|
266
|
-
...options.overrides
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
return configs2;
|
|
270
|
-
};
|
|
271
|
-
var typescript = (options = {}) => [
|
|
272
|
-
...typescriptCore(options),
|
|
273
|
-
{
|
|
274
|
-
name: "ntnyq/ts/types",
|
|
275
|
-
files: [GLOB_DTS, "**/types/**/*.ts"],
|
|
276
|
-
rules: {
|
|
277
|
-
"no-use-before-define": "off",
|
|
278
|
-
"no-restricted-syntax": "off",
|
|
279
|
-
"import/no-duplicates": "off",
|
|
280
|
-
"import/newline-after-import": "off",
|
|
281
|
-
"@typescript-eslint/no-use-before-define": "off"
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
];
|
|
285
|
-
|
|
286
165
|
// src/configs/vue.ts
|
|
287
166
|
var vue2Rules = {
|
|
288
167
|
...default3.configs.base.rules,
|
|
@@ -480,11 +359,6 @@ var vue = (options = {}) => {
|
|
|
480
359
|
const isVue3 = options.vueVersion !== 2;
|
|
481
360
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
482
361
|
return [
|
|
483
|
-
...config({
|
|
484
|
-
name: "ntnyq/vue/ts",
|
|
485
|
-
files: [GLOB_VUE],
|
|
486
|
-
extends: typescriptCore()
|
|
487
|
-
}),
|
|
488
362
|
{
|
|
489
363
|
name: "ntnyq/vue/setup",
|
|
490
364
|
plugins: {
|
|
@@ -496,7 +370,7 @@ var vue = (options = {}) => {
|
|
|
496
370
|
sourceType: "module",
|
|
497
371
|
ecmaVersion: "latest",
|
|
498
372
|
extraFileExtensions: [".vue"],
|
|
499
|
-
parser:
|
|
373
|
+
parser: parserTypeScript,
|
|
500
374
|
ecmaFeatures: {
|
|
501
375
|
jsx: true
|
|
502
376
|
}
|
|
@@ -511,7 +385,7 @@ var vue = (options = {}) => {
|
|
|
511
385
|
},
|
|
512
386
|
processor: sfcBlocks === false ? default3.processors[".vue"] : mergeProcessors2([
|
|
513
387
|
default3.processors[".vue"],
|
|
514
|
-
|
|
388
|
+
default22({
|
|
515
389
|
...sfcBlocks,
|
|
516
390
|
blocks: {
|
|
517
391
|
styles: true,
|
|
@@ -1150,9 +1024,9 @@ var ntnyq = (options = {}) => [
|
|
|
1150
1024
|
|
|
1151
1025
|
// src/configs/regexp.ts
|
|
1152
1026
|
var regexp = (options = {}) => {
|
|
1153
|
-
const
|
|
1027
|
+
const config = pluginRegexp.configs["flat/recommended"];
|
|
1154
1028
|
const rules = {
|
|
1155
|
-
...
|
|
1029
|
+
...config.rules
|
|
1156
1030
|
};
|
|
1157
1031
|
if (options.level === "warn") {
|
|
1158
1032
|
for (const key in rules) {
|
|
@@ -1163,7 +1037,7 @@ var regexp = (options = {}) => {
|
|
|
1163
1037
|
}
|
|
1164
1038
|
return [
|
|
1165
1039
|
{
|
|
1166
|
-
...
|
|
1040
|
+
...config,
|
|
1167
1041
|
name: "ntnyq/regexp",
|
|
1168
1042
|
rules: {
|
|
1169
1043
|
...rules,
|
|
@@ -1242,12 +1116,12 @@ var DEFAULT_PRETTIER_OPTIONS = {
|
|
|
1242
1116
|
|
|
1243
1117
|
// src/utils/env.ts
|
|
1244
1118
|
import { resolve } from "node:path";
|
|
1245
|
-
import
|
|
1119
|
+
import process from "node:process";
|
|
1246
1120
|
import { isPackageExists } from "local-pkg";
|
|
1247
1121
|
var hasTypeScript = isPackageExists("typescript");
|
|
1248
1122
|
var hasVitest = isPackageExists("vitest");
|
|
1249
1123
|
var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
|
|
1250
|
-
paths: [resolve(
|
|
1124
|
+
paths: [resolve(process.cwd(), "playground")]
|
|
1251
1125
|
});
|
|
1252
1126
|
var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
1253
1127
|
|
|
@@ -1573,10 +1447,10 @@ var comments = (options = {}) => [
|
|
|
1573
1447
|
{
|
|
1574
1448
|
name: "ntnyq/eslint-comments",
|
|
1575
1449
|
plugins: {
|
|
1576
|
-
"@eslint-community/eslint-comments":
|
|
1450
|
+
"@eslint-community/eslint-comments": default21
|
|
1577
1451
|
},
|
|
1578
1452
|
rules: {
|
|
1579
|
-
...
|
|
1453
|
+
...default21.configs.recommended.rules,
|
|
1580
1454
|
"@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
|
|
1581
1455
|
// Overrides rules
|
|
1582
1456
|
...options.overrides
|
|
@@ -1588,9 +1462,9 @@ var comments = (options = {}) => [
|
|
|
1588
1462
|
var markdown = (options = {}) => {
|
|
1589
1463
|
if (!Array.isArray(default7.configs?.processor)) return [];
|
|
1590
1464
|
return [
|
|
1591
|
-
...default7.configs.processor.map((
|
|
1592
|
-
...
|
|
1593
|
-
name: `ntnyq/${
|
|
1465
|
+
...default7.configs.processor.map((config) => ({
|
|
1466
|
+
...config,
|
|
1467
|
+
name: `ntnyq/${config.name}`
|
|
1594
1468
|
})),
|
|
1595
1469
|
{
|
|
1596
1470
|
name: "ntnyq/markdown/disabled/code-blocks",
|
|
@@ -1695,6 +1569,22 @@ var prettier = (options = {}) => {
|
|
|
1695
1569
|
];
|
|
1696
1570
|
};
|
|
1697
1571
|
|
|
1572
|
+
// src/configs/stylistic.ts
|
|
1573
|
+
var stylistic = (options = {}) => [
|
|
1574
|
+
{
|
|
1575
|
+
name: "ntnyq/stylistic",
|
|
1576
|
+
plugins: {
|
|
1577
|
+
"@stylistic": default17
|
|
1578
|
+
},
|
|
1579
|
+
rules: {
|
|
1580
|
+
// Only rules are not conflicted with Prettier
|
|
1581
|
+
// Use stylistic config to provide type support
|
|
1582
|
+
// Overrides rules
|
|
1583
|
+
...options.overrides
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
];
|
|
1587
|
+
|
|
1698
1588
|
// src/configs/gitignore.ts
|
|
1699
1589
|
import createGitIgnoreConfig from "eslint-config-flat-gitignore";
|
|
1700
1590
|
var gitignore = (options = {}) => {
|
|
@@ -1940,13 +1830,205 @@ var jsx = () => [
|
|
|
1940
1830
|
}
|
|
1941
1831
|
];
|
|
1942
1832
|
|
|
1833
|
+
// src/configs/typescript.ts
|
|
1834
|
+
import process2 from "node:process";
|
|
1835
|
+
var typeAwareRules = {
|
|
1836
|
+
"dot-notation": "off",
|
|
1837
|
+
"require-await": "off",
|
|
1838
|
+
"no-implied-eval": "off",
|
|
1839
|
+
"no-throw-literal": "off",
|
|
1840
|
+
// too strict
|
|
1841
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
1842
|
+
"@typescript-eslint/require-await": "error",
|
|
1843
|
+
"@typescript-eslint/unbound-method": "error",
|
|
1844
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
1845
|
+
"@typescript-eslint/await-thenable": "error",
|
|
1846
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
1847
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
1848
|
+
"@typescript-eslint/only-throw-error": "error",
|
|
1849
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
1850
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
1851
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
1852
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
1853
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
1854
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
1855
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
1856
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
1857
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
1858
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
1859
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
1860
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
1861
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
1862
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
1863
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
1864
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }]
|
|
1865
|
+
};
|
|
1866
|
+
var recommendedRules = configs.recommended.reduce((rules, config) => {
|
|
1867
|
+
return { ...rules, ...config.rules || {} };
|
|
1868
|
+
}, {});
|
|
1869
|
+
var typescript = (options = {}) => {
|
|
1870
|
+
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
1871
|
+
const {
|
|
1872
|
+
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
1873
|
+
ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`],
|
|
1874
|
+
overridesTypeAwareRules = {},
|
|
1875
|
+
parserOptions = {}
|
|
1876
|
+
} = options;
|
|
1877
|
+
function createParserConfig(enableTypeAware = false, files = [], ignores2 = []) {
|
|
1878
|
+
const parserConfig = {
|
|
1879
|
+
name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
1880
|
+
files,
|
|
1881
|
+
ignores: [...ignores2],
|
|
1882
|
+
languageOptions: {
|
|
1883
|
+
parser: parserTypeScript,
|
|
1884
|
+
parserOptions: {
|
|
1885
|
+
// extraFileExtensions: [''],
|
|
1886
|
+
sourceType: "module",
|
|
1887
|
+
...enableTypeAware ? {
|
|
1888
|
+
projectService: {
|
|
1889
|
+
allowDefaultProject: ["./*.js"],
|
|
1890
|
+
defaultProject: options.tsconfigPath
|
|
1891
|
+
},
|
|
1892
|
+
tsconfigRootDir: process2.cwd()
|
|
1893
|
+
} : {},
|
|
1894
|
+
...parserOptions
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
};
|
|
1898
|
+
return parserConfig;
|
|
1899
|
+
}
|
|
1900
|
+
return [
|
|
1901
|
+
{
|
|
1902
|
+
name: "ntnyq/ts/setup",
|
|
1903
|
+
plugins: {
|
|
1904
|
+
"@typescript-eslint": plugin,
|
|
1905
|
+
antfu: default8
|
|
1906
|
+
}
|
|
1907
|
+
},
|
|
1908
|
+
...enableTypeAwareLint ? [
|
|
1909
|
+
createParserConfig(false, [GLOB_TS, GLOB_TSX]),
|
|
1910
|
+
createParserConfig(true, filesTypeAware, ignoresTypeAware)
|
|
1911
|
+
] : [createParserConfig(false, [GLOB_TS, GLOB_TSX])],
|
|
1912
|
+
{
|
|
1913
|
+
name: "ntnyq/ts/rules",
|
|
1914
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
1915
|
+
rules: {
|
|
1916
|
+
...recommendedRules,
|
|
1917
|
+
// Disabled in favor of ts rules
|
|
1918
|
+
"no-redeclare": "off",
|
|
1919
|
+
"no-use-before-define": "off",
|
|
1920
|
+
"no-unused-vars": "off",
|
|
1921
|
+
"@typescript-eslint/no-redeclare": [
|
|
1922
|
+
"error",
|
|
1923
|
+
{
|
|
1924
|
+
builtinGlobals: false,
|
|
1925
|
+
ignoreDeclarationMerge: true
|
|
1926
|
+
}
|
|
1927
|
+
],
|
|
1928
|
+
"@typescript-eslint/no-use-before-define": [
|
|
1929
|
+
"error",
|
|
1930
|
+
{
|
|
1931
|
+
functions: false,
|
|
1932
|
+
classes: false,
|
|
1933
|
+
variables: true,
|
|
1934
|
+
allowNamedExports: false,
|
|
1935
|
+
enums: true,
|
|
1936
|
+
typedefs: false,
|
|
1937
|
+
ignoreTypeReferences: false
|
|
1938
|
+
}
|
|
1939
|
+
],
|
|
1940
|
+
"@typescript-eslint/no-unused-vars": [
|
|
1941
|
+
"error",
|
|
1942
|
+
{
|
|
1943
|
+
// Args after the last used will be reported
|
|
1944
|
+
args: "after-used",
|
|
1945
|
+
argsIgnorePattern: "^_",
|
|
1946
|
+
caughtErrors: "all",
|
|
1947
|
+
caughtErrorsIgnorePattern: "^_",
|
|
1948
|
+
destructuredArrayIgnorePattern: "^_",
|
|
1949
|
+
varsIgnorePattern: "^_",
|
|
1950
|
+
ignoreRestSiblings: true
|
|
1951
|
+
}
|
|
1952
|
+
],
|
|
1953
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
1954
|
+
"error",
|
|
1955
|
+
{
|
|
1956
|
+
allowShortCircuit: true,
|
|
1957
|
+
allowTernary: true,
|
|
1958
|
+
allowTaggedTemplates: true
|
|
1959
|
+
}
|
|
1960
|
+
],
|
|
1961
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
1962
|
+
"error",
|
|
1963
|
+
{
|
|
1964
|
+
prefer: "type-imports",
|
|
1965
|
+
fixStyle: "separate-type-imports",
|
|
1966
|
+
disallowTypeAnnotations: false
|
|
1967
|
+
}
|
|
1968
|
+
],
|
|
1969
|
+
"@typescript-eslint/no-empty-object-type": [
|
|
1970
|
+
"error",
|
|
1971
|
+
{
|
|
1972
|
+
allowInterfaces: "always",
|
|
1973
|
+
allowObjectTypes: "always"
|
|
1974
|
+
}
|
|
1975
|
+
],
|
|
1976
|
+
"@typescript-eslint/consistent-type-assertions": [
|
|
1977
|
+
"error",
|
|
1978
|
+
{
|
|
1979
|
+
assertionStyle: "as",
|
|
1980
|
+
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
1981
|
+
}
|
|
1982
|
+
],
|
|
1983
|
+
"@typescript-eslint/prefer-as-const": "warn",
|
|
1984
|
+
"@typescript-eslint/no-namespace": "off",
|
|
1985
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
1986
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
1987
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
1988
|
+
"@typescript-eslint/naming-convention": "off",
|
|
1989
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
1990
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
1991
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
1992
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1993
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
1994
|
+
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
1995
|
+
// Overrides rules
|
|
1996
|
+
...options.overrides
|
|
1997
|
+
}
|
|
1998
|
+
},
|
|
1999
|
+
...enableTypeAwareLint ? [
|
|
2000
|
+
{
|
|
2001
|
+
name: "ntnyq/ts/rules/type-aware",
|
|
2002
|
+
files: [...filesTypeAware],
|
|
2003
|
+
ignores: [...ignoresTypeAware],
|
|
2004
|
+
rules: {
|
|
2005
|
+
...typeAwareRules,
|
|
2006
|
+
// Overrides type aware rules
|
|
2007
|
+
...overridesTypeAwareRules
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
] : [],
|
|
2011
|
+
{
|
|
2012
|
+
name: "ntnyq/ts/types",
|
|
2013
|
+
files: [GLOB_DTS, "**/types/**/*.ts"],
|
|
2014
|
+
rules: {
|
|
2015
|
+
"no-use-before-define": "off",
|
|
2016
|
+
"no-restricted-syntax": "off",
|
|
2017
|
+
"import/no-duplicates": "off",
|
|
2018
|
+
"import/newline-after-import": "off",
|
|
2019
|
+
"@typescript-eslint/no-use-before-define": "off"
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
];
|
|
2023
|
+
};
|
|
2024
|
+
|
|
1943
2025
|
// src/configs/githubAction.ts
|
|
1944
2026
|
var githubAction = (options = {}) => [
|
|
1945
2027
|
{
|
|
1946
2028
|
name: "ntnyq/github-action",
|
|
1947
2029
|
files: [GLOB_GITHUB_ACTION],
|
|
1948
2030
|
plugins: {
|
|
1949
|
-
"github-action":
|
|
2031
|
+
"github-action": default18
|
|
1950
2032
|
},
|
|
1951
2033
|
rules: {
|
|
1952
2034
|
"github-action/require-action-name": "error",
|
|
@@ -1961,7 +2043,7 @@ var perfectionist = (options = {}) => [
|
|
|
1961
2043
|
{
|
|
1962
2044
|
name: "ntnyq/perfectionist",
|
|
1963
2045
|
plugins: {
|
|
1964
|
-
perfectionist:
|
|
2046
|
+
perfectionist: default19
|
|
1965
2047
|
},
|
|
1966
2048
|
rules: {
|
|
1967
2049
|
"perfectionist/sort-imports": [
|
|
@@ -2047,7 +2129,7 @@ var unusedImports = (options = {}) => [
|
|
|
2047
2129
|
{
|
|
2048
2130
|
name: "ntnyq/unused-imports",
|
|
2049
2131
|
plugins: {
|
|
2050
|
-
"unused-imports":
|
|
2132
|
+
"unused-imports": default20
|
|
2051
2133
|
},
|
|
2052
2134
|
rules: {
|
|
2053
2135
|
"@typescript-eslint/no-unused-vars": "off",
|
|
@@ -2072,7 +2154,7 @@ var unusedImports = (options = {}) => [
|
|
|
2072
2154
|
];
|
|
2073
2155
|
|
|
2074
2156
|
// src/core.ts
|
|
2075
|
-
function defineESLintConfig(options = {}, userConfigs
|
|
2157
|
+
async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
2076
2158
|
const configs2 = [];
|
|
2077
2159
|
if (options.gitignore ?? true) {
|
|
2078
2160
|
configs2.push(
|
|
@@ -2087,9 +2169,18 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2087
2169
|
...node({
|
|
2088
2170
|
overrides: getOverrides(options, "node")
|
|
2089
2171
|
}),
|
|
2172
|
+
...command({
|
|
2173
|
+
...resolveSubOptions(options, "command")
|
|
2174
|
+
}),
|
|
2090
2175
|
...imports({
|
|
2091
2176
|
overrides: getOverrides(options, "imports")
|
|
2092
2177
|
}),
|
|
2178
|
+
...jsdoc({
|
|
2179
|
+
overrides: getOverrides(options, "jsdoc")
|
|
2180
|
+
}),
|
|
2181
|
+
...comments({
|
|
2182
|
+
overrides: getOverrides(options, "comments")
|
|
2183
|
+
}),
|
|
2093
2184
|
...javascript({
|
|
2094
2185
|
...resolveSubOptions(options, "javascript"),
|
|
2095
2186
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2118,20 +2209,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2118
2209
|
})
|
|
2119
2210
|
);
|
|
2120
2211
|
}
|
|
2121
|
-
if (options.jsdoc ?? true) {
|
|
2122
|
-
configs2.push(
|
|
2123
|
-
...jsdoc({
|
|
2124
|
-
overrides: getOverrides(options, "jsdoc")
|
|
2125
|
-
})
|
|
2126
|
-
);
|
|
2127
|
-
}
|
|
2128
|
-
if (options.comments ?? true) {
|
|
2129
|
-
configs2.push(
|
|
2130
|
-
...comments({
|
|
2131
|
-
overrides: getOverrides(options, "comments")
|
|
2132
|
-
})
|
|
2133
|
-
);
|
|
2134
|
-
}
|
|
2135
2212
|
if (options.typescript ?? hasTypeScript) {
|
|
2136
2213
|
configs2.push(
|
|
2137
2214
|
...typescript({
|
|
@@ -2200,17 +2277,17 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2200
2277
|
})
|
|
2201
2278
|
);
|
|
2202
2279
|
}
|
|
2203
|
-
if (options.
|
|
2280
|
+
if (options.antfu ?? true) {
|
|
2204
2281
|
configs2.push(
|
|
2205
|
-
...
|
|
2206
|
-
|
|
2282
|
+
...antfu({
|
|
2283
|
+
overrides: getOverrides(options, "antfu")
|
|
2207
2284
|
})
|
|
2208
2285
|
);
|
|
2209
2286
|
}
|
|
2210
|
-
if (options.
|
|
2287
|
+
if (options.stylistic ?? true) {
|
|
2211
2288
|
configs2.push(
|
|
2212
|
-
...
|
|
2213
|
-
overrides: getOverrides(options, "
|
|
2289
|
+
...stylistic({
|
|
2290
|
+
overrides: getOverrides(options, "stylistic")
|
|
2214
2291
|
})
|
|
2215
2292
|
);
|
|
2216
2293
|
}
|
|
@@ -2227,9 +2304,9 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2227
2304
|
overrides: getOverrides(options, "prettier")
|
|
2228
2305
|
}) : [];
|
|
2229
2306
|
const composer = new FlatConfigComposer();
|
|
2230
|
-
composer.append(
|
|
2307
|
+
await composer.append(
|
|
2231
2308
|
...configs2,
|
|
2232
|
-
...
|
|
2309
|
+
...userConfigs,
|
|
2233
2310
|
...configSpecials,
|
|
2234
2311
|
...configPrettier
|
|
2235
2312
|
);
|
|
@@ -2239,6 +2316,7 @@ export {
|
|
|
2239
2316
|
DEFAULT_PRETTIER_OPTIONS,
|
|
2240
2317
|
GLOB_ALL_SRC,
|
|
2241
2318
|
GLOB_ASTRO,
|
|
2319
|
+
GLOB_ASTRO_TS,
|
|
2242
2320
|
GLOB_CSS,
|
|
2243
2321
|
GLOB_DIST,
|
|
2244
2322
|
GLOB_DTS,
|
|
@@ -2271,7 +2349,6 @@ export {
|
|
|
2271
2349
|
antfu,
|
|
2272
2350
|
command,
|
|
2273
2351
|
comments,
|
|
2274
|
-
config as createTypeScriptConfig,
|
|
2275
2352
|
defineESLintConfig,
|
|
2276
2353
|
format,
|
|
2277
2354
|
getOverrides,
|
|
@@ -2302,39 +2379,40 @@ export {
|
|
|
2302
2379
|
parserYaml,
|
|
2303
2380
|
perfectionist,
|
|
2304
2381
|
default8 as pluginAntfu,
|
|
2305
|
-
|
|
2382
|
+
default21 as pluginComments,
|
|
2306
2383
|
default11 as pluginFormat,
|
|
2307
|
-
|
|
2384
|
+
default18 as pluginGitHubAction,
|
|
2308
2385
|
default14 as pluginImport,
|
|
2309
2386
|
default9 as pluginJsdoc,
|
|
2310
2387
|
default10 as pluginJsonc,
|
|
2311
2388
|
default7 as pluginMarkdown,
|
|
2312
2389
|
default2 as pluginNode,
|
|
2313
2390
|
default6 as pluginNtnyq,
|
|
2314
|
-
|
|
2391
|
+
default19 as pluginPerfectionist,
|
|
2315
2392
|
default16 as pluginPrettier,
|
|
2316
2393
|
pluginRegexp,
|
|
2394
|
+
default17 as pluginStylistic,
|
|
2317
2395
|
default5 as pluginToml,
|
|
2318
2396
|
plugin as pluginTypeScript,
|
|
2319
2397
|
default15 as pluginUnicorn,
|
|
2320
2398
|
default12 as pluginUnoCSS,
|
|
2321
|
-
|
|
2399
|
+
default20 as pluginUnusedImports,
|
|
2322
2400
|
default13 as pluginVitest,
|
|
2323
2401
|
default3 as pluginVue,
|
|
2324
2402
|
default4 as pluginYaml,
|
|
2325
2403
|
prettier,
|
|
2326
2404
|
processorPassThrough,
|
|
2327
|
-
|
|
2405
|
+
default22 as processorVueBlocks,
|
|
2328
2406
|
regexp,
|
|
2329
2407
|
resolveSubOptions,
|
|
2330
2408
|
sort,
|
|
2331
2409
|
specials,
|
|
2410
|
+
stylistic,
|
|
2332
2411
|
test,
|
|
2333
2412
|
toArray,
|
|
2334
2413
|
toml,
|
|
2335
2414
|
typescript,
|
|
2336
2415
|
configs as typescriptConfigs,
|
|
2337
|
-
typescriptCore,
|
|
2338
2416
|
unicorn,
|
|
2339
2417
|
unocss,
|
|
2340
2418
|
unusedImports,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.4.0",
|
|
5
5
|
"packageManager": "pnpm@9.14.2",
|
|
6
6
|
"description": "An opinionated ESLint config preset of ntnyq",
|
|
7
7
|
"keywords": [
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
59
59
|
"@eslint/js": "^9.15.0",
|
|
60
60
|
"@eslint/markdown": "^6.2.1",
|
|
61
|
+
"@stylistic/eslint-plugin": "^2.11.0",
|
|
61
62
|
"@unocss/eslint-plugin": "^0.64.1",
|
|
62
63
|
"@vitest/eslint-plugin": "^1.1.10",
|
|
63
64
|
"eslint-config-flat-gitignore": "^0.3.0",
|
|
@@ -66,12 +67,12 @@
|
|
|
66
67
|
"eslint-plugin-antfu": "^2.7.0",
|
|
67
68
|
"eslint-plugin-command": "^0.2.6",
|
|
68
69
|
"eslint-plugin-format": "^0.1.2",
|
|
69
|
-
"eslint-plugin-github-action": "^0.0.
|
|
70
|
+
"eslint-plugin-github-action": "^0.0.4",
|
|
70
71
|
"eslint-plugin-import-x": "^4.4.3",
|
|
71
72
|
"eslint-plugin-jsdoc": "^50.5.0",
|
|
72
73
|
"eslint-plugin-jsonc": "^2.18.2",
|
|
73
|
-
"eslint-plugin-n": "^17.
|
|
74
|
-
"eslint-plugin-ntnyq": "^0.
|
|
74
|
+
"eslint-plugin-n": "^17.14.0",
|
|
75
|
+
"eslint-plugin-ntnyq": "^0.7.0",
|
|
75
76
|
"eslint-plugin-perfectionist": "^4.0.3",
|
|
76
77
|
"eslint-plugin-prettier": "^5.2.1",
|
|
77
78
|
"eslint-plugin-regexp": "^2.7.0",
|
|
@@ -91,8 +92,8 @@
|
|
|
91
92
|
"yaml-eslint-parser": "^1.2.3"
|
|
92
93
|
},
|
|
93
94
|
"devDependencies": {
|
|
94
|
-
"@ntnyq/prettier-config": "^1.
|
|
95
|
-
"@types/node": "^22.9.
|
|
95
|
+
"@ntnyq/prettier-config": "^1.22.0",
|
|
96
|
+
"@types/node": "^22.9.3",
|
|
96
97
|
"bumpp": "^9.8.1",
|
|
97
98
|
"eslint": "^9.15.0",
|
|
98
99
|
"eslint-typegen": "^0.3.2",
|
|
@@ -103,7 +104,7 @@
|
|
|
103
104
|
"rimraf": "^6.0.1",
|
|
104
105
|
"tsup": "^8.3.5",
|
|
105
106
|
"tsx": "^4.19.2",
|
|
106
|
-
"typescript": "^5.
|
|
107
|
+
"typescript": "^5.7.2",
|
|
107
108
|
"zx": "^8.2.2"
|
|
108
109
|
},
|
|
109
110
|
"engines": {
|