fix(@vben/commitlint-config): scope is not suitable for scoped package names

pull/48/MERGE
vince 2024-07-08 22:41:08 +08:00
parent 04a1533a1e
commit d0edf3ca34
3 changed files with 35 additions and 11 deletions

View File

@ -31,6 +31,7 @@
"@commitlint/cli": "^19.3.0", "@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2", "@commitlint/config-conventional": "^19.2.2",
"@vben/node-utils": "workspace:*", "@vben/node-utils": "workspace:*",
"commitlint-plugin-function-rules": "^4.0.0",
"cz-git": "^1.9.3", "cz-git": "^1.9.3",
"czg": "^1.9.3" "czg": "^1.9.3"
} }

View File

@ -6,12 +6,8 @@ import { getPackagesSync } from '@vben/node-utils';
const { packages } = getPackagesSync(); const { packages } = getPackagesSync();
const pkgs = packages.map((pkg) => { const allowedScopes = [
return pkg.packageJson.name?.replace('@vben-core/', ''); ...packages.map((pkg) => pkg.packageJson.name),
});
const scopes = [
...pkgs,
'project', 'project',
'style', 'style',
'lint', 'lint',
@ -33,6 +29,7 @@ const scopeComplete = execSync('git status --porcelain || true')
const userConfig: UserConfig = { const userConfig: UserConfig = {
extends: ['@commitlint/config-conventional'], extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
prompt: { prompt: {
/** @use `pnpm commit :f` */ /** @use `pnpm commit :f` */
alias: { alias: {
@ -102,16 +99,28 @@ const userConfig: UserConfig = {
* ^^^^^^^^^^^^^^ * ^^^^^^^^^^^^^^
*/ */
'footer-leading-blank': [1, 'always'], 'footer-leading-blank': [1, 'always'],
/**
* type[scope]: [function] description
* ^^^^^
*/
'function-rules/scope-enum': [
2, // level: error
'always',
(parsed: { scope: string }) => {
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] * type[scope]: [function] description [No more than 108 characters]
* ^^^^^ * ^^^^^
*/ */
'header-max-length': [2, 'always', 108], 'header-max-length': [2, 'always', 108],
/**
* type[scope]: [function] description 'scope-enum': [0],
* ^^^^^
*/
'scope-enum': [2, 'always', scopes],
'subject-case': [0], 'subject-case': [0],
'subject-empty': [2, 'never'], 'subject-empty': [2, 'never'],
'type-empty': [2, 'never'], 'type-empty': [2, 'never'],

View File

@ -255,6 +255,9 @@ importers:
'@vben/node-utils': '@vben/node-utils':
specifier: workspace:* specifier: workspace:*
version: link:../../node-utils version: link:../../node-utils
commitlint-plugin-function-rules:
specifier: ^4.0.0
version: 4.0.0(@commitlint/lint@19.2.2)
cz-git: cz-git:
specifier: ^1.9.3 specifier: ^1.9.3
version: 1.9.3 version: 1.9.3
@ -3221,6 +3224,7 @@ packages:
'@ls-lint/ls-lint@2.2.3': '@ls-lint/ls-lint@2.2.3':
resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==} resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==}
cpu: [x64, arm64, s390x]
os: [darwin, linux, win32] os: [darwin, linux, win32]
hasBin: true hasBin: true
@ -4682,6 +4686,12 @@ packages:
resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==} resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==}
engines: {node: '>= 12.0.0'} engines: {node: '>= 12.0.0'}
commitlint-plugin-function-rules@4.0.0:
resolution: {integrity: sha512-ddZAgEm4MtgwHiPCb/mFpPeN2mW/doN7l14Lt9g2nFV3NpZVL0RJ6hFU/JJuEqRTVBlji/qmGzMeNR8qZ9BXfw==}
engines: {node: '>=20'}
peerDependencies:
'@commitlint/lint': '>=19 <20'
common-tags@1.8.2: common-tags@1.8.2:
resolution: {integrity: sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==} resolution: {integrity: sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==}
engines: {node: '>=4.0.0'} engines: {node: '>=4.0.0'}
@ -13689,6 +13699,10 @@ snapshots:
comment-parser@1.4.1: {} comment-parser@1.4.1: {}
commitlint-plugin-function-rules@4.0.0(@commitlint/lint@19.2.2):
dependencies:
'@commitlint/lint': 19.2.2
common-tags@1.8.2: {} common-tags@1.8.2: {}
commondir@1.0.1: {} commondir@1.0.1: {}