Skip to content

Commit 3545cce

Browse files
committed
fix(cz-git): both check the scope empty rule use ruleIsNotApplicable
link #15
1 parent ba44c8d commit 3545cce

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/cz-git/src/loader.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
buildCommit,
1818
log,
1919
enumRuleIsActive,
20-
ruleIsActive,
20+
emptyRuleIsActive,
2121
getEnumList,
2222
getValueByCallBack
2323
} from "./until";
@@ -55,7 +55,7 @@ export const generateOptions = (clConfig: UserConfig): CommitizenGitOptions => {
5555
scopes: pkgConfig.scopes ?? clPromptConfig.scopes ?? getEnumList(clConfig?.rules?.["scope-enum"] as any),
5656
scopeOverrides: pkgConfig.scopeOverrides ?? clPromptConfig.scopeOverrides ?? defaultConfig.scopeOverrides,
5757
allowCustomScopes: pkgConfig.allowCustomScopes ?? clPromptConfig.allowCustomScopes ?? !enumRuleIsActive(clConfig?.rules?.["scope-enum"] as any),
58-
allowEmptyScopes: pkgConfig.allowEmptyScopes ?? clPromptConfig.allowEmptyScopes ?? !ruleIsActive(clConfig?.rules?.["scope-empty"] as any),
58+
allowEmptyScopes: pkgConfig.allowEmptyScopes ?? clPromptConfig.allowEmptyScopes ?? !emptyRuleIsActive(clConfig?.rules?.["scope-empty"] as any),
5959
customScopesAlign: pkgConfig.customScopesAlign ?? clPromptConfig.customScopesAlign ?? defaultConfig.customScopesAlign,
6060
customScopesAlias: pkgConfig.customScopesAlias ?? clPromptConfig.customScopesAlias ?? defaultConfig.customScopesAlias,
6161
emptyScopesAlias: pkgConfig.emptyScopesAlias ?? clPromptConfig.emptyScopesAlias ?? defaultConfig.emptyScopesAlias,

‎packages/cz-git/src/until/rules.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function ruleIsActive<T extends Rule>(
3636
}
3737

3838
/**
39-
* @description: rule is can ignore
39+
* @description: rule is effect.
4040
*/
4141
export function ruleIsNotApplicable(
4242
rule: Rule
@@ -50,7 +50,7 @@ export function ruleIsNotApplicable(
5050
}
5151

5252
/**
53-
* @description: rule is effect
53+
* @description: rule is can ignore
5454
*/
5555
export function ruleIsApplicable(
5656
rule: Rule
@@ -75,6 +75,10 @@ export function getEnumList(rule: Rule | undefined): string[] {
7575
return rule && Array.isArray(rule) && Array.isArray(rule[2]) ? rule[2] : [];
7676
}
7777

78+
export function emptyRuleIsActive(rule: Rule | undefined): boolean {
79+
return rule && Array.isArray(rule) ? ruleIsActive(rule) && ruleIsNotApplicable(rule) : false;
80+
}
81+
7882
/**
7983
* @example: getMaxLength(rules['max-header-length'] => 100)
8084
*/

0 commit comments

Comments
 (0)