Skip to content

Commit

Permalink
chore: 更新依赖库版本,更新 eslint,删除一些 index 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
fkworld committed Nov 11, 2023
1 parent 1d2ac0f commit 350af08
Show file tree
Hide file tree
Showing 27 changed files with 1,400 additions and 1,537 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
node_modules
pnpm-lock.yaml
56 changes: 23 additions & 33 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
"root": true,
"env": {
"browser": true,
"node": true
"node": true,
"es6": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"@unocss",
"prettier"
"@unocss"
],
"plugins": ["@typescript-eslint", "simple-import-sort", "import", "react"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
// 使用三等号
"eqeqeq": "error",
Expand All @@ -23,53 +31,35 @@
// import/export 排序,参考 https://github.com/lydell/eslint-plugin-simple-import-sort#example-configuration
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/first": ["error", "disable-absolute-first"],
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
// 禁用 export default
"import/no-default-export": "error",
// 禁用引入不在 dependencies 中的依赖
"import/no-extraneous-dependencies": ["error", { "devDependencies": false }],
// react 组件自闭合
"react/self-closing-comp": "error",
// react hooks 的依赖项检查
"react-hooks/exhaustive-deps": "error",
// react jsx props 排序
"react/jsx-sort-props": ["error", { "reservedFirst": true, "callbacksLast": true }],
// Always use Array<T> or ReadonlyArray<T> for all array types. 参考 https://typescript-eslint.io/rules/array-type/
"@typescript-eslint/array-type": [
"error",
{ "default": "generic", "readonly": "generic" }
]
"@typescript-eslint/array-type": ["error", { "default": "generic" }]
},
"overrides": [
// 对特殊文件,允许 export default
{
"files": ["**/index.ts", "**/index.tsx", "**/index.js", "**/index.jsx"],
"files": ["src/pages/*/index.tsx"],
"rules": {
// 在 index 文件中禁用代码逻辑,只允许使用 import/export 语句
"no-restricted-syntax": [
"error",
{
"selector": "VariableDeclaration",
"message": "Code logic is not allowed in index file."
},
{
"selector": "FunctionDeclaration",
"message": "Code logic is not allowed in index file."
},
{
"selector": "ClassDeclaration",
"message": "Code logic is not allowed in index file."
}
]
"import/no-default-export": "off"
}
},
// 对特殊文件,允许 export default 和基础逻辑
// 对 test 文件,允许引入 devDependencies
{
"files": [
"./src/pages/*/index.tsx",
"./uno.config.ts",
"./vite.config.ts"
],
"files": ["src/**/*.test.ts"],
"rules": {
"import/no-default-export": "off",
"no-restricted-syntax": "off"
"import/no-extraneous-dependencies": "off"
}
}
]
Expand Down
12 changes: 2 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# mac
.DS_Store

# node
dist
node_modules

# vitest
/coverage

# project
/dist
/src/pages/money-analysis/source.csv
src/pages/money-analysis/source.csv
4 changes: 2 additions & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"**/*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"**/*.{js,cjs,mjs,md,json,html}": ["prettier --write"]
"**/*.{ts,tsx,js,jsx,cjs,mjs}": ["eslint --fix", "prettier --write"],
"**/*.{md,json,html,yml,yaml}": ["prettier --write"]
}
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
node_modules
pnpm-lock.yaml
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"semi": true,
"trailingComma": "all"
"trailingComma": "all",
"printWidth": 120
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cSpell.words": [],
"cSpell.words": ["commitlint", "fkworld", "unocss"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
Expand Down
57 changes: 27 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"scripts": {
"prepare": "husky install",
"dev": "vite",
"test": "vitest run --reporter=verbose",
"test:coverage": "vitest run --coverage",
"test": "vitest run",
"build": "vite build",
"preview": "vite preview",
"lint:eslint": "eslint --fix .",
Expand All @@ -27,44 +26,42 @@
"url": "https://github.com/fkworld/space/issues"
},
"homepage": "https://github.com/fkworld/space#readme",
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@ls-lint/ls-lint": "^2.1.0",
"@types/lodash": "^4.14.199",
"@types/papaparse": "^5.3.9",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/wicg-file-system-access": "^2020.9.8",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"@unocss/eslint-config": "^0.56.4",
"@vitest/coverage-c8": "^0.33.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"vitest": "^0.34.4"
},
"dependencies": {
"@ant-design/charts": "^1.4.2",
"@ant-design/colors": "^7.0.0",
"@ant-design/icons": "^5.2.6",
"@vitejs/plugin-react": "^4.0.4",
"@vitejs/plugin-react": "^4.1.1",
"ahooks": "^3.7.8",
"antd": "^5.9.1",
"antd": "^5.11.1",
"lodash": "^4.17.21",
"papaparse": "^5.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.16.0",
"react-router-dom": "^6.18.0",
"typescript": "^5.2.2",
"unocss": "^0.56.5",
"vite": "^4.4.9"
"vite": "^4.5.0"
},
"devDependencies": {
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@ls-lint/ls-lint": "^2.2.2",
"@types/lodash": "^4.14.201",
"@types/papaparse": "^5.3.11",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@types/wicg-file-system-access": "^2020.9.8",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@unocss/eslint-config": "^0.56.5",
"eslint": "^8.53.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"vitest": "^0.34.6"
}
}
Loading

0 comments on commit 350af08

Please sign in to comment.