From 99f9267bcab393982717316322d35f139b540091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Tue, 24 Mar 2026 13:30:03 +0800 Subject: [PATCH] chore: configure lint-staged and commitlint --- .husky/commit-msg | 1 + .husky/pre-commit | 1 + .lintstagedrc.json | 8 ++++++++ commitlint.config.js | 23 +++++++++++++++++++++++ test-lint.js | 1 + 5 files changed, 34 insertions(+) create mode 100755 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 .lintstagedrc.json create mode 100644 commitlint.config.js create mode 100644 test-lint.js diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..0a4b97d --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +npx --no -- commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..2312dc5 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 0000000..052e381 --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,8 @@ +{ + "*.{js,jsx,ts,tsx}": [ + "eslint --fix" + ], + "*.{json,md}": [ + "eslint --fix" + ] +} diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..d5c281b --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,23 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'type-enum': [ + 2, + 'always', + [ + 'feat', + 'fix', + 'docs', + 'style', + 'refactor', + 'perf', + 'test', + 'chore', + 'revert', + 'build', + 'ci' + ] + ], + 'subject-case': [0] + } +}; diff --git a/test-lint.js b/test-lint.js new file mode 100644 index 0000000..a2248ef --- /dev/null +++ b/test-lint.js @@ -0,0 +1 @@ +console.log('test');