@ntnyq/eslint-config 3.3.1 → 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 +10 -10
- package/dist/index.cjs +223 -172
- package/dist/index.d.cts +36 -14
- package/dist/index.d.ts +36 -14
- package/dist/index.js +215 -163
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,20 +109,24 @@ Check for detail in:
|
|
|
109
109
|
|
|
110
110
|
```ts
|
|
111
111
|
export interface ConfigOptions extends ConfigOptionsInternal {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
sort?: boolean | ConfigSortOptions
|
|
112
|
+
node?: ConfigNodeOptions
|
|
115
113
|
|
|
116
|
-
|
|
114
|
+
jsdoc?: ConfigJsdocOptions
|
|
117
115
|
|
|
118
|
-
|
|
116
|
+
ignores?: ConfigIgnoresOptions
|
|
119
117
|
|
|
120
118
|
imports?: ConfigImportsOptions
|
|
121
119
|
|
|
122
|
-
|
|
120
|
+
command?: ConfigCommandOptions
|
|
121
|
+
|
|
122
|
+
comments?: ConfigCommentsOptions
|
|
123
123
|
|
|
124
124
|
javascript?: ConfigJavaScriptOptions
|
|
125
125
|
|
|
126
|
+
sort?: boolean | ConfigSortOptions
|
|
127
|
+
|
|
128
|
+
gitignore?: boolean | ConfigGitIgnoreOptions
|
|
129
|
+
|
|
126
130
|
stylistic?: boolean | ConfigStylisticOptions
|
|
127
131
|
|
|
128
132
|
typescript?: boolean | ConfigTypeScriptOptions
|
|
@@ -133,10 +137,6 @@ export interface ConfigOptions extends ConfigOptionsInternal {
|
|
|
133
137
|
|
|
134
138
|
perfectionist?: boolean | ConfigPerfectionistOptions
|
|
135
139
|
|
|
136
|
-
comments?: boolean | ConfigCommentsOptions
|
|
137
|
-
|
|
138
|
-
jsdoc?: boolean | ConfigJsdocOptions
|
|
139
|
-
|
|
140
140
|
unocss?: boolean | ConfigUnoCSSOptions
|
|
141
141
|
|
|
142
142
|
regexp?: boolean | ConfigRegexpOptions
|
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: () =>
|
|
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: () =>
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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":
|
|
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:
|
|
514
|
+
parser: parserTypeScript,
|
|
643
515
|
ecmaFeatures: {
|
|
644
516
|
jsx: true
|
|
645
517
|
}
|
|
@@ -1293,9 +1165,9 @@ var ntnyq = (options = {}) => [
|
|
|
1293
1165
|
|
|
1294
1166
|
// src/configs/regexp.ts
|
|
1295
1167
|
var regexp = (options = {}) => {
|
|
1296
|
-
const
|
|
1168
|
+
const config = pluginRegexp.configs["flat/recommended"];
|
|
1297
1169
|
const rules = {
|
|
1298
|
-
...
|
|
1170
|
+
...config.rules
|
|
1299
1171
|
};
|
|
1300
1172
|
if (options.level === "warn") {
|
|
1301
1173
|
for (const key in rules) {
|
|
@@ -1306,7 +1178,7 @@ var regexp = (options = {}) => {
|
|
|
1306
1178
|
}
|
|
1307
1179
|
return [
|
|
1308
1180
|
{
|
|
1309
|
-
...
|
|
1181
|
+
...config,
|
|
1310
1182
|
name: "ntnyq/regexp",
|
|
1311
1183
|
rules: {
|
|
1312
1184
|
...rules,
|
|
@@ -1385,12 +1257,12 @@ var DEFAULT_PRETTIER_OPTIONS = {
|
|
|
1385
1257
|
|
|
1386
1258
|
// src/utils/env.ts
|
|
1387
1259
|
var import_node_path = require("path");
|
|
1388
|
-
var
|
|
1260
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
1389
1261
|
var import_local_pkg = require("local-pkg");
|
|
1390
1262
|
var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
|
|
1391
1263
|
var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
|
|
1392
1264
|
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)(
|
|
1265
|
+
paths: [(0, import_node_path.resolve)(import_node_process.default.cwd(), "playground")]
|
|
1394
1266
|
});
|
|
1395
1267
|
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
1268
|
|
|
@@ -1731,9 +1603,9 @@ var comments = (options = {}) => [
|
|
|
1731
1603
|
var markdown = (options = {}) => {
|
|
1732
1604
|
if (!Array.isArray(import_markdown.default.configs?.processor)) return [];
|
|
1733
1605
|
return [
|
|
1734
|
-
...import_markdown.default.configs.processor.map((
|
|
1735
|
-
...
|
|
1736
|
-
name: `ntnyq/${
|
|
1606
|
+
...import_markdown.default.configs.processor.map((config) => ({
|
|
1607
|
+
...config,
|
|
1608
|
+
name: `ntnyq/${config.name}`
|
|
1737
1609
|
})),
|
|
1738
1610
|
{
|
|
1739
1611
|
name: "ntnyq/markdown/disabled/code-blocks",
|
|
@@ -2099,6 +1971,198 @@ var jsx = () => [
|
|
|
2099
1971
|
}
|
|
2100
1972
|
];
|
|
2101
1973
|
|
|
1974
|
+
// src/configs/typescript.ts
|
|
1975
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
1976
|
+
var typeAwareRules = {
|
|
1977
|
+
"dot-notation": "off",
|
|
1978
|
+
"require-await": "off",
|
|
1979
|
+
"no-implied-eval": "off",
|
|
1980
|
+
"no-throw-literal": "off",
|
|
1981
|
+
// too strict
|
|
1982
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
1983
|
+
"@typescript-eslint/require-await": "error",
|
|
1984
|
+
"@typescript-eslint/unbound-method": "error",
|
|
1985
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
1986
|
+
"@typescript-eslint/await-thenable": "error",
|
|
1987
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
1988
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
1989
|
+
"@typescript-eslint/only-throw-error": "error",
|
|
1990
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
1991
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
1992
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
1993
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
1994
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
1995
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
1996
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
1997
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
1998
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
1999
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
2000
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
2001
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
2002
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
2003
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
2004
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
2005
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }]
|
|
2006
|
+
};
|
|
2007
|
+
var recommendedRules = import_typescript_eslint3.configs.recommended.reduce((rules, config) => {
|
|
2008
|
+
return { ...rules, ...config.rules || {} };
|
|
2009
|
+
}, {});
|
|
2010
|
+
var typescript = (options = {}) => {
|
|
2011
|
+
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
2012
|
+
const {
|
|
2013
|
+
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
2014
|
+
ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`],
|
|
2015
|
+
overridesTypeAwareRules = {},
|
|
2016
|
+
parserOptions = {}
|
|
2017
|
+
} = options;
|
|
2018
|
+
function createParserConfig(enableTypeAware = false, files = [], ignores2 = []) {
|
|
2019
|
+
const parserConfig = {
|
|
2020
|
+
name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
2021
|
+
files,
|
|
2022
|
+
ignores: [...ignores2],
|
|
2023
|
+
languageOptions: {
|
|
2024
|
+
parser: parserTypeScript,
|
|
2025
|
+
parserOptions: {
|
|
2026
|
+
// extraFileExtensions: [''],
|
|
2027
|
+
sourceType: "module",
|
|
2028
|
+
...enableTypeAware ? {
|
|
2029
|
+
projectService: {
|
|
2030
|
+
allowDefaultProject: ["./*.js"],
|
|
2031
|
+
defaultProject: options.tsconfigPath
|
|
2032
|
+
},
|
|
2033
|
+
tsconfigRootDir: import_node_process2.default.cwd()
|
|
2034
|
+
} : {},
|
|
2035
|
+
...parserOptions
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
return parserConfig;
|
|
2040
|
+
}
|
|
2041
|
+
return [
|
|
2042
|
+
{
|
|
2043
|
+
name: "ntnyq/ts/setup",
|
|
2044
|
+
plugins: {
|
|
2045
|
+
"@typescript-eslint": import_typescript_eslint2.plugin,
|
|
2046
|
+
antfu: import_eslint_plugin_antfu.default
|
|
2047
|
+
}
|
|
2048
|
+
},
|
|
2049
|
+
...enableTypeAwareLint ? [
|
|
2050
|
+
createParserConfig(false, [GLOB_TS, GLOB_TSX]),
|
|
2051
|
+
createParserConfig(true, filesTypeAware, ignoresTypeAware)
|
|
2052
|
+
] : [createParserConfig(false, [GLOB_TS, GLOB_TSX])],
|
|
2053
|
+
{
|
|
2054
|
+
name: "ntnyq/ts/rules",
|
|
2055
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
2056
|
+
rules: {
|
|
2057
|
+
...recommendedRules,
|
|
2058
|
+
// Disabled in favor of ts rules
|
|
2059
|
+
"no-redeclare": "off",
|
|
2060
|
+
"no-use-before-define": "off",
|
|
2061
|
+
"no-unused-vars": "off",
|
|
2062
|
+
"@typescript-eslint/no-redeclare": [
|
|
2063
|
+
"error",
|
|
2064
|
+
{
|
|
2065
|
+
builtinGlobals: false,
|
|
2066
|
+
ignoreDeclarationMerge: true
|
|
2067
|
+
}
|
|
2068
|
+
],
|
|
2069
|
+
"@typescript-eslint/no-use-before-define": [
|
|
2070
|
+
"error",
|
|
2071
|
+
{
|
|
2072
|
+
functions: false,
|
|
2073
|
+
classes: false,
|
|
2074
|
+
variables: true,
|
|
2075
|
+
allowNamedExports: false,
|
|
2076
|
+
enums: true,
|
|
2077
|
+
typedefs: false,
|
|
2078
|
+
ignoreTypeReferences: false
|
|
2079
|
+
}
|
|
2080
|
+
],
|
|
2081
|
+
"@typescript-eslint/no-unused-vars": [
|
|
2082
|
+
"error",
|
|
2083
|
+
{
|
|
2084
|
+
// Args after the last used will be reported
|
|
2085
|
+
args: "after-used",
|
|
2086
|
+
argsIgnorePattern: "^_",
|
|
2087
|
+
caughtErrors: "all",
|
|
2088
|
+
caughtErrorsIgnorePattern: "^_",
|
|
2089
|
+
destructuredArrayIgnorePattern: "^_",
|
|
2090
|
+
varsIgnorePattern: "^_",
|
|
2091
|
+
ignoreRestSiblings: true
|
|
2092
|
+
}
|
|
2093
|
+
],
|
|
2094
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
2095
|
+
"error",
|
|
2096
|
+
{
|
|
2097
|
+
allowShortCircuit: true,
|
|
2098
|
+
allowTernary: true,
|
|
2099
|
+
allowTaggedTemplates: true
|
|
2100
|
+
}
|
|
2101
|
+
],
|
|
2102
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
2103
|
+
"error",
|
|
2104
|
+
{
|
|
2105
|
+
prefer: "type-imports",
|
|
2106
|
+
fixStyle: "separate-type-imports",
|
|
2107
|
+
disallowTypeAnnotations: false
|
|
2108
|
+
}
|
|
2109
|
+
],
|
|
2110
|
+
"@typescript-eslint/no-empty-object-type": [
|
|
2111
|
+
"error",
|
|
2112
|
+
{
|
|
2113
|
+
allowInterfaces: "always",
|
|
2114
|
+
allowObjectTypes: "always"
|
|
2115
|
+
}
|
|
2116
|
+
],
|
|
2117
|
+
"@typescript-eslint/consistent-type-assertions": [
|
|
2118
|
+
"error",
|
|
2119
|
+
{
|
|
2120
|
+
assertionStyle: "as",
|
|
2121
|
+
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
2122
|
+
}
|
|
2123
|
+
],
|
|
2124
|
+
"@typescript-eslint/prefer-as-const": "warn",
|
|
2125
|
+
"@typescript-eslint/no-namespace": "off",
|
|
2126
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
2127
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
2128
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
2129
|
+
"@typescript-eslint/naming-convention": "off",
|
|
2130
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
2131
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
2132
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
2133
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2134
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
2135
|
+
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
2136
|
+
// Overrides rules
|
|
2137
|
+
...options.overrides
|
|
2138
|
+
}
|
|
2139
|
+
},
|
|
2140
|
+
...enableTypeAwareLint ? [
|
|
2141
|
+
{
|
|
2142
|
+
name: "ntnyq/ts/rules/type-aware",
|
|
2143
|
+
files: [...filesTypeAware],
|
|
2144
|
+
ignores: [...ignoresTypeAware],
|
|
2145
|
+
rules: {
|
|
2146
|
+
...typeAwareRules,
|
|
2147
|
+
// Overrides type aware rules
|
|
2148
|
+
...overridesTypeAwareRules
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
] : [],
|
|
2152
|
+
{
|
|
2153
|
+
name: "ntnyq/ts/types",
|
|
2154
|
+
files: [GLOB_DTS, "**/types/**/*.ts"],
|
|
2155
|
+
rules: {
|
|
2156
|
+
"no-use-before-define": "off",
|
|
2157
|
+
"no-restricted-syntax": "off",
|
|
2158
|
+
"import/no-duplicates": "off",
|
|
2159
|
+
"import/newline-after-import": "off",
|
|
2160
|
+
"@typescript-eslint/no-use-before-define": "off"
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
];
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2102
2166
|
// src/configs/githubAction.ts
|
|
2103
2167
|
var githubAction = (options = {}) => [
|
|
2104
2168
|
{
|
|
@@ -2231,7 +2295,7 @@ var unusedImports = (options = {}) => [
|
|
|
2231
2295
|
];
|
|
2232
2296
|
|
|
2233
2297
|
// src/core.ts
|
|
2234
|
-
function defineESLintConfig(options = {}, userConfigs
|
|
2298
|
+
async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
2235
2299
|
const configs2 = [];
|
|
2236
2300
|
if (options.gitignore ?? true) {
|
|
2237
2301
|
configs2.push(
|
|
@@ -2246,9 +2310,18 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2246
2310
|
...node({
|
|
2247
2311
|
overrides: getOverrides(options, "node")
|
|
2248
2312
|
}),
|
|
2313
|
+
...command({
|
|
2314
|
+
...resolveSubOptions(options, "command")
|
|
2315
|
+
}),
|
|
2249
2316
|
...imports({
|
|
2250
2317
|
overrides: getOverrides(options, "imports")
|
|
2251
2318
|
}),
|
|
2319
|
+
...jsdoc({
|
|
2320
|
+
overrides: getOverrides(options, "jsdoc")
|
|
2321
|
+
}),
|
|
2322
|
+
...comments({
|
|
2323
|
+
overrides: getOverrides(options, "comments")
|
|
2324
|
+
}),
|
|
2252
2325
|
...javascript({
|
|
2253
2326
|
...resolveSubOptions(options, "javascript"),
|
|
2254
2327
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2277,20 +2350,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2277
2350
|
})
|
|
2278
2351
|
);
|
|
2279
2352
|
}
|
|
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
2353
|
if (options.typescript ?? hasTypeScript) {
|
|
2295
2354
|
configs2.push(
|
|
2296
2355
|
...typescript({
|
|
@@ -2359,13 +2418,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2359
2418
|
})
|
|
2360
2419
|
);
|
|
2361
2420
|
}
|
|
2362
|
-
if (options.command ?? true) {
|
|
2363
|
-
configs2.push(
|
|
2364
|
-
...command({
|
|
2365
|
-
...resolveSubOptions(options, "command")
|
|
2366
|
-
})
|
|
2367
|
-
);
|
|
2368
|
-
}
|
|
2369
2421
|
if (options.antfu ?? true) {
|
|
2370
2422
|
configs2.push(
|
|
2371
2423
|
...antfu({
|
|
@@ -2393,9 +2445,9 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2393
2445
|
overrides: getOverrides(options, "prettier")
|
|
2394
2446
|
}) : [];
|
|
2395
2447
|
const composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
2396
|
-
composer.append(
|
|
2448
|
+
await composer.append(
|
|
2397
2449
|
...configs2,
|
|
2398
|
-
...
|
|
2450
|
+
...userConfigs,
|
|
2399
2451
|
...configSpecials,
|
|
2400
2452
|
...configPrettier
|
|
2401
2453
|
);
|
|
@@ -2406,6 +2458,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2406
2458
|
DEFAULT_PRETTIER_OPTIONS,
|
|
2407
2459
|
GLOB_ALL_SRC,
|
|
2408
2460
|
GLOB_ASTRO,
|
|
2461
|
+
GLOB_ASTRO_TS,
|
|
2409
2462
|
GLOB_CSS,
|
|
2410
2463
|
GLOB_DIST,
|
|
2411
2464
|
GLOB_DTS,
|
|
@@ -2438,7 +2491,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2438
2491
|
antfu,
|
|
2439
2492
|
command,
|
|
2440
2493
|
comments,
|
|
2441
|
-
createTypeScriptConfig,
|
|
2442
2494
|
defineESLintConfig,
|
|
2443
2495
|
format,
|
|
2444
2496
|
getOverrides,
|
|
@@ -2503,7 +2555,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2503
2555
|
toml,
|
|
2504
2556
|
typescript,
|
|
2505
2557
|
typescriptConfigs,
|
|
2506
|
-
typescriptCore,
|
|
2507
2558
|
unicorn,
|
|
2508
2559
|
unocss,
|
|
2509
2560
|
unusedImports,
|