Skip to content

Commit 15a4564

Browse files
committed
feat: 优化项目模板配置
- 新增 .gitattributes 文件,设置文本文件的自动转换 - 更新 .gitignore 和 _prettierignore 文件,优化忽略项 - 修改 biome.jsonc 和 eslint.config.mjs,统一代码格式规范 - 更新 lefthook.yml.ejs,增加 commitlint 检查 - 调整 tsconfig.json,优化 TypeScript 配置
1 parent fa653d5 commit 15a4564

File tree

7 files changed

+60
-23
lines changed

7 files changed

+60
-23
lines changed

templates/default/_gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# .gitattributes
2+
3+
* text=auto
4+
5+
6+

templates/default/_gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ node_modules
2525
.history
2626
!.vscode/extensions.json
2727

28-
# dist and cache
28+
# dist
2929
/dist
30-
/dist-*
31-
/dist_*
32-
.cache
3330

3431
# testing
3532
/coverage

templates/default/_prettierignore

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ yarn.lock
2525
# Editor directories and files
2626
.idea
2727
.vscode
28-
!.vscode/extensions.json
28+
.history
2929

30-
# dist and cache
30+
# dist
3131
/dist
32-
/dist-*
33-
/dist_*
34-
.cache
3532

3633
# testing
3734
/coverage
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
# release-please
40+
.release-please-manifest.json
41+
42+

templates/default/biome.jsonc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@
88
},
99
"files": {
1010
"ignoreUnknown": true,
11-
"ignore": [".*", "package.json", "package-lock.json", "pnpm-lock.{yml,yaml}", "yarn.lock", "templates"]
11+
"ignore": [
12+
".*",
13+
"node_modules",
14+
"/dist/**",
15+
"/public/**",
16+
"/coverage/**",
17+
"package.json",
18+
"package-lock.json",
19+
"pnpm-lock.{yml,yaml}",
20+
"yarn.lock"
21+
]
1222
},
1323
"formatter": {
1424
"enabled": true,

templates/default/eslint.config.mjs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* eslint.config.mjs
33
* @ref https://eslint.org/
4+
* @ref https://github.com/antfu/eslint-config
45
*/
56

67
import { antfu } from '@antfu/eslint-config';
@@ -9,11 +10,18 @@ import prettierConfig from './prettier.config.mjs';
910
export default antfu(
1011
{
1112
type: 'lib',
13+
yaml: true,
14+
typescript: true,
1215
ignores: [
13-
'**/dist/**',
14-
'**/dist-*/**',
15-
'**/dist_*/**',
16-
'coverage/**',
16+
".*",
17+
"node_modules",
18+
"/dist/**",
19+
"/public/**",
20+
"/coverage/**",
21+
"package.json",
22+
"package-lock.json",
23+
"pnpm-lock.{yml,yaml}",
24+
"yarn.lock"
1725
],
1826
stylistic: {
1927
semi: prettierConfig.semi,
@@ -33,3 +41,5 @@ export default antfu(
3341
},
3442
},
3543
);
44+
45+

templates/default/lefthook.yml.ejs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@
44
pre-commit:
55
parallel: true
66
commands:
7-
lint:
7+
<%_ if (codeLinter === 'biome') { _%>
8+
biome:
89
glob: "*"
9-
<%_ if (codeLinter === 'biome') { _%>
1010
run: npx biome check --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
11-
<%_ } else if (codeLinter === 'eslint') { _%>
11+
stage_fixed: true
12+
<%_ } else if (codeLinter === 'eslint') { _%>
13+
eslint:
14+
glob: "*"
1215
run: npx eslint --no-error-on-unmatched-pattern --no-color --fix {staged_files}
13-
<%_ } _%>
1416
stage_fixed: true
17+
<%_ } _%>
1518

1619
commit-msg:
1720
parallel: true
1821
commands:
19-
lint:
22+
commitlint:
2023
run: npx commitlint --edit
24+
25+

templates/default/tsconfig.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"compilerOptions": {
3-
"jsx": "react",
43
"target": "ES2023",
54
"module": "ESNext",
65
"moduleResolution": "bundler",
@@ -13,13 +12,18 @@
1312
"esModuleInterop": true,
1413
"resolveJsonModule": true,
1514
"verbatimModuleSyntax": true,
16-
"allowImportingTsExtensions": true,
15+
"allowImportingTsExtensions": false,
1716
"allowSyntheticDefaultImports": true,
1817
"forceConsistentCasingInFileNames": true,
1918

2019
"lib": ["ES2023", "DOM"],
2120
"types": [],
22-
"plugins": []
21+
"plugins": [],
22+
"paths": {
23+
"@/*": ["./src/*"]
24+
}
2325
},
24-
"include": ["src", "test", "*.ts", "*.mts"]
26+
"include": ["**/*.ts", "**/*.mts", "**/*.tsx", "**/*.vue"],
2527
}
28+
29+

0 commit comments

Comments
 (0)