Skip to content

Commit 13a9d3c

Browse files
committed
feat: optimize tsconfig, eslint basic
1 parent 9eb6b7f commit 13a9d3c

File tree

7 files changed

+82
-22
lines changed

7 files changed

+82
-22
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,6 @@ dist
129129
.yarn/build-state.yml
130130
.yarn/install-state.gz
131131
.pnp.*
132+
133+
# for get changed pkg path
134+
cache-changed-pkg-path.sh

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"format": "prettier --write --cache .",
1313
"build": "pnpm -r --filter='./packages/*' run build",
1414
"dev": "pnpm -r --parallel --filter='./packages/*' run dev",
15-
"release": "bumpp package.json packages/**/package.json"
15+
"getchanged": "sh ./scripts/get-changed-pkg-path.sh",
16+
"release": "sh cache-changed-pkg-path.sh"
1617
},
1718
"repository": {
1819
"type": "git",
@@ -26,7 +27,8 @@
2627
},
2728
"lint-staged": {
2829
"*": [
29-
"prettier --write --cache --ignore-unknown"
30+
"prettier --write --cache --ignore-unknown",
31+
"pnpm run getchanged"
3032
],
3133
"packages/*/{src,types}/**/*.ts": [
3234
"eslint --cache --fix"

packages/chaos-tsconfig/tsconfig.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,34 @@
22
"display": "chaos",
33
"$schema": "https://json.schemastore.org/tsconfig",
44
"compilerOptions": {
5+
"target": "ESNext",
6+
"module": "ESNext",
57
"allowJs": true,
68
"baseUrl": ".",
79
"outDir": "dist",
10+
"moduleResolution": "NodeNext",
11+
"jsx": "preserve",
12+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
13+
14+
"composite": true,
15+
"isolatedModules": true,
16+
"strict": true,
17+
818
"declaration": true,
919
"esModuleInterop": true,
20+
1021
"noImplicitAny": true,
1122
"noImplicitReturns": true,
1223
"noImplicitThis": true,
13-
"jsx": "preserve",
14-
"lib": ["DOM"],
15-
"module": "ESNext",
16-
"moduleResolution": "NodeNext",
24+
"noUnusedLocals": true,
25+
"noUnusedParameters": true,
26+
1727
"noEmit": true,
28+
"allowImportingTsExtensions": true,
29+
"allowSyntheticDefaultImports": true,
30+
"useDefineForClassFields": true,
31+
"noFallthroughCasesInSwitch": true,
32+
"resolveJsonModule": true,
1833
"typeRoots": ["node_modules/@types"],
1934
"skipLibCheck": true
2035
}

packages/eslint-config/basic/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { builtinModules } = require('node:module');
2+
13
module.exports = {
24
env: {
35
es6: true,
@@ -216,10 +218,14 @@ module.exports = {
216218
{ count: 1, considerComments: true },
217219
],
218220
'import/no-self-import': 'error',
221+
'import/no-nodejs-modules': [
222+
'error',
223+
{ allow: builtinModules.map((mod) => `node:${mod}`) },
224+
],
219225

220226
// Common
221227
semi: ['error', 'never'],
222-
curly: ['error', 'multi-or-nest', 'consistent'],
228+
// curly: ['error', 'multi-or-nest', 'consistent'],
223229
quotes: ['error', 'single'],
224230
'quote-props': ['error', 'consistent-as-needed'],
225231

scripts/get-changed-pkg-path.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# 获取所有发生变更的文件列表
4+
changed_files=$(git diff --cached --name-only)
5+
6+
# 初始化变量用于存储包路径字符串
7+
package_paths=""
8+
9+
# 遍历发生变更的文件列表
10+
for file in $changed_files; do
11+
12+
# 提取文件所在目录路径
13+
directory=$(dirname "$file")
14+
15+
# 检查目录路径是否包含 packages 关键字
16+
if [[ $directory == *"packages"* ]]; then
17+
18+
# 拼接 package.json 的路径,并添加到 package_paths 变量中
19+
package_paths="$package_paths$directory/package.json "
20+
fi
21+
done
22+
23+
# 打印发生内容更新的包的package.json的路径字符串
24+
echo "发生内容更新的包的package.json的路径:\n$package_paths"
25+
26+
filename="cache-changed-pkg-path.sh"
27+
28+
if [ ! -f "$filename" ]; then
29+
touch "$filename"
30+
31+
echo "File created successfully."
32+
fi
33+
34+
echo "bumpp $package_paths" > $filename

scripts/get-changed-pkg.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# 获取所有发生变更的文件列表
4+
changed_files=$(git diff --name-only)
5+
6+
# 打印发生变更的文件列表
7+
# echo "发生变更的文件列表:"
8+
# echo "$changed_files"
9+
10+
# 筛选出包含 package.json 文件的路径,并提取包名
11+
changed_packages=$(echo "$changed_files" | grep -oE "^packages/[^/]+" | awk -F '/' '{print $2}' | sort -u)
12+
13+
# 打印包名列表
14+
echo "发生内容更新的包名列表:"
15+
echo "$changed_packages"

tsconfig.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)