From bfdc0e0e6d5e47aa501f9b6fadd143d9c97cf00a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 24 六月 2026 17:40:39 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
internal/lint-configs/commitlint-config/index.mjs | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 153 insertions(+), 0 deletions(-)
diff --git a/internal/lint-configs/commitlint-config/index.mjs b/internal/lint-configs/commitlint-config/index.mjs
new file mode 100644
index 0000000..36c3b09
--- /dev/null
+++ b/internal/lint-configs/commitlint-config/index.mjs
@@ -0,0 +1,153 @@
+import { execSync } from 'node:child_process';
+
+import { getPackagesSync } from '@vben/node-utils';
+
+const { packages } = getPackagesSync();
+
+const allowedScopes = [
+ ...packages.map((pkg) => pkg.packageJson.name),
+ 'project',
+ 'style',
+ 'lint',
+ 'ci',
+ 'dev',
+ 'deploy',
+ 'other',
+];
+
+// precomputed scope
+const scopeComplete = execSync('git status --porcelain || true')
+ .toString()
+ .trim()
+ .split('\n')
+ .find((r) => ~r.indexOf('M src'))
+ ?.replaceAll(/(\/)/g, '%%')
+ ?.match(/src%%((\w|-)*)/)?.[1]
+ ?.replace(/s$/, '');
+
+/**
+ * @type {import('cz-git').UserConfig}
+ */
+const userConfig = {
+ extends: ['@commitlint/config-conventional'],
+ plugins: ['commitlint-plugin-function-rules'],
+ prompt: {
+ /** @use `pnpm commit :f` */
+ alias: {
+ b: 'build: bump dependencies',
+ c: 'chore: update config',
+ f: 'docs: fix typos',
+ r: 'docs: update README',
+ s: 'style: update code format',
+ },
+ allowCustomIssuePrefixs: false,
+ // scopes: [...scopes, 'mock'],
+ allowEmptyIssuePrefixs: false,
+ customScopesAlign: scopeComplete ? 'bottom' : 'top',
+ defaultScope: scopeComplete,
+ // English
+ typesAppend: [
+ { name: 'workflow: workflow improvements', value: 'workflow' },
+ { name: 'types: type definition file changes', value: 'types' },
+ ],
+
+ // 涓嫳鏂囧鐓х増
+ // messages: {
+ // type: '閫夋嫨浣犺鎻愪氦鐨勭被鍨� :',
+ // scope: '閫夋嫨涓�涓彁浜よ寖鍥� (鍙��):',
+ // customScope: '璇疯緭鍏ヨ嚜瀹氫箟鐨勬彁浜よ寖鍥� :',
+ // subject: '濉啓绠�鐭簿鐐肩殑鍙樻洿鎻忚堪 :\n',
+ // body: '濉啓鏇村姞璇︾粏鐨勫彉鏇存弿杩� (鍙��)銆備娇鐢� "|" 鎹㈣ :\n',
+ // breaking: '鍒椾妇闈炲吋瀹规�ч噸澶х殑鍙樻洿 (鍙��)銆備娇鐢� "|" 鎹㈣ :\n',
+ // footerPrefixsSelect: '閫夋嫨鍏宠仈issue鍓嶇紑 (鍙��):',
+ // customFooterPrefixs: '杈撳叆鑷畾涔塱ssue鍓嶇紑 :',
+ // footer: '鍒椾妇鍏宠仈issue (鍙��) 渚嬪: #31, #I3244 :\n',
+ // confirmCommit: '鏄惁鎻愪氦鎴栦慨鏀筩ommit ?',
+ // },
+ // types: [
+ // { value: 'feat', name: 'feat: 鏂板鍔熻兘' },
+ // { value: 'fix', name: 'fix: 淇缂洪櫡' },
+ // { value: 'docs', name: 'docs: 鏂囨。鍙樻洿' },
+ // { value: 'style', name: 'style: 浠g爜鏍煎紡' },
+ // { value: 'refactor', name: 'refactor: 浠g爜閲嶆瀯' },
+ // { value: 'perf', name: 'perf: 鎬ц兘浼樺寲' },
+ // { value: 'test', name: 'test: 娣诲姞鐤忔紡娴嬭瘯鎴栧凡鏈夋祴璇曟敼鍔�' },
+ // { value: 'build', name: 'build: 鏋勫缓娴佺▼銆佸閮ㄤ緷璧栧彉鏇� (濡傚崌绾� npm 鍖呫�佷慨鏀规墦鍖呴厤缃瓑)' },
+ // { value: 'ci', name: 'ci: 淇敼 CI 閰嶇疆銆佽剼鏈�' },
+ // { value: 'revert', name: 'revert: 鍥炴粴 commit' },
+ // { value: 'chore', name: 'chore: 瀵规瀯寤鸿繃绋嬫垨杈呭姪宸ュ叿鍜屽簱鐨勬洿鏀� (涓嶅奖鍝嶆簮鏂囦欢銆佹祴璇曠敤渚�)' },
+ // { value: 'wip', name: 'wip: 姝e湪寮�鍙戜腑' },
+ // { value: 'workflow', name: 'workflow: 宸ヤ綔娴佺▼鏀硅繘' },
+ // { value: 'types', name: 'types: 绫诲瀷瀹氫箟鏂囦欢淇敼' },
+ // ],
+ // emptyScopesAlias: 'empty: 涓嶅~鍐�',
+ // customScopesAlias: 'custom: 鑷畾涔�',
+ },
+ rules: {
+ /**
+ * type[scope]: [function] description
+ *
+ * ^^^^^^^^^^^^^^ empty line.
+ * - Something here
+ */
+ 'body-leading-blank': [2, 'always'],
+ /**
+ * type[scope]: [function] description
+ *
+ * - something here
+ *
+ * ^^^^^^^^^^^^^^
+ */
+ 'footer-leading-blank': [1, 'always'],
+ /**
+ * type[scope]: [function] description
+ * ^^^^^
+ */
+ 'function-rules/scope-enum': [
+ 2, // level: error
+ 'always',
+ (parsed) => {
+ if (!parsed.scope || allowedScopes.includes(parsed.scope)) {
+ return [true];
+ }
+
+ return [false, `scope must be one of ${allowedScopes.join(', ')}`];
+ },
+ ],
+ /**
+ * type[scope]: [function] description [No more than 108 characters]
+ * ^^^^^
+ */
+ 'header-max-length': [2, 'always', 108],
+
+ 'scope-enum': [0],
+ 'subject-case': [0],
+ 'subject-empty': [2, 'never'],
+ 'type-empty': [2, 'never'],
+ /**
+ * type[scope]: [function] description
+ * ^^^^
+ */
+ 'type-enum': [
+ 2,
+ 'always',
+ [
+ 'feat',
+ 'fix',
+ 'perf',
+ 'style',
+ 'docs',
+ 'test',
+ 'refactor',
+ 'build',
+ 'ci',
+ 'chore',
+ 'revert',
+ 'types',
+ 'release',
+ ],
+ ],
+ },
+};
+
+export default userConfig;
--
Gitblit v1.9.3