@ithinkdt/lint 4.0.0-2 → 4.0.0-200

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