@ithinkdt/lint 4.0.0-6 → 4.0.0-700
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 +1 -20
- package/package.json +37 -41
- package/src/base.js +271 -163
- package/src/index.d.ts +8 -0
- package/src/index.js +230 -99
- package/src/rules/index.js +26 -0
- package/src/rules/no-relative-parent-imports.js +54 -0
- package/src/rules/prefer-import-alias.js +66 -0
- package/src/stylelint.d.ts +1 -1
- package/src/stylelint.js +18 -42
- package/src/tsparser-for-extra-files/index.js +6 -5
- package/src/tsparser-for-extra-files/transform.js +14 -14
- package/src/tsparser-for-extra-files/ts.js +81 -113
- package/src/tsparser-for-extra-files/utils/resolve-project-list.js +18 -12
- package/src/prettier-fix-vue.js +0 -54
- package/src/prettier.d.ts +0 -4
- package/src/prettier.js +0 -15
- package/tsconfig.json +0 -14
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
- 集成 `eslint-plugin-tsdoc` 规则;
|
|
11
11
|
- 集成 `eslint-plugin-import-x` 规则;
|
|
12
12
|
- 集成 `eslint-plugin-playwright`、`@vitest/eslint-plugin` 测试代码规则;
|
|
13
|
-
- 支持 `StyleLint
|
|
13
|
+
- 支持 `StyleLint` 配置。
|
|
14
14
|
|
|
15
15
|
> 由于启用了类型感知规则,原则上 typescript 会在整个项目上执行,推测 `lint-staged` 效果不佳。
|
|
16
16
|
|
|
@@ -51,22 +51,3 @@ export default {
|
|
|
51
51
|
},
|
|
52
52
|
}
|
|
53
53
|
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Prettier
|
|
57
|
-
|
|
58
|
-
安装 `npm i -D prettier`
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
// prettier.config.js
|
|
62
|
-
|
|
63
|
-
import ithinkdt from '@ithinkdt/lint/prettier'
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @type {import('prettier').Config}
|
|
67
|
-
*/
|
|
68
|
-
export default {
|
|
69
|
-
...ithinkdt,
|
|
70
|
-
// 覆盖配置
|
|
71
|
-
}
|
|
72
|
-
```
|
package/package.json
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ithinkdt/lint",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-700",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "iThinkDT
|
|
5
|
+
"description": "iThinkDT 项目的 ESLint、StyleLint 配置",
|
|
6
6
|
"keywords": [
|
|
7
|
-
"vue",
|
|
8
7
|
"ithinkdt",
|
|
8
|
+
"vue",
|
|
9
9
|
"lint",
|
|
10
10
|
"eslint",
|
|
11
|
-
"eslint-config",
|
|
12
|
-
"prettier",
|
|
13
11
|
"stylelint"
|
|
14
12
|
],
|
|
15
13
|
"files": [
|
|
16
|
-
"
|
|
14
|
+
"src"
|
|
17
15
|
],
|
|
18
16
|
"main": "./src/index.js",
|
|
19
17
|
"module": "./src/index.js",
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
20
19
|
"exports": {
|
|
21
20
|
".": {
|
|
22
21
|
"types": "./src/index.d.ts",
|
|
23
22
|
"default": "./src/index.js"
|
|
24
23
|
},
|
|
25
|
-
"./prettier": {
|
|
26
|
-
"types": "./src/prettier.d.ts",
|
|
27
|
-
"default": "./src/prettier.js"
|
|
28
|
-
},
|
|
29
24
|
"./stylelint": {
|
|
30
25
|
"types": "./src/stylelint.d.ts",
|
|
31
26
|
"default": "./src/stylelint.js"
|
|
@@ -37,48 +32,49 @@
|
|
|
37
32
|
},
|
|
38
33
|
"sideEffects": false,
|
|
39
34
|
"dependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
35
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
|
36
|
+
"@eslint/js": "^9.39.2",
|
|
37
|
+
"@eslint/json": ">=0.14.0",
|
|
38
|
+
"@eslint/markdown": "7.5.1",
|
|
39
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
40
|
+
"@typescript-eslint/parser": "^8.50.0",
|
|
41
|
+
"@unocss/eslint-config": "^66.5.10",
|
|
42
|
+
"@vitest/eslint-plugin": "^1.5.2",
|
|
43
|
+
"@vue/compiler-sfc": "^3.5.25",
|
|
44
|
+
"eslint-flat-config-utils": "^2.1.4",
|
|
44
45
|
"eslint-import-resolver-custom-alias": "^1.3.2",
|
|
45
|
-
"eslint-import-resolver-typescript": "^
|
|
46
|
-
"eslint-
|
|
47
|
-
"eslint-plugin-
|
|
48
|
-
"eslint-plugin-
|
|
49
|
-
"eslint-plugin-
|
|
50
|
-
"eslint-plugin-
|
|
51
|
-
"
|
|
46
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
47
|
+
"eslint-merge-processors": "^2.0.0",
|
|
48
|
+
"eslint-plugin-format": "^1.1.0",
|
|
49
|
+
"eslint-plugin-import": "npm:eslint-plugin-import-x@^4.16.1",
|
|
50
|
+
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
51
|
+
"eslint-plugin-playwright": "^2.4.0",
|
|
52
|
+
"eslint-plugin-tsdoc": ">=0.5.0",
|
|
53
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
54
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
55
|
+
"eslint-processor-vue-blocks": "^2.0.0",
|
|
56
|
+
"globals": "^16.5.0",
|
|
57
|
+
"globby": "^16.0.0",
|
|
52
58
|
"is-glob": "^4.0.3",
|
|
53
|
-
"postcss": "^8.
|
|
54
|
-
"
|
|
55
|
-
"postcss-scss": "^4.0.9",
|
|
56
|
-
"stylelint-config-recommended": "^14.0.1",
|
|
57
|
-
"stylelint-config-standard": "^36.0.1",
|
|
58
|
-
"stylelint-config-standard-scss": "^13.1.0",
|
|
59
|
+
"postcss-html": "^1.8.0",
|
|
60
|
+
"stylelint-config-standard": "^39.0.1",
|
|
59
61
|
"stylelint-config-standard-vue": "^1.0.0",
|
|
60
|
-
"stylelint-order": "^
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"vue-eslint-parser": "^9.4.3"
|
|
62
|
+
"stylelint-order": "^7.0.0",
|
|
63
|
+
"typescript-eslint": "^8.50.0",
|
|
64
|
+
"vue-eslint-parser": "^10.2.0"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
|
-
"eslint": ">=
|
|
67
|
+
"eslint": ">=9",
|
|
67
68
|
"stylelint": ">=16",
|
|
68
|
-
"
|
|
69
|
-
"dprint": ">=0.47",
|
|
70
|
-
"typescript": ">=5"
|
|
69
|
+
"typescript": ">=5.8"
|
|
71
70
|
},
|
|
72
71
|
"devDependencies": {
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"stylelint": "~16.9.0",
|
|
77
|
-
"typescript": "~5.5.4"
|
|
72
|
+
"eslint": "^9.39.2",
|
|
73
|
+
"stylelint": "~16.26.1",
|
|
74
|
+
"typescript": "~5.9.3"
|
|
78
75
|
},
|
|
79
76
|
"license": "MIT",
|
|
80
77
|
"scripts": {
|
|
81
|
-
"format": "prettier --write \"./{src}/**/*.{js,vue,ts,jsx,tsx}\"",
|
|
82
78
|
"release": "pnpm publish --no-git-checks"
|
|
83
79
|
}
|
|
84
80
|
}
|
package/src/base.js
CHANGED
|
@@ -1,193 +1,301 @@
|
|
|
1
|
-
import { env } from 'node:process'
|
|
2
|
-
|
|
3
|
-
import { config as tsconfig, configs as tsconfigs } from 'typescript-eslint'
|
|
4
|
-
|
|
5
1
|
import js from '@eslint/js'
|
|
6
|
-
import
|
|
7
|
-
import
|
|
2
|
+
import json from '@eslint/json'
|
|
3
|
+
import markdown from '@eslint/markdown'
|
|
4
|
+
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs'
|
|
5
|
+
import stylistic from '@stylistic/eslint-plugin'
|
|
6
|
+
import { composer } from 'eslint-flat-config-utils'
|
|
7
|
+
import format from 'eslint-plugin-format'
|
|
8
8
|
import importx from 'eslint-plugin-import'
|
|
9
|
+
import noonlytests from 'eslint-plugin-no-only-tests'
|
|
10
|
+
import tsdoc from 'eslint-plugin-tsdoc'
|
|
11
|
+
import unicorn from 'eslint-plugin-unicorn'
|
|
12
|
+
import globals from 'globals'
|
|
13
|
+
import { configs as tsconfigs } from 'typescript-eslint'
|
|
9
14
|
|
|
10
15
|
export { default as vitest } from '@vitest/eslint-plugin'
|
|
11
16
|
export { default as playwright } from 'eslint-plugin-playwright'
|
|
12
17
|
export { default as vue } from 'eslint-plugin-vue'
|
|
13
18
|
|
|
14
|
-
export * as
|
|
19
|
+
export * as vueParser from 'vue-eslint-parser'
|
|
20
|
+
|
|
21
|
+
export { default as tsParser } from './tsparser-for-extra-files/index.js'
|
|
22
|
+
|
|
23
|
+
export { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
|
|
15
24
|
|
|
16
|
-
export
|
|
25
|
+
export const defaultJsFiles = ['**/*.cts', '**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs']
|
|
26
|
+
export const defaultTsFiles = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts']
|
|
27
|
+
export const defaultTsWithVueFiles = [...defaultTsFiles, '**/*.vue']
|
|
28
|
+
export const defaultEsFiles = [...defaultTsWithVueFiles, ...defaultJsFiles]
|
|
17
29
|
|
|
18
|
-
export const
|
|
19
|
-
files: ['**/*.js', '**/*.cjs'],
|
|
30
|
+
export const disableTypeChecked = {
|
|
20
31
|
...tsconfigs.disableTypeChecked,
|
|
32
|
+
files: defaultJsFiles,
|
|
21
33
|
}
|
|
22
34
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
plugins: {
|
|
33
|
-
tsdoc,
|
|
35
|
+
export function base({ stylistic: stylisticOptions, inCI }) {
|
|
36
|
+
return composer(
|
|
37
|
+
comments.recommended,
|
|
38
|
+
markdown.configs.recommended,
|
|
39
|
+
{
|
|
40
|
+
...json.configs.recommended,
|
|
41
|
+
files: ['**/*.json'],
|
|
42
|
+
ignores: ['package-lock.json'],
|
|
43
|
+
language: 'json/json',
|
|
34
44
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
'
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
'error',
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
{
|
|
116
|
-
checksVoidReturn: false,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
// 允许模版表达式使用数字
|
|
120
|
-
'@typescript-eslint/restrict-template-expressions': [
|
|
121
|
-
'warn',
|
|
122
|
-
{
|
|
123
|
-
allowNumber: true,
|
|
124
|
-
},
|
|
125
|
-
],
|
|
45
|
+
[
|
|
46
|
+
js.configs.recommended,
|
|
47
|
+
unicorn.configs.recommended,
|
|
48
|
+
importx.flatConfigs.recommended,
|
|
49
|
+
].map((it) => {
|
|
50
|
+
return {
|
|
51
|
+
...it,
|
|
52
|
+
files: defaultEsFiles,
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
[
|
|
56
|
+
...tsconfigs.recommendedTypeChecked,
|
|
57
|
+
importx.flatConfigs.typescript,
|
|
58
|
+
].map((it) => {
|
|
59
|
+
return {
|
|
60
|
+
...it,
|
|
61
|
+
files: defaultTsWithVueFiles,
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
stylisticOptions
|
|
65
|
+
? [
|
|
66
|
+
{
|
|
67
|
+
...stylistic.configs.customize(stylisticOptions),
|
|
68
|
+
files: defaultEsFiles,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
files: ['**/*.css', '**/*.scss', '**/*.less'],
|
|
72
|
+
languageOptions: {
|
|
73
|
+
parser: format.parserPlain,
|
|
74
|
+
},
|
|
75
|
+
plugins: {
|
|
76
|
+
format,
|
|
77
|
+
},
|
|
78
|
+
rules: {
|
|
79
|
+
'format/prettier': ['warn', {
|
|
80
|
+
parser: 'css',
|
|
81
|
+
tabWidth: stylisticOptions.indent,
|
|
82
|
+
}],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
: [],
|
|
87
|
+
{
|
|
88
|
+
files: defaultEsFiles,
|
|
89
|
+
rules: {
|
|
90
|
+
'comments/disable-enable-pair': ['error', {
|
|
91
|
+
allowWholeFile: true,
|
|
92
|
+
}],
|
|
93
|
+
// see https://typescript-eslint.io/troubleshooting/typed-linting/performance#eslint-plugin-import
|
|
94
|
+
'import-x/no-unresolved': 'off',
|
|
95
|
+
'import-x/namespace': 'off',
|
|
96
|
+
'import-x/default': 'off',
|
|
97
|
+
'import-x/no-duplicates': ['warn', {
|
|
98
|
+
considerQueryString: true,
|
|
99
|
+
}],
|
|
100
|
+
'import-x/extensions': 'off',
|
|
101
|
+
'import-x/no-unused-modules': 'off',
|
|
102
|
+
'import-x/no-deprecated': inCI ? 'error' : 'off',
|
|
103
|
+
'import-x/no-named-as-default': inCI ? 'warn' : 'off',
|
|
104
|
+
'import-x/no-named-as-default-member': 'off',
|
|
105
|
+
'import-x/no-cycle': ['error', {
|
|
106
|
+
maxDepth: 2,
|
|
107
|
+
ignoreExternal: true,
|
|
108
|
+
}],
|
|
109
|
+
'import-x/no-useless-path-segments': 'error',
|
|
110
|
+
'import-x/first': 'warn',
|
|
111
|
+
'import-x/exports-last': 'off',
|
|
112
|
+
'import-x/group-exports': 'off',
|
|
113
|
+
'import-x/newline-after-import': 'error',
|
|
114
|
+
'import-x/no-relative-packages': 'error',
|
|
115
|
+
'import-x/no-absolute-path': 'error',
|
|
116
|
+
|
|
117
|
+
// ------ start copy from @vue/eslint-config-typescript
|
|
118
|
+
|
|
119
|
+
// The following rules are enabled in an `overrides` field in the
|
|
120
|
+
// `@typescript-eslint/recommended` ruleset, only turned on for TypeScript source modules
|
|
121
|
+
// <https://github.com/typescript-eslint/typescript-eslint/blob/cb2d44650d27d8b917e8ce19423245b834db29d2/packages/eslint-plugin/src/configs/eslint-recommended.ts#L27-L30>
|
|
122
|
+
|
|
123
|
+
// But as ESLint cannot precisely target `<script lang="ts">` blocks and skip normal `<script>`,
|
|
124
|
+
// no TypeScript code in `.vue` files would be checked against these rules.
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
// So we now enable them globally.
|
|
127
|
+
// That would also check plain JavaScript files, which diverges a little from
|
|
128
|
+
// the original intention of the `@typescript-eslint/recommended` rulset.
|
|
129
|
+
// But it should be mostly fine.
|
|
130
|
+
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
|
|
131
|
+
'prefer-const': ['error', {
|
|
132
|
+
destructuring: 'all',
|
|
133
|
+
}], // ts provides better types with const
|
|
134
|
+
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
|
|
135
|
+
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
|
|
129
136
|
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
// 允许缩写
|
|
138
|
+
'unicorn/prevent-abbreviations': 'off',
|
|
132
139
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
// 不提升箭头函数
|
|
141
|
+
'unicorn/consistent-function-scoping': ['warn', {
|
|
142
|
+
checkArrowFunctions: false,
|
|
143
|
+
}],
|
|
144
|
+
|
|
145
|
+
// 文件名拼写忽略组件
|
|
146
|
+
'unicorn/filename-case': ['warn', {
|
|
137
147
|
case: 'kebabCase',
|
|
138
148
|
ignore: [String.raw`\.(j|t)sx$`, String.raw`\.vue`],
|
|
139
|
-
},
|
|
140
|
-
|
|
149
|
+
}],
|
|
150
|
+
|
|
151
|
+
// 忽略 Array.reduce
|
|
152
|
+
'unicorn/no-array-reduce': 'off',
|
|
141
153
|
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
// 重导出检查 忽略已用变量
|
|
155
|
+
'unicorn/prefer-export-from': ['error', {
|
|
156
|
+
ignoreUsedVariables: true,
|
|
157
|
+
}],
|
|
144
158
|
|
|
145
|
-
|
|
146
|
-
|
|
159
|
+
'unicorn/no-useless-undefined': ['warn', {
|
|
160
|
+
checkArguments: false,
|
|
161
|
+
checkArrowFunctionBody: false,
|
|
162
|
+
}],
|
|
163
|
+
'unicorn/no-null': 'off',
|
|
147
164
|
|
|
148
|
-
|
|
149
|
-
|
|
165
|
+
// 仅单行时优先三元表达式
|
|
166
|
+
'unicorn/prefer-ternary': ['warn',
|
|
167
|
+
'only-single-line',
|
|
168
|
+
],
|
|
150
169
|
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
// 关闭 优先 String#replaceAll(),使用全局标志进行正则表达式搜索
|
|
171
|
+
'unicorn/prefer-string-replace-all': 'off',
|
|
153
172
|
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
// 关闭 优先 structuredClone()
|
|
174
|
+
'unicorn/prefer-structured-clone': 'off',
|
|
156
175
|
|
|
157
|
-
|
|
158
|
-
|
|
176
|
+
// 与 ts/no-this-alias 重复
|
|
177
|
+
'unicorn/no-this-assignment': 'off',
|
|
159
178
|
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
'unicorn/template-indent': 'off',
|
|
180
|
+
'unicorn/empty-brace-spaces': 'off',
|
|
181
|
+
'unicorn/no-nested-ternary': 'off',
|
|
182
|
+
'unicorn/number-literal-case': 'off',
|
|
183
|
+
'unicorn/prefer-top-level-await': 'off',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
files: defaultJsFiles,
|
|
188
|
+
languageOptions: {
|
|
189
|
+
globals: {
|
|
190
|
+
...globals.browser,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
rules: {
|
|
194
|
+
'no-unused-vars': ['error', {
|
|
195
|
+
ignoreRestSiblings: true,
|
|
196
|
+
destructuredArrayIgnorePattern: '^_',
|
|
197
|
+
}],
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
files: defaultTsWithVueFiles,
|
|
202
|
+
plugins: {
|
|
203
|
+
tsdoc,
|
|
204
|
+
},
|
|
205
|
+
rules: {
|
|
206
|
+
// 启用 tsdoc 扫描
|
|
207
|
+
'tsdoc/syntax': 'warn',
|
|
208
|
+
// 不允许使用标记为 @deprecated 的代码
|
|
209
|
+
'ts/no-deprecated': 'warn',
|
|
210
|
+
|
|
211
|
+
// this rule, if on, would require explicit return type on the `render` function
|
|
212
|
+
// 'ts/explicit-function-return-type': 'off',
|
|
162
213
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
214
|
+
// ------ end
|
|
215
|
+
|
|
216
|
+
// 忽略下划线开始的变量名
|
|
217
|
+
'ts/no-unused-vars': ['warn', {
|
|
218
|
+
args: 'after-used',
|
|
219
|
+
argsIgnorePattern: '^_',
|
|
220
|
+
varsIgnorePattern: '^_',
|
|
221
|
+
destructuredArrayIgnorePattern: '^_',
|
|
222
|
+
ignoreRestSiblings: true,
|
|
223
|
+
caughtErrors: 'none',
|
|
224
|
+
}],
|
|
225
|
+
// 允许非空断言
|
|
226
|
+
'ts/no-non-null-assertion': 'off',
|
|
227
|
+
// 空合并提示
|
|
228
|
+
'ts/prefer-nullish-coalescing': ['warn', {
|
|
229
|
+
ignoreConditionalTests: true,
|
|
230
|
+
ignoreTernaryTests: true,
|
|
231
|
+
ignoreMixedLogicalExpressions: true,
|
|
232
|
+
ignorePrimitives: true,
|
|
233
|
+
}],
|
|
234
|
+
'ts/no-empty-object-type': ['error', {
|
|
235
|
+
allowInterfaces: 'with-single-extends',
|
|
236
|
+
allowWithName: 'Props$',
|
|
237
|
+
}],
|
|
238
|
+
|
|
239
|
+
'ts/no-explicit-any': ['error', {
|
|
240
|
+
ignoreRestArgs: true,
|
|
241
|
+
}],
|
|
242
|
+
|
|
243
|
+
// 允许未 catch 的 promise
|
|
244
|
+
'ts/no-floating-promises': 'off',
|
|
245
|
+
'ts/no-misused-promises': ['warn', {
|
|
246
|
+
checksVoidReturn: false,
|
|
247
|
+
}],
|
|
248
|
+
// 允许模版表达式使用数字
|
|
249
|
+
'ts/restrict-template-expressions': ['warn', {
|
|
250
|
+
allowNumber: true,
|
|
251
|
+
}],
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
files: ['**/*.d.ts'],
|
|
256
|
+
rules: {
|
|
257
|
+
'ts/no-explicit-any': ['warn', {
|
|
258
|
+
ignoreRestArgs: true,
|
|
259
|
+
}],
|
|
260
|
+
'ts/no-empty-object-type': 'off',
|
|
261
|
+
'unicorn/no-abusive-eslint-disable': 'off',
|
|
262
|
+
},
|
|
167
263
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
'tsdoc/syntax': 'warn',
|
|
174
|
-
|
|
175
|
-
// 不允许使用标记为 @deprecated 的代码
|
|
176
|
-
'@typescript-eslint/no-deprecated': ['warn'],
|
|
264
|
+
{
|
|
265
|
+
files: ['**/shims-*.d.ts'],
|
|
266
|
+
rules: {
|
|
267
|
+
'comments/no-unlimited-disable': 'off',
|
|
268
|
+
},
|
|
177
269
|
},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
270
|
+
{
|
|
271
|
+
files: ['**/*.cjs'],
|
|
272
|
+
rules: {
|
|
273
|
+
// in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled
|
|
274
|
+
'ts/no-require-imports': 'off',
|
|
275
|
+
},
|
|
184
276
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
277
|
+
{
|
|
278
|
+
files: ['**/tests/**'],
|
|
279
|
+
plugins: {
|
|
280
|
+
'no-only-tests': noonlytests,
|
|
281
|
+
},
|
|
282
|
+
rules: {
|
|
283
|
+
'test/no-only-tests': ['error', {
|
|
284
|
+
fix: inCI ? true : false,
|
|
285
|
+
}],
|
|
286
|
+
},
|
|
191
287
|
},
|
|
192
|
-
|
|
193
|
-
|
|
288
|
+
{
|
|
289
|
+
files: ['**/locales/**'],
|
|
290
|
+
rules: {
|
|
291
|
+
// 文件名拼写忽略 locale
|
|
292
|
+
'unicorn/filename-case': 'off',
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
).renamePlugins({
|
|
296
|
+
'no-only-tests': 'test',
|
|
297
|
+
'@typescript-eslint': 'ts',
|
|
298
|
+
'@stylistic': 'style',
|
|
299
|
+
'@eslint-community/eslint-comments': 'comments',
|
|
300
|
+
})
|
|
301
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { StylisticCustomizeOptions } from '@stylistic/eslint-plugin'
|
|
1
2
|
import { Config } from 'typescript-eslint'
|
|
2
3
|
|
|
4
|
+
export { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
|
|
5
|
+
|
|
3
6
|
/** Options for {@link lintConfig} */
|
|
4
7
|
export interface LintOptions {
|
|
5
8
|
/** 是否启用 \@unocss/eslint-config */
|
|
6
9
|
unocss?: boolean
|
|
10
|
+
/** 是否启用 \@stylistic/eslint-plugin */
|
|
11
|
+
stylistic?: boolean | StylisticCustomizeOptions
|
|
12
|
+
|
|
13
|
+
/** 指定 TSConfig 根目录 */
|
|
14
|
+
tsconfigRootDir?: string
|
|
7
15
|
}
|
|
8
16
|
|
|
9
17
|
declare const lintConfig: (options?: LintOptions) => Config
|