Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

替换 husky,添加 biome #17390

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

49 changes: 49 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"ignoreUnknown": true
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"linter": {
"rules": {
"style": {
"noNonNullAssertion": "off"
},
"correctness": {
"useHookAtTopLevel": "error"
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
"formatter": {
"formatWithErrors": true,
"lineWidth": 100,
"indentStyle": "space"
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "single"
}
},
"css": {
"parser": {
"cssModules": true
},
"formatter": {
"enabled": true
},
"linter": {
"enabled": true
}
}
}
41 changes: 41 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# yaml-language-server:$schema=./node_modules/lefthook/schema.json
# https://evilmartians.github.io/lefthook/configuration/

pre-commit:
piped: true
jobs:
- name: Linting & Formatting
glob: "*.{ts,tsx,js,jsx,mjs,mts,json,jsonc,css}"
run: pnpm biome check --fix {staged_files} --reporter summary
stage_fixed: true

# - name: QA
# group:
# parallel: true
# jobs:
# - name: typecheck
# glob: "*.{ts,tsx}"
# run: pnpm tsc
# - name: test
# glob: "*.{ts,tsx}"
# run: pnpm run test

prepare-commit-msg:
commands:
commit:
skip:
- run: node -e "require('fs').readFileSync('.git/COMMIT_EDITMSG','utf8').trim()||process.exit(1)"
interactive: true
run: pnpm git-cz --hook
env:
LEFTHOOK: "0"

commit-msg:
commands:
commitlint:
run: pnpm commitlint --edit {1} --config commitlint.config.js

post-merge:
commands:
dependencies:
run: git diff --quiet HEAD@{$(echo 1)} -- pnpm-lock.yaml || pnpm install
24 changes: 8 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"author": "O2Team",
"private": true,
"license": "MIT",
"keywords": [
"taro"
],
"keywords": ["taro"],
"bugs": {
"url": "https://github.com/NervJS/taro/issues"
},
Expand All @@ -19,7 +17,7 @@
"main": "index.js",
"scripts": {
"preinstall": "npx only-allow pnpm",
"prepare": "husky install",
"prepare": "node -e \"try { require('child_process').execSync('git config --unset core.hookspath', {stdio: 'ignore'}); } catch (e) {}\" && lefthook install",
"build": "pnpm -r --filter=./packages/* prod",
"build:binding:debug": "pnpm --filter @tarojs/binding run build:debug",
"build:binding:release": "pnpm --filter @tarojs/binding run build",
Expand All @@ -37,15 +35,8 @@
"version:release": "pnpm --parallel -r --aggregate-output --filter=./{npm/**,crates/native_binding,packages/*} exec npm version ${npm_package_version}",
"version:git": "git add . && git commit -m \"chore(release): publish ${npm_package_version}\"",
"version:changelog": "conventional-changelog -p angular",
"artifacts": "pnpm --filter @tarojs/helper --filter @tarojs/binding run artifacts"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix"
],
"*.json": [
"prettier --write"
]
"artifacts": "pnpm --filter @tarojs/helper --filter @tarojs/binding run artifacts",
"commit": "git add -A && git commit -a --no-edit"
},
"taroTemp": [
"@types/babel__core",
Expand Down Expand Up @@ -79,6 +70,7 @@
"@babel/core": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/runtime": "^7.24.4",
"@biomejs/biome": "^1.9.4",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@rollup/plugin-alias": "^5.1.0",
Expand Down Expand Up @@ -128,7 +120,7 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-standard": "^4.0.1",
"husky": "^8.0.1",
"git-cz": "^4.9.0",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jest-environment-jsdom": "^29.6.4",
Expand All @@ -137,7 +129,7 @@
"jest-preset-stylelint": "^7.0.0",
"jest-taro-helper": "workspace:*",
"jsdom": "^24.0.0",
"lint-staged": "^13.0.2",
"lefthook": "^1.11.2",
"minimist": "^1.2.8",
"mkdirp": "^3.0.1",
"npm-run-all": "^4.1.2",
Expand All @@ -156,8 +148,8 @@
"stylelint-order": "^6.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.1",
"typescript": "~5.4.5",
"tslib": "^2.6.2",
"typescript": "~5.4.5",
"vitest": "^1.6.0"
},
"pnpm": {
Expand Down
Loading