@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/README.md
CHANGED
|
@@ -109,20 +109,26 @@ 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
|
+
|
|
130
|
+
stylistic?: boolean | ConfigStylisticOptions
|
|
131
|
+
|
|
126
132
|
typescript?: boolean | ConfigTypeScriptOptions
|
|
127
133
|
|
|
128
134
|
unicorn?: boolean | ConfigUnicornOptions
|
|
@@ -131,10 +137,6 @@ export interface ConfigOptions extends ConfigOptionsInternal {
|
|
|
131
137
|
|
|
132
138
|
perfectionist?: boolean | ConfigPerfectionistOptions
|
|
133
139
|
|
|
134
|
-
comments?: boolean | ConfigCommentsOptions
|
|
135
|
-
|
|
136
|
-
jsdoc?: boolean | ConfigJsdocOptions
|
|
137
|
-
|
|
138
140
|
unocss?: boolean | ConfigUnoCSSOptions
|
|
139
141
|
|
|
140
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,
|
|
@@ -108,8 +108,9 @@ __export(src_exports, {
|
|
|
108
108
|
pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
|
|
109
109
|
pluginPrettier: () => import_eslint_plugin_prettier.default,
|
|
110
110
|
pluginRegexp: () => pluginRegexp,
|
|
111
|
+
pluginStylistic: () => import_eslint_plugin3.default,
|
|
111
112
|
pluginToml: () => import_eslint_plugin_toml.default,
|
|
112
|
-
pluginTypeScript: () =>
|
|
113
|
+
pluginTypeScript: () => import_typescript_eslint2.plugin,
|
|
113
114
|
pluginUnicorn: () => import_eslint_plugin_unicorn.default,
|
|
114
115
|
pluginUnoCSS: () => import_eslint_plugin.default,
|
|
115
116
|
pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
|
|
@@ -123,12 +124,12 @@ __export(src_exports, {
|
|
|
123
124
|
resolveSubOptions: () => resolveSubOptions,
|
|
124
125
|
sort: () => sort,
|
|
125
126
|
specials: () => specials,
|
|
127
|
+
stylistic: () => stylistic,
|
|
126
128
|
test: () => test,
|
|
127
129
|
toArray: () => toArray,
|
|
128
130
|
toml: () => toml,
|
|
129
131
|
typescript: () => typescript,
|
|
130
|
-
typescriptConfigs: () =>
|
|
131
|
-
typescriptCore: () => typescriptCore,
|
|
132
|
+
typescriptConfigs: () => import_typescript_eslint3.configs,
|
|
132
133
|
unicorn: () => unicorn,
|
|
133
134
|
unocss: () => unocss,
|
|
134
135
|
unusedImports: () => unusedImports,
|
|
@@ -144,16 +145,13 @@ var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
|
144
145
|
// src/configs/vue.ts
|
|
145
146
|
var import_eslint_merge_processors3 = require("eslint-merge-processors");
|
|
146
147
|
|
|
147
|
-
// src/eslint/utils.ts
|
|
148
|
-
var import_typescript_eslint = require("typescript-eslint");
|
|
149
|
-
|
|
150
148
|
// src/eslint/parsers.ts
|
|
151
|
-
var
|
|
149
|
+
var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
|
|
152
150
|
var parserVue = __toESM(require("vue-eslint-parser"), 1);
|
|
153
151
|
var parserToml = __toESM(require("toml-eslint-parser"), 1);
|
|
154
152
|
var parserYaml = __toESM(require("yaml-eslint-parser"), 1);
|
|
155
153
|
var parserJsonc = __toESM(require("jsonc-eslint-parser"), 1);
|
|
156
|
-
var parserTypeScript =
|
|
154
|
+
var parserTypeScript = import_typescript_eslint.default.parser;
|
|
157
155
|
var parserPlain = {
|
|
158
156
|
meta: {
|
|
159
157
|
name: "plain-eslint-parser"
|
|
@@ -186,20 +184,21 @@ var import_markdown = __toESM(require("@eslint/markdown"), 1);
|
|
|
186
184
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
187
185
|
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
188
186
|
var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
189
|
-
var
|
|
187
|
+
var import_typescript_eslint2 = require("typescript-eslint");
|
|
190
188
|
var import_eslint_plugin_format = __toESM(require("eslint-plugin-format"), 1);
|
|
191
189
|
var import_eslint_plugin = __toESM(require("@unocss/eslint-plugin"), 1);
|
|
192
190
|
var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
|
|
193
191
|
var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
|
|
194
192
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
195
193
|
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
|
|
194
|
+
var import_eslint_plugin3 = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
196
195
|
var import_eslint_plugin_github_action = __toESM(require("eslint-plugin-github-action"), 1);
|
|
197
196
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
198
197
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
199
198
|
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
200
199
|
|
|
201
200
|
// src/eslint/configs.ts
|
|
202
|
-
var
|
|
201
|
+
var import_typescript_eslint3 = require("typescript-eslint");
|
|
203
202
|
|
|
204
203
|
// src/eslint/processors.ts
|
|
205
204
|
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
@@ -233,6 +232,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
|
|
|
233
232
|
var GLOB_TOML = "**/*.toml";
|
|
234
233
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
235
234
|
var GLOB_ASTRO = "**/*.astro";
|
|
235
|
+
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
236
236
|
var GLOB_SVELTE = "**/*.svelte";
|
|
237
237
|
var GLOB_MARKDOWN = "**/*.md";
|
|
238
238
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
@@ -303,126 +303,6 @@ var GLOB_EXCLUDE = [
|
|
|
303
303
|
"**/.yarnrc"
|
|
304
304
|
];
|
|
305
305
|
|
|
306
|
-
// src/configs/typescript.ts
|
|
307
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
308
|
-
var typescriptCore = (options = {}) => {
|
|
309
|
-
const isTypeAware = !!options.tsconfigPath;
|
|
310
|
-
const configs2 = (0, import_typescript_eslint.config)({
|
|
311
|
-
name: "ntnyq/ts/core",
|
|
312
|
-
extends: [...import_typescript_eslint4.configs.recommended],
|
|
313
|
-
files: [GLOB_TS, GLOB_TSX],
|
|
314
|
-
languageOptions: {
|
|
315
|
-
parser: parserTypeScript,
|
|
316
|
-
parserOptions: {
|
|
317
|
-
sourceType: "module",
|
|
318
|
-
...isTypeAware ? {
|
|
319
|
-
projectService: {
|
|
320
|
-
defaultProject: options.tsconfigPath
|
|
321
|
-
},
|
|
322
|
-
tsconfigRootDir: import_node_process.default.cwd()
|
|
323
|
-
} : {}
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
rules: {
|
|
327
|
-
// Disabled in favor of ts rules
|
|
328
|
-
"no-redeclare": "off",
|
|
329
|
-
"no-use-before-define": "off",
|
|
330
|
-
"no-unused-vars": "off",
|
|
331
|
-
"@typescript-eslint/no-redeclare": [
|
|
332
|
-
"error",
|
|
333
|
-
{
|
|
334
|
-
builtinGlobals: false,
|
|
335
|
-
ignoreDeclarationMerge: true
|
|
336
|
-
}
|
|
337
|
-
],
|
|
338
|
-
"@typescript-eslint/no-use-before-define": [
|
|
339
|
-
"error",
|
|
340
|
-
{
|
|
341
|
-
functions: false,
|
|
342
|
-
classes: false,
|
|
343
|
-
variables: true,
|
|
344
|
-
allowNamedExports: false,
|
|
345
|
-
enums: true,
|
|
346
|
-
typedefs: false,
|
|
347
|
-
ignoreTypeReferences: false
|
|
348
|
-
}
|
|
349
|
-
],
|
|
350
|
-
"@typescript-eslint/no-unused-vars": [
|
|
351
|
-
"error",
|
|
352
|
-
{
|
|
353
|
-
// Args after the last used will be reported
|
|
354
|
-
args: "after-used",
|
|
355
|
-
argsIgnorePattern: "^_",
|
|
356
|
-
caughtErrors: "all",
|
|
357
|
-
caughtErrorsIgnorePattern: "^_",
|
|
358
|
-
destructuredArrayIgnorePattern: "^_",
|
|
359
|
-
varsIgnorePattern: "^_",
|
|
360
|
-
ignoreRestSiblings: true
|
|
361
|
-
}
|
|
362
|
-
],
|
|
363
|
-
"@typescript-eslint/no-unused-expressions": [
|
|
364
|
-
"error",
|
|
365
|
-
{
|
|
366
|
-
allowShortCircuit: true,
|
|
367
|
-
allowTernary: true,
|
|
368
|
-
allowTaggedTemplates: true
|
|
369
|
-
}
|
|
370
|
-
],
|
|
371
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
372
|
-
"error",
|
|
373
|
-
{
|
|
374
|
-
prefer: "type-imports",
|
|
375
|
-
fixStyle: "separate-type-imports",
|
|
376
|
-
disallowTypeAnnotations: false
|
|
377
|
-
}
|
|
378
|
-
],
|
|
379
|
-
"@typescript-eslint/no-empty-object-type": [
|
|
380
|
-
"error",
|
|
381
|
-
{
|
|
382
|
-
allowInterfaces: "always",
|
|
383
|
-
allowObjectTypes: "always"
|
|
384
|
-
}
|
|
385
|
-
],
|
|
386
|
-
"@typescript-eslint/consistent-type-assertions": [
|
|
387
|
-
"error",
|
|
388
|
-
{
|
|
389
|
-
assertionStyle: "as",
|
|
390
|
-
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
391
|
-
}
|
|
392
|
-
],
|
|
393
|
-
"@typescript-eslint/prefer-as-const": "warn",
|
|
394
|
-
"@typescript-eslint/no-namespace": "off",
|
|
395
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
396
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
397
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
398
|
-
"@typescript-eslint/naming-convention": "off",
|
|
399
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
400
|
-
"@typescript-eslint/triple-slash-reference": "off",
|
|
401
|
-
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
402
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
403
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
404
|
-
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
405
|
-
// Overrides rules
|
|
406
|
-
...options.overrides
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
return configs2;
|
|
410
|
-
};
|
|
411
|
-
var typescript = (options = {}) => [
|
|
412
|
-
...typescriptCore(options),
|
|
413
|
-
{
|
|
414
|
-
name: "ntnyq/ts/types",
|
|
415
|
-
files: [GLOB_DTS, "**/types/**/*.ts"],
|
|
416
|
-
rules: {
|
|
417
|
-
"no-use-before-define": "off",
|
|
418
|
-
"no-restricted-syntax": "off",
|
|
419
|
-
"import/no-duplicates": "off",
|
|
420
|
-
"import/newline-after-import": "off",
|
|
421
|
-
"@typescript-eslint/no-use-before-define": "off"
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
];
|
|
425
|
-
|
|
426
306
|
// src/configs/vue.ts
|
|
427
307
|
var vue2Rules = {
|
|
428
308
|
...import_eslint_plugin_vue.default.configs.base.rules,
|
|
@@ -620,23 +500,18 @@ var vue = (options = {}) => {
|
|
|
620
500
|
const isVue3 = options.vueVersion !== 2;
|
|
621
501
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
622
502
|
return [
|
|
623
|
-
...(0, import_typescript_eslint.config)({
|
|
624
|
-
name: "ntnyq/vue/ts",
|
|
625
|
-
files: [GLOB_VUE],
|
|
626
|
-
extends: typescriptCore()
|
|
627
|
-
}),
|
|
628
503
|
{
|
|
629
504
|
name: "ntnyq/vue/setup",
|
|
630
505
|
plugins: {
|
|
631
506
|
vue: import_eslint_plugin_vue.default,
|
|
632
|
-
"@typescript-eslint":
|
|
507
|
+
"@typescript-eslint": import_typescript_eslint2.plugin
|
|
633
508
|
},
|
|
634
509
|
languageOptions: {
|
|
635
510
|
parserOptions: {
|
|
636
511
|
sourceType: "module",
|
|
637
512
|
ecmaVersion: "latest",
|
|
638
513
|
extraFileExtensions: [".vue"],
|
|
639
|
-
parser:
|
|
514
|
+
parser: parserTypeScript,
|
|
640
515
|
ecmaFeatures: {
|
|
641
516
|
jsx: true
|
|
642
517
|
}
|
|
@@ -1290,9 +1165,9 @@ var ntnyq = (options = {}) => [
|
|
|
1290
1165
|
|
|
1291
1166
|
// src/configs/regexp.ts
|
|
1292
1167
|
var regexp = (options = {}) => {
|
|
1293
|
-
const
|
|
1168
|
+
const config = pluginRegexp.configs["flat/recommended"];
|
|
1294
1169
|
const rules = {
|
|
1295
|
-
...
|
|
1170
|
+
...config.rules
|
|
1296
1171
|
};
|
|
1297
1172
|
if (options.level === "warn") {
|
|
1298
1173
|
for (const key in rules) {
|
|
@@ -1303,7 +1178,7 @@ var regexp = (options = {}) => {
|
|
|
1303
1178
|
}
|
|
1304
1179
|
return [
|
|
1305
1180
|
{
|
|
1306
|
-
...
|
|
1181
|
+
...config,
|
|
1307
1182
|
name: "ntnyq/regexp",
|
|
1308
1183
|
rules: {
|
|
1309
1184
|
...rules,
|
|
@@ -1382,12 +1257,12 @@ var DEFAULT_PRETTIER_OPTIONS = {
|
|
|
1382
1257
|
|
|
1383
1258
|
// src/utils/env.ts
|
|
1384
1259
|
var import_node_path = require("path");
|
|
1385
|
-
var
|
|
1260
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
1386
1261
|
var import_local_pkg = require("local-pkg");
|
|
1387
1262
|
var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
|
|
1388
1263
|
var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
|
|
1389
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", {
|
|
1390
|
-
paths: [(0, import_node_path.resolve)(
|
|
1265
|
+
paths: [(0, import_node_path.resolve)(import_node_process.default.cwd(), "playground")]
|
|
1391
1266
|
});
|
|
1392
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");
|
|
1393
1268
|
|
|
@@ -1728,9 +1603,9 @@ var comments = (options = {}) => [
|
|
|
1728
1603
|
var markdown = (options = {}) => {
|
|
1729
1604
|
if (!Array.isArray(import_markdown.default.configs?.processor)) return [];
|
|
1730
1605
|
return [
|
|
1731
|
-
...import_markdown.default.configs.processor.map((
|
|
1732
|
-
...
|
|
1733
|
-
name: `ntnyq/${
|
|
1606
|
+
...import_markdown.default.configs.processor.map((config) => ({
|
|
1607
|
+
...config,
|
|
1608
|
+
name: `ntnyq/${config.name}`
|
|
1734
1609
|
})),
|
|
1735
1610
|
{
|
|
1736
1611
|
name: "ntnyq/markdown/disabled/code-blocks",
|
|
@@ -1835,6 +1710,22 @@ var prettier = (options = {}) => {
|
|
|
1835
1710
|
];
|
|
1836
1711
|
};
|
|
1837
1712
|
|
|
1713
|
+
// src/configs/stylistic.ts
|
|
1714
|
+
var stylistic = (options = {}) => [
|
|
1715
|
+
{
|
|
1716
|
+
name: "ntnyq/stylistic",
|
|
1717
|
+
plugins: {
|
|
1718
|
+
"@stylistic": import_eslint_plugin3.default
|
|
1719
|
+
},
|
|
1720
|
+
rules: {
|
|
1721
|
+
// Only rules are not conflicted with Prettier
|
|
1722
|
+
// Use stylistic config to provide type support
|
|
1723
|
+
// Overrides rules
|
|
1724
|
+
...options.overrides
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
];
|
|
1728
|
+
|
|
1838
1729
|
// src/configs/gitignore.ts
|
|
1839
1730
|
var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
|
|
1840
1731
|
var gitignore = (options = {}) => {
|
|
@@ -2080,6 +1971,198 @@ var jsx = () => [
|
|
|
2080
1971
|
}
|
|
2081
1972
|
];
|
|
2082
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
|
+
|
|
2083
2166
|
// src/configs/githubAction.ts
|
|
2084
2167
|
var githubAction = (options = {}) => [
|
|
2085
2168
|
{
|
|
@@ -2212,7 +2295,7 @@ var unusedImports = (options = {}) => [
|
|
|
2212
2295
|
];
|
|
2213
2296
|
|
|
2214
2297
|
// src/core.ts
|
|
2215
|
-
function defineESLintConfig(options = {}, userConfigs
|
|
2298
|
+
async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
2216
2299
|
const configs2 = [];
|
|
2217
2300
|
if (options.gitignore ?? true) {
|
|
2218
2301
|
configs2.push(
|
|
@@ -2227,9 +2310,18 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2227
2310
|
...node({
|
|
2228
2311
|
overrides: getOverrides(options, "node")
|
|
2229
2312
|
}),
|
|
2313
|
+
...command({
|
|
2314
|
+
...resolveSubOptions(options, "command")
|
|
2315
|
+
}),
|
|
2230
2316
|
...imports({
|
|
2231
2317
|
overrides: getOverrides(options, "imports")
|
|
2232
2318
|
}),
|
|
2319
|
+
...jsdoc({
|
|
2320
|
+
overrides: getOverrides(options, "jsdoc")
|
|
2321
|
+
}),
|
|
2322
|
+
...comments({
|
|
2323
|
+
overrides: getOverrides(options, "comments")
|
|
2324
|
+
}),
|
|
2233
2325
|
...javascript({
|
|
2234
2326
|
...resolveSubOptions(options, "javascript"),
|
|
2235
2327
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2258,20 +2350,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2258
2350
|
})
|
|
2259
2351
|
);
|
|
2260
2352
|
}
|
|
2261
|
-
if (options.jsdoc ?? true) {
|
|
2262
|
-
configs2.push(
|
|
2263
|
-
...jsdoc({
|
|
2264
|
-
overrides: getOverrides(options, "jsdoc")
|
|
2265
|
-
})
|
|
2266
|
-
);
|
|
2267
|
-
}
|
|
2268
|
-
if (options.comments ?? true) {
|
|
2269
|
-
configs2.push(
|
|
2270
|
-
...comments({
|
|
2271
|
-
overrides: getOverrides(options, "comments")
|
|
2272
|
-
})
|
|
2273
|
-
);
|
|
2274
|
-
}
|
|
2275
2353
|
if (options.typescript ?? hasTypeScript) {
|
|
2276
2354
|
configs2.push(
|
|
2277
2355
|
...typescript({
|
|
@@ -2340,17 +2418,17 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2340
2418
|
})
|
|
2341
2419
|
);
|
|
2342
2420
|
}
|
|
2343
|
-
if (options.
|
|
2421
|
+
if (options.antfu ?? true) {
|
|
2344
2422
|
configs2.push(
|
|
2345
|
-
...
|
|
2346
|
-
|
|
2423
|
+
...antfu({
|
|
2424
|
+
overrides: getOverrides(options, "antfu")
|
|
2347
2425
|
})
|
|
2348
2426
|
);
|
|
2349
2427
|
}
|
|
2350
|
-
if (options.
|
|
2428
|
+
if (options.stylistic ?? true) {
|
|
2351
2429
|
configs2.push(
|
|
2352
|
-
...
|
|
2353
|
-
overrides: getOverrides(options, "
|
|
2430
|
+
...stylistic({
|
|
2431
|
+
overrides: getOverrides(options, "stylistic")
|
|
2354
2432
|
})
|
|
2355
2433
|
);
|
|
2356
2434
|
}
|
|
@@ -2367,9 +2445,9 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2367
2445
|
overrides: getOverrides(options, "prettier")
|
|
2368
2446
|
}) : [];
|
|
2369
2447
|
const composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
2370
|
-
composer.append(
|
|
2448
|
+
await composer.append(
|
|
2371
2449
|
...configs2,
|
|
2372
|
-
...
|
|
2450
|
+
...userConfigs,
|
|
2373
2451
|
...configSpecials,
|
|
2374
2452
|
...configPrettier
|
|
2375
2453
|
);
|
|
@@ -2380,6 +2458,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2380
2458
|
DEFAULT_PRETTIER_OPTIONS,
|
|
2381
2459
|
GLOB_ALL_SRC,
|
|
2382
2460
|
GLOB_ASTRO,
|
|
2461
|
+
GLOB_ASTRO_TS,
|
|
2383
2462
|
GLOB_CSS,
|
|
2384
2463
|
GLOB_DIST,
|
|
2385
2464
|
GLOB_DTS,
|
|
@@ -2412,7 +2491,6 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2412
2491
|
antfu,
|
|
2413
2492
|
command,
|
|
2414
2493
|
comments,
|
|
2415
|
-
createTypeScriptConfig,
|
|
2416
2494
|
defineESLintConfig,
|
|
2417
2495
|
format,
|
|
2418
2496
|
getOverrides,
|
|
@@ -2455,6 +2533,7 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2455
2533
|
pluginPerfectionist,
|
|
2456
2534
|
pluginPrettier,
|
|
2457
2535
|
pluginRegexp,
|
|
2536
|
+
pluginStylistic,
|
|
2458
2537
|
pluginToml,
|
|
2459
2538
|
pluginTypeScript,
|
|
2460
2539
|
pluginUnicorn,
|
|
@@ -2470,12 +2549,12 @@ function defineESLintConfig(options = {}, userConfigs = []) {
|
|
|
2470
2549
|
resolveSubOptions,
|
|
2471
2550
|
sort,
|
|
2472
2551
|
specials,
|
|
2552
|
+
stylistic,
|
|
2473
2553
|
test,
|
|
2474
2554
|
toArray,
|
|
2475
2555
|
toml,
|
|
2476
2556
|
typescript,
|
|
2477
2557
|
typescriptConfigs,
|
|
2478
|
-
typescriptCore,
|
|
2479
2558
|
unicorn,
|
|
2480
2559
|
unocss,
|
|
2481
2560
|
unusedImports,
|