@infra-x/create-eslint-config 0.1.3 → 0.1.4

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.
@@ -29,16 +29,15 @@
29
29
  "vitest": "^4.0.18"
30
30
  },
31
31
  "dependencies": {
32
- "@eslint-react/eslint-plugin": "^2.11.0",
32
+ "@eslint-react/eslint-plugin": "^2.13.0",
33
33
  "@eslint/compat": "1.4.1",
34
34
  "@eslint/core": "0.17.0",
35
- "@eslint/js": "^9.39.2",
35
+ "@eslint/js": "^9.39.3",
36
36
  "@next/eslint-plugin-next": "^16.1.6",
37
- "@stylistic/eslint-plugin": "^5.7.1",
38
- "@vitest/eslint-plugin": "^1.6.6",
39
- "eslint-config-prettier": "^10.1.8",
37
+ "@stylistic/eslint-plugin": "^5.9.0",
38
+ "@vitest/eslint-plugin": "^1.6.9",
40
39
  "eslint-import-resolver-typescript": "^4.4.4",
41
- "eslint-plugin-better-tailwindcss": "^4.1.1",
40
+ "eslint-plugin-better-tailwindcss": "^4.3.1",
42
41
  "eslint-plugin-boundaries": "^5.4.0",
43
42
  "eslint-plugin-depend": "^1.4.0",
44
43
  "eslint-plugin-import-x": "4.16.1",
@@ -48,9 +47,9 @@
48
47
  "eslint-plugin-prettier": "^5.5.5",
49
48
  "eslint-plugin-react-hooks": "^7.0.1",
50
49
  "eslint-plugin-react-refresh": "^0.4.26",
51
- "eslint-plugin-storybook": "^10.2.7",
50
+ "eslint-plugin-storybook": "^10.2.12",
52
51
  "eslint-plugin-unicorn": "^57.0.0",
53
- "typescript-eslint": "^8.54.0"
52
+ "typescript-eslint": "^8.56.1"
54
53
  },
55
54
  "peerDependencies": {
56
55
  "eslint": "^9.39.2",
@@ -13,7 +13,7 @@ import type { Linter } from 'eslint'
13
13
  * TypeScript 规则配置
14
14
  */
15
15
  export function typescript(options: TypeScriptOptions = {}): Linter.Config[] {
16
- const { files = [GLOB_TS], tsconfigRootDir, allowDefaultProject, defaultProject, overrides = {} } = options
16
+ const { files = [GLOB_TS], tsconfigRootDir, overrides = {} } = options
17
17
 
18
18
  return defineConfig({
19
19
  name: 'typescript/rules',
@@ -25,9 +25,7 @@ export function typescript(options: TypeScriptOptions = {}): Linter.Config[] {
25
25
  languageOptions: {
26
26
  parser,
27
27
  parserOptions: {
28
- projectService: allowDefaultProject
29
- ? { allowDefaultProject, defaultProject }
30
- : true,
28
+ projectService: true,
31
29
  tsconfigRootDir: tsconfigRootDir ?? process.cwd(),
32
30
  },
33
31
  },
@@ -17,7 +17,11 @@
17
17
  * ```
18
18
  */
19
19
 
20
+ import { defineConfig } from 'eslint/config'
21
+ import { configs as tsConfigs, parser as tsParser } from 'typescript-eslint'
22
+
20
23
  import { a11y } from './configs/a11y'
24
+ import { tailwind } from './configs/better-tailwindcss'
21
25
  import { boundaries } from './configs/boundaries'
22
26
  import { depend } from './configs/depend'
23
27
  import { ignores } from './configs/ignores'
@@ -30,7 +34,6 @@ import { prettier } from './configs/prettier'
30
34
  import { react } from './configs/react'
31
35
  import { storybook } from './configs/storybook'
32
36
  import { stylistic } from './configs/stylistic'
33
- import { tailwind } from './configs/tailwind'
34
37
  import { typescript } from './configs/typescript'
35
38
  import { unicorn } from './configs/unicorn'
36
39
  import { vitest } from './configs/vitest'
@@ -83,6 +86,8 @@ export interface ComposeConfigOptions {
83
86
  unicorn?: boolean | UnicornOptions
84
87
  /** 依赖优化建议 @default true */
85
88
  depend?: boolean | DependOptions
89
+ /** config 文件(*.config.ts)专属规则(不启用类型检查)@default true */
90
+ configFiles?: boolean
86
91
 
87
92
  // 框架配置
88
93
  /** React 配置 */
@@ -138,10 +143,6 @@ const CONFIG_REGISTRY: ConfigEntry[] = [
138
143
  key: 'typescript',
139
144
  fn: typescript,
140
145
  defaultOn: true,
141
- inject: () => ({
142
- allowDefaultProject: ['*.config.ts', '*.config.mts'],
143
- defaultProject: 'tsconfig.config.json',
144
- }),
145
146
  },
146
147
  { key: 'stylistic', fn: stylistic, defaultOn: true },
147
148
  { key: 'unicorn', fn: unicorn, defaultOn: true },
@@ -178,27 +179,26 @@ export function composeConfig(options: ComposeConfigOptions = {}): Linter.Config
178
179
  configs.push(...fn({ ...injected, ...base }))
179
180
  }
180
181
 
181
- // allowDefaultProject 文件附加宽松规则覆盖(内置默认值 + 用户覆盖)
182
- const tsEntry = CONFIG_REGISTRY.find((e) => e.key === 'typescript')
183
- const tsInjected = tsEntry?.inject ? tsEntry.inject(options) : {}
184
- const tsBase = typeof options.typescript === 'object' ? options.typescript : {}
185
- const tsOpts = { ...tsInjected, ...tsBase } as TypeScriptOptions
186
- if (options.typescript !== false && tsOpts.allowDefaultProject) {
187
- configs.push({
188
- name: 'typescript/config-files-relaxed',
189
- files: tsOpts.allowDefaultProject,
190
- rules: {
191
- '@typescript-eslint/no-unsafe-assignment': 'off',
192
- '@typescript-eslint/no-unsafe-member-access': 'off',
193
- '@typescript-eslint/no-unsafe-call': 'off',
194
- '@typescript-eslint/no-unsafe-return': 'off',
195
- '@typescript-eslint/no-unsafe-argument': 'off',
196
- 'unicorn/import-style': 'off',
197
- },
198
- })
199
- }
200
-
201
- return configs
182
+ return options.configFiles === false
183
+ ? configs
184
+ : defineConfig([
185
+ {
186
+ ignores: ['*.config.ts', '*.config.mts'],
187
+ extends: [configs],
188
+ },
189
+ {
190
+ name: 'typescript/config-files',
191
+ files: ['*.config.ts', '*.config.mts'],
192
+ extends: [tsConfigs.recommended],
193
+ languageOptions: {
194
+ parser: tsParser,
195
+ parserOptions: {
196
+ project: false,
197
+ tsconfigRootDir: (typeof options.typescript === 'object' ? options.typescript.tsconfigRootDir : undefined) ?? process.cwd(),
198
+ },
199
+ },
200
+ },
201
+ ])
202
202
  }
203
203
 
204
204
  // ============================================================================
@@ -1,4 +1,8 @@
1
1
  {
2
2
  "extends": "@infra-x/typescript-config/tsconfig.library.json",
3
- "include": ["src"],
3
+ "include": ["src", "*.config.ts", "*.config.mts"],
4
+ "compilerOptions": {
5
+ "types": ["node"],
6
+ "isolatedDeclarations": false // 减少维护,在那时关闭吧,不然 config 需要繁琐的配置
7
+ }
4
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infra-x/create-eslint-config",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "description": "CLI to copy ESLint config source into a monorepo.",
6
6
  "author": "infra-x",
7
7
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "scripts": {
24
24
  "build": "tsdown",
25
25
  "dev": "tsdown --watch",
26
- "typecheck": "tsc --noEmit && tsc -p tsconfig.config.json --noEmit",
26
+ "typecheck": "tsc --noEmit",
27
27
  "prepublishOnly": "pnpm run build"
28
28
  },
29
29
  "dependencies": {
@@ -32,9 +32,9 @@
32
32
  "devDependencies": {
33
33
  "@infra-x/eslint-config": "workspace:*",
34
34
  "@infra-x/typescript-config": "workspace:*",
35
- "@types/node": "^25.0.3",
36
- "eslint": "^9.0.0",
37
- "tsdown": "^0.18.1",
35
+ "@types/node": "^25.3.1",
36
+ "eslint": "^9.39.3",
37
+ "tsdown": "^0.18.4",
38
38
  "typescript": "^5.9.3"
39
39
  },
40
40
  "main": "./dist/index.mjs",
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "@infra-x/typescript-config/tsconfig.config.json",
3
- "include": ["*.config.ts", "*.config.mts"]
4
- }