-
Notifications
You must be signed in to change notification settings - Fork 934
feat: allow scope-enum to also config delimiter #2407
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
Conversation
cc @escapedcat |
there is few things that are missing right now,
commitlint/@commitlint/prompt/src/library/utils.ts Lines 82 to 96 in baf1082
same for this piece of code: commitlint/@commitlint/prompt/src/library/get-prompt.ts Lines 119 to 121 in baf1082
currently there is no tests that validate configuration for prompt |
@armano2 I made the changes. I didn't change |
For some reasons the checks here don't start/complete. |
hmm I rebased but also don't know what's going on |
We had something similar before with this PR: #2224 (comment) |
hmm I tried but no dice it seems |
Ugh, this is confusing. I tried google but no luck. |
@escapedcat, this is not an issue, circleci was doing ~2-3 days ago https://status.circleci.com/incidents/0jqzs9bd1ff3, you should retrigger build to fix this |
export function enumRuleIsActive( | ||
rule: RuleEntry | ||
rule: RuleEntry<EnumRuleOptions> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is not valid, as rule, we should require RuleEntry, rn, you basically force to have correct values, than type-guard is semi useless, this works only because you force expected type mapping in getRules, and all guards are useless now
Can't find this PR in the list of pipelines: https://app.circleci.com/pipelines/github/conventional-changelog/commitlint |
): rule is | ||
| [string, Readonly<[RuleConfigSeverity, 'always']>] | ||
| [string, Readonly<[RuleConfigSeverity, 'always', unknown]>] { | ||
| [string, Readonly<[RuleConfigSeverity, 'always', C]>] { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
export function getRules<C = unknown>( | ||
prefix: string, | ||
rules: QualifiedRules | ||
): RuleEntry<C>[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function returns array of unknown rules and you can't know what types thy are going to be, all what you know is that prefix stats with something
!!(config = rule[1][2]) && | ||
(!enumConfigIsExtendable(config) | ||
? config.length > 0 | ||
: Array.isArray(config.values) && config.values.length > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!(config = rule[1][2]) && | |
(!enumConfigIsExtendable(config) | |
? config.length > 0 | |
: Array.isArray(config.values) && config.values.length > 0) | |
(Array.isArray(rule[1][2]) | |
? rule[1][2].length > 0 | |
: typeof rule[1][2] === 'object' && | |
'values' in rule[1][2] && | |
rule[1][2].length > 0) |
}; | ||
|
||
let enumRule = getRules('type', rules) | ||
let enumRule = getRules<EnumRuleOptions>('type', rules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of those forced types should be removed
const rules: any = { | ||
const rules: Record<string, RuleEntry<EnumRuleOptions>[1]> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
easiest will be pushing something to this branch, as it should retrigger build i added some comments about type guards, type guard should change type only for stuff that actualy is validated in function, we can't have getRules return X rule as it can cause issues -> this function returns all reles that are prefixed with something |
@@ -118,7 +121,7 @@ export default function getPrompt( | |||
if (enumRule) { | |||
const [, [, , enums]] = enumRule; | |||
|
|||
enums.forEach((enumerable) => { | |||
(enums as string[]).forEach((enumerable) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should not do typecasts as types should be correct here, you can do something like this
(enums as string[]).forEach((enumerable) => { | |
(Array.isArray(enums) ? enums : enums.values).forEach((enumerable) => { |
function enumConfigIsExtendable( | ||
config?: EnumRuleOptions | ||
): config is EnumRuleExtendableOptions { | ||
return !Array.isArray(config); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this guard is invalidas its only check is not any[]
@longlho would you be able to integrate aramanos feedback? If the checks still won't pass we can do the checks locally and merge it in anyways. Not sure what's the issue with circleci here or what we could do to make this work. |
sry I haven't got time to get back to this PR :( |
No worries, just re-open it once you find some time ❤️ |
When doing the research we missed that commitlint has some multi-scope predefined delimeters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarious by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we initially anticipated. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimeters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarious by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we initially anticipated. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimeters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarious by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we initially anticipated. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimeters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarious by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we wanted in the first place. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimiters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarious by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we wanted in the first place. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimiters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarios by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we wanted in the first place. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimiters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarios by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we wanted in the first place. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
When doing the research we missed that commitlint has some multi-scope predefined delimiters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarios by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we wanted in the first place. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
fix #2108
Allow scope-enum rule to also configure delimiter regex
Description
Motivation and Context
Usage examples
How Has This Been Tested?
Types of changes
Checklist: