@infra-x/create-eslint-config 0.1.0 → 0.1.2
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/dist/template/src/configs/tailwind.ts +4 -2
- package/dist/template/src/configs/typescript.ts +4 -2
- package/dist/template/src/index.ts +29 -1
- package/dist/template/src/types.ts +2 -0
- package/dist/template/tsconfig.config.json +4 -0
- package/dist/template/tsconfig.json +1 -4
- package/package.json +18 -11
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { defineConfig } from 'eslint/config'
|
|
5
5
|
import eslintPluginBetterTailwindcss from 'eslint-plugin-better-tailwindcss'
|
|
6
6
|
|
|
7
|
+
import { GLOB_JSX } from '../utils'
|
|
8
|
+
|
|
7
9
|
import type { TailwindOptions } from '../types'
|
|
8
10
|
import type { Linter } from 'eslint'
|
|
9
11
|
|
|
@@ -11,11 +13,11 @@ import type { Linter } from 'eslint'
|
|
|
11
13
|
* Tailwind CSS 规则配置
|
|
12
14
|
*/
|
|
13
15
|
export function tailwind(options: TailwindOptions = {}): Linter.Config[] {
|
|
14
|
-
const { files, overrides = {}, entryPoint = 'src/global.css' } = options
|
|
16
|
+
const { files = [GLOB_JSX], overrides = {}, entryPoint = 'src/global.css' } = options
|
|
15
17
|
|
|
16
18
|
return defineConfig({
|
|
17
19
|
name: 'tailwind/rules',
|
|
18
|
-
files
|
|
20
|
+
files,
|
|
19
21
|
extends: [
|
|
20
22
|
eslintPluginBetterTailwindcss.configs.recommended,
|
|
21
23
|
],
|
|
@@ -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, overrides = {} } = options
|
|
16
|
+
const { files = [GLOB_TS], tsconfigRootDir, allowDefaultProject, defaultProject, overrides = {} } = options
|
|
17
17
|
|
|
18
18
|
return defineConfig({
|
|
19
19
|
name: 'typescript/rules',
|
|
@@ -25,7 +25,9 @@ export function typescript(options: TypeScriptOptions = {}): Linter.Config[] {
|
|
|
25
25
|
languageOptions: {
|
|
26
26
|
parser,
|
|
27
27
|
parserOptions: {
|
|
28
|
-
projectService:
|
|
28
|
+
projectService: allowDefaultProject
|
|
29
|
+
? { allowDefaultProject, defaultProject }
|
|
30
|
+
: true,
|
|
29
31
|
tsconfigRootDir: tsconfigRootDir ?? process.cwd(),
|
|
30
32
|
},
|
|
31
33
|
},
|
|
@@ -134,7 +134,15 @@ const CONFIG_REGISTRY: ConfigEntry[] = [
|
|
|
134
134
|
// 默认开启
|
|
135
135
|
{ key: 'ignores', fn: ignores, defaultOn: true },
|
|
136
136
|
{ key: 'javascript', fn: javascript, defaultOn: true },
|
|
137
|
-
{
|
|
137
|
+
{
|
|
138
|
+
key: 'typescript',
|
|
139
|
+
fn: typescript,
|
|
140
|
+
defaultOn: true,
|
|
141
|
+
inject: () => ({
|
|
142
|
+
allowDefaultProject: ['*.config.ts', '*.config.mts'],
|
|
143
|
+
defaultProject: 'tsconfig.config.json',
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
138
146
|
{ key: 'stylistic', fn: stylistic, defaultOn: true },
|
|
139
147
|
{ key: 'unicorn', fn: unicorn, defaultOn: true },
|
|
140
148
|
{ key: 'depend', fn: depend, defaultOn: true },
|
|
@@ -170,6 +178,26 @@ export function composeConfig(options: ComposeConfigOptions = {}): Linter.Config
|
|
|
170
178
|
configs.push(...fn({ ...injected, ...base }))
|
|
171
179
|
}
|
|
172
180
|
|
|
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
|
+
|
|
173
201
|
return configs
|
|
174
202
|
}
|
|
175
203
|
|
package/package.json
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infra-x/create-eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "CLI to copy ESLint config source into a monorepo.",
|
|
6
6
|
"author": "infra-x",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/oNo500/infra-code.git",
|
|
11
|
+
"directory": "packages/create-eslint-config"
|
|
12
|
+
},
|
|
8
13
|
"publishConfig": {
|
|
9
14
|
"access": "public"
|
|
10
15
|
},
|
|
11
16
|
"bin": {
|
|
12
|
-
"create-eslint-config": "./dist/index.mjs"
|
|
17
|
+
"create-eslint-config": "./dist/index.mjs",
|
|
18
|
+
"cec": "./dist/index.mjs"
|
|
13
19
|
},
|
|
14
20
|
"files": [
|
|
15
21
|
"dist"
|
|
16
22
|
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsdown",
|
|
25
|
+
"dev": "tsdown --watch",
|
|
26
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.config.json --noEmit",
|
|
27
|
+
"prepublishOnly": "pnpm run build"
|
|
28
|
+
},
|
|
17
29
|
"dependencies": {
|
|
18
30
|
"@clack/prompts": "^0.11.0"
|
|
19
31
|
},
|
|
20
32
|
"devDependencies": {
|
|
33
|
+
"@infra-x/eslint-config": "workspace:*",
|
|
34
|
+
"@infra-x/typescript-config": "workspace:*",
|
|
21
35
|
"@types/node": "^25.0.3",
|
|
22
36
|
"eslint": "^9.0.0",
|
|
23
37
|
"tsdown": "^0.18.1",
|
|
24
|
-
"typescript": "^5.9.3"
|
|
25
|
-
"@infra-x/eslint-config": "0.1.0",
|
|
26
|
-
"@infra-x/typescript-config": "0.1.0"
|
|
38
|
+
"typescript": "^5.9.3"
|
|
27
39
|
},
|
|
28
40
|
"main": "./dist/index.mjs",
|
|
29
41
|
"module": "./dist/index.mjs",
|
|
30
42
|
"exports": {
|
|
31
43
|
".": "./dist/index.mjs",
|
|
32
44
|
"./package.json": "./package.json"
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "tsdown",
|
|
36
|
-
"dev": "tsdown --watch",
|
|
37
|
-
"typecheck": "tsc --noEmit"
|
|
38
45
|
}
|
|
39
|
-
}
|
|
46
|
+
}
|