@ithinkdt/lint 4.0.0-9 → 4.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/lint",
3
- "version": "4.0.0-9",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "description": "iThinkDT 项目的 ESLint、StyleLint 配置",
6
6
  "keywords": [
@@ -32,35 +32,36 @@
32
32
  },
33
33
  "sideEffects": false,
34
34
  "dependencies": {
35
- "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
36
- "@eslint/js": "^9.37.0",
37
- "@eslint/json": ">=0.13.2",
38
- "@eslint/markdown": "7.4.0",
39
- "@stylistic/eslint-plugin": "^5.4.0",
40
- "@typescript-eslint/parser": "^8.46.0",
41
- "@unocss/eslint-config": "^66.5.2",
42
- "@vitest/eslint-plugin": "^1.3.16",
43
- "@vue/compiler-sfc": "^3.5.22",
44
- "eslint-flat-config-utils": "^2.1.4",
35
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0",
36
+ "@eslint/js": "^9.39.2",
37
+ "@eslint/json": ">=1.0.1",
38
+ "@eslint/markdown": "7.5.1",
39
+ "@stylistic/eslint-plugin": "^5.9.0",
40
+ "@typescript-eslint/parser": "^8.56.1",
41
+ "@unocss/eslint-config": "^66.6.2",
42
+ "@vitest/eslint-plugin": "^1.6.9",
43
+ "@vue/compiler-sfc": "^3.5.29",
44
+ "eslint-flat-config-utils": "^3.0.1",
45
45
  "eslint-import-resolver-custom-alias": "^1.3.2",
46
46
  "eslint-import-resolver-typescript": "^4.4.4",
47
47
  "eslint-merge-processors": "^2.0.0",
48
- "eslint-plugin-format": "^1.0.2",
48
+ "eslint-plugin-format": "^2.0.1",
49
49
  "eslint-plugin-import": "npm:eslint-plugin-import-x@^4.16.1",
50
50
  "eslint-plugin-no-only-tests": "^3.3.0",
51
- "eslint-plugin-playwright": "^2.2.2",
52
- "eslint-plugin-tsdoc": ">=0.4.0",
53
- "eslint-plugin-unicorn": "^61.0.2",
54
- "eslint-plugin-vue": "^10.5.0",
51
+ "eslint-plugin-playwright": "^2.7.1",
52
+ "eslint-plugin-tsdoc": ">=0.5.2",
53
+ "eslint-plugin-unicorn": "^63.0.0",
54
+ "eslint-plugin-vue": "^10.8.0",
55
55
  "eslint-processor-vue-blocks": "^2.0.0",
56
- "globby": "^15.0.0",
56
+ "globals": "^17.3.0",
57
+ "globby": "^16.1.1",
57
58
  "is-glob": "^4.0.3",
58
- "postcss-html": "^1.8.0",
59
- "stylelint-config-standard": "^39.0.1",
59
+ "postcss-html": "^1.8.1",
60
+ "stylelint-config-standard": "^40.0.0",
60
61
  "stylelint-config-standard-vue": "^1.0.0",
61
- "stylelint-order": "^7.0.0",
62
- "typescript-eslint": "^8.46.0",
63
- "vue-eslint-parser": "^10.2.0"
62
+ "stylelint-order": "^7.0.1",
63
+ "typescript-eslint": "^8.56.1",
64
+ "vue-eslint-parser": "^10.4.0"
64
65
  },
65
66
  "peerDependencies": {
66
67
  "eslint": ">=9",
@@ -68,8 +69,8 @@
68
69
  "typescript": ">=5.8"
69
70
  },
70
71
  "devDependencies": {
71
- "eslint": "^9.37.0",
72
- "stylelint": "~16.25.0",
72
+ "eslint": "^9.39.2",
73
+ "stylelint": "~17.4.0",
73
74
  "typescript": "~5.9.3"
74
75
  },
75
76
  "license": "MIT",
package/src/base.js CHANGED
@@ -9,6 +9,7 @@ import importx from 'eslint-plugin-import'
9
9
  import noonlytests from 'eslint-plugin-no-only-tests'
10
10
  import tsdoc from 'eslint-plugin-tsdoc'
11
11
  import unicorn from 'eslint-plugin-unicorn'
12
+ import globals from 'globals'
12
13
  import { configs as tsconfigs } from 'typescript-eslint'
13
14
 
14
15
  export { default as vitest } from '@vitest/eslint-plugin'
@@ -23,7 +24,8 @@ export { createTypeScriptImportResolver } from 'eslint-import-resolver-typescrip
23
24
 
24
25
  export const defaultJsFiles = ['**/*.cts', '**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs']
25
26
  export const defaultTsFiles = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts']
26
- export const defaultEsFiles = [...defaultTsFiles, ...defaultJsFiles, '**/*.vue']
27
+ export const defaultTsWithVueFiles = [...defaultTsFiles, '**/*.vue']
28
+ export const defaultEsFiles = [...defaultTsWithVueFiles, ...defaultJsFiles]
27
29
 
28
30
  export const disableTypeChecked = {
29
31
  ...tsconfigs.disableTypeChecked,
@@ -40,17 +42,25 @@ export function base({ stylistic: stylisticOptions, inCI }) {
40
42
  ignores: ['package-lock.json'],
41
43
  language: 'json/json',
42
44
  },
43
- [js.configs.recommended,
45
+ [
46
+ js.configs.recommended,
44
47
  unicorn.configs.recommended,
45
- ...tsconfigs.recommendedTypeChecked,
46
48
  importx.flatConfigs.recommended,
47
- importx.flatConfigs.typescript,
48
49
  ].map((it) => {
49
50
  return {
50
51
  ...it,
51
52
  files: defaultEsFiles,
52
53
  }
53
54
  }),
55
+ [
56
+ ...tsconfigs.recommendedTypeChecked,
57
+ importx.flatConfigs.typescript,
58
+ ].map((it) => {
59
+ return {
60
+ ...it,
61
+ files: defaultTsWithVueFiles,
62
+ }
63
+ }),
54
64
  stylisticOptions
55
65
  ? [
56
66
  {
@@ -106,13 +116,6 @@ export function base({ stylistic: stylisticOptions, inCI }) {
106
116
 
107
117
  // ------ start copy from @vue/eslint-config-typescript
108
118
 
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
119
  // The following rules are enabled in an `overrides` field in the
117
120
  // `@typescript-eslint/recommended` ruleset, only turned on for TypeScript source modules
118
121
  // <https://github.com/typescript-eslint/typescript-eslint/blob/cb2d44650d27d8b917e8ce19423245b834db29d2/packages/eslint-plugin/src/configs/eslint-recommended.ts#L27-L30>
@@ -131,48 +134,6 @@ export function base({ stylistic: stylisticOptions, inCI }) {
131
134
  'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
132
135
  'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
133
136
 
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',
142
- argsIgnorePattern: '^_',
143
- varsIgnorePattern: '^_',
144
- destructuredArrayIgnorePattern: '^_',
145
- ignoreRestSiblings: true,
146
- caughtErrors: 'none',
147
- }],
148
- // 允许非空断言
149
- 'ts/no-non-null-assertion': 'off',
150
- // 空合并提示
151
- 'ts/prefer-nullish-coalescing': ['warn', {
152
- ignoreConditionalTests: true,
153
- ignoreTernaryTests: true,
154
- ignoreMixedLogicalExpressions: true,
155
- ignorePrimitives: true,
156
- }],
157
- 'ts/no-empty-object-type': ['error', {
158
- allowInterfaces: 'with-single-extends',
159
- allowWithName: 'Props$',
160
- }],
161
-
162
- 'ts/no-explicit-any': ['error', {
163
- ignoreRestArgs: true,
164
- }],
165
-
166
- // 允许未 catch 的 promise
167
- 'ts/no-floating-promises': 'off',
168
- 'ts/no-misused-promises': ['warn', {
169
- checksVoidReturn: false,
170
- }],
171
- // 允许模版表达式使用数字
172
- 'ts/restrict-template-expressions': ['warn', {
173
- allowNumber: true,
174
- }],
175
-
176
137
  // 允许缩写
177
138
  'unicorn/prevent-abbreviations': 'off',
178
139
 
@@ -195,9 +156,6 @@ export function base({ stylistic: stylisticOptions, inCI }) {
195
156
  ignoreUsedVariables: true,
196
157
  }],
197
158
 
198
- // tla 设为 警告
199
- 'unicorn/prefer-top-level-await': 'warn',
200
-
201
159
  'unicorn/no-useless-undefined': ['warn', {
202
160
  checkArguments: false,
203
161
  checkArrowFunctionBody: false,
@@ -226,7 +184,25 @@ export function base({ stylistic: stylisticOptions, inCI }) {
226
184
  },
227
185
  },
228
186
  {
229
- files: defaultTsFiles,
187
+ files: defaultJsFiles,
188
+ languageOptions: {
189
+ globals: {
190
+ ...globals.browser,
191
+ },
192
+ },
193
+ rules: {
194
+ 'no-unused-vars': ['warn', {
195
+ args: 'after-used',
196
+ argsIgnorePattern: '^_',
197
+ varsIgnorePattern: '^_',
198
+ destructuredArrayIgnorePattern: '^_',
199
+ ignoreRestSiblings: true,
200
+ caughtErrors: 'none',
201
+ }],
202
+ },
203
+ },
204
+ {
205
+ files: defaultTsWithVueFiles,
230
206
  plugins: {
231
207
  tsdoc,
232
208
  },
@@ -235,6 +211,48 @@ export function base({ stylistic: stylisticOptions, inCI }) {
235
211
  'tsdoc/syntax': 'warn',
236
212
  // 不允许使用标记为 @deprecated 的代码
237
213
  'ts/no-deprecated': 'warn',
214
+
215
+ // this rule, if on, would require explicit return type on the `render` function
216
+ // 'ts/explicit-function-return-type': 'off',
217
+
218
+ // ------ end
219
+
220
+ // 忽略下划线开始的变量名
221
+ 'ts/no-unused-vars': ['warn', {
222
+ args: 'after-used',
223
+ argsIgnorePattern: '^_',
224
+ varsIgnorePattern: '^_',
225
+ destructuredArrayIgnorePattern: '^_',
226
+ ignoreRestSiblings: true,
227
+ caughtErrors: 'none',
228
+ }],
229
+ // 允许非空断言
230
+ 'ts/no-non-null-assertion': 'off',
231
+ // 空合并提示
232
+ 'ts/prefer-nullish-coalescing': ['warn', {
233
+ ignoreConditionalTests: true,
234
+ ignoreTernaryTests: true,
235
+ ignoreMixedLogicalExpressions: true,
236
+ ignorePrimitives: true,
237
+ }],
238
+ 'ts/no-empty-object-type': ['error', {
239
+ allowInterfaces: 'with-single-extends',
240
+ allowWithName: 'Props$',
241
+ }],
242
+
243
+ 'ts/no-explicit-any': ['error', {
244
+ ignoreRestArgs: true,
245
+ }],
246
+
247
+ // 允许未 catch 的 promise
248
+ 'ts/no-floating-promises': 'off',
249
+ 'ts/no-misused-promises': ['warn', {
250
+ checksVoidReturn: false,
251
+ }],
252
+ // 允许模版表达式使用数字
253
+ 'ts/restrict-template-expressions': ['warn', {
254
+ allowNumber: true,
255
+ }],
238
256
  },
239
257
  },
240
258
  {
package/src/index.js CHANGED
@@ -2,7 +2,6 @@ import { env } from 'node:process'
2
2
 
3
3
  import unocss from '@unocss/eslint-config/flat'
4
4
  import { mergeProcessors } from 'eslint-merge-processors'
5
- import tsdoc from 'eslint-plugin-tsdoc'
6
5
  import processorVueBlocks from 'eslint-processor-vue-blocks'
7
6
 
8
7
  import { base, defaultEsFiles, defaultJsFiles, defaultTsFiles, disableTypeChecked, playwright, tsParser, vitest, vue, vueParser } from './base.js'
@@ -226,14 +225,9 @@ export default function config({ unocss: withUnoCSS, stylistic: withStylistic, t
226
225
  },
227
226
  },
228
227
  },
229
- plugins: { tsdoc },
230
228
  rules: {
231
- // 启用 tsdoc 扫描
232
- 'tsdoc/syntax': 'warn',
233
229
  /** script setup 不能开启此规则 */
234
230
  'import-x/exports-last': 'off',
235
- // 不允许使用标记为 @deprecated 的代码
236
- 'ts/no-deprecated': 'warn',
237
231
  },
238
232
  },
239
233
 
@@ -1,3 +1,5 @@
1
+ import { cwd } from 'node:process'
2
+
1
3
  import { parser as tsEslintParser } from 'typescript-eslint'
2
4
 
3
5
  import { TSServiceManager } from './ts.js'
@@ -41,7 +43,7 @@ function* _iterateOptions(options) {
41
43
  if (!options.project) {
42
44
  throw new Error('Specify `parserOptions.project`. Otherwise there is no point in using this parser.')
43
45
  }
44
- const tsconfigRootDir = typeof options.tsconfigRootDir === 'string' ? options.tsconfigRootDir : process.cwd()
46
+ const tsconfigRootDir = typeof options.tsconfigRootDir === 'string' ? options.tsconfigRootDir : cwd()
45
47
 
46
48
  for (const project of resolveProjectList({
47
49
  project: getProjectConfigFiles({
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path'
2
+ import { cwd } from 'node:process'
2
3
 
3
4
  import ts from 'typescript'
4
5
 
@@ -309,7 +310,7 @@ function isVirtualTSX(fileName, extraFileExtensions) {
309
310
  function formatDiagnostics(diagnostics) {
310
311
  return ts.formatDiagnostics(diagnostics, {
311
312
  getCanonicalFileName: f => f,
312
- getCurrentDirectory: () => process.cwd(),
313
+ getCurrentDirectory: () => cwd(),
313
314
  getNewLine: () => '\n',
314
315
  })
315
316
  }
@@ -326,7 +327,7 @@ function normalizeFileName(fileName) {
326
327
  }
327
328
 
328
329
  function toAbsolutePath(filePath, baseDir) {
329
- return path.isAbsolute(filePath) ? filePath : path.join(baseDir || process.cwd(), filePath)
330
+ return path.isAbsolute(filePath) ? filePath : path.join(baseDir || cwd(), filePath)
330
331
  }
331
332
 
332
333
  function* iterateDirs(filePath) {
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path'
2
+ import { cwd } from 'node:process'
2
3
 
3
4
  import { globbySync } from 'globby'
4
5
  import isGlob from 'is-glob'
@@ -64,5 +65,5 @@ function _getCanonicalFileName(filePath) {
64
65
  }
65
66
 
66
67
  function _ensureAbsolutePath(p, tsconfigRootDir) {
67
- return path.isAbsolute(p) ? p : path.join(tsconfigRootDir || process.cwd(), p)
68
+ return path.isAbsolute(p) ? p : path.join(tsconfigRootDir || cwd(), p)
68
69
  }