-
Notifications
You must be signed in to change notification settings - Fork 919
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
Fix/3779: Adjust logic for 'never' scope-enum validation #3795
Fix/3779: Adjust logic for 'never' scope-enum validation #3795
Conversation
…pendency for @commitlint/load
@@ -1,139 +1,183 @@ | |||
import parse from '@commitlint/parse'; |
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 looks like a lot of changes, but in summary, I organized the old tests by use-case and they are still getting executed; in addition, I added more automated tests to cover all of the message types for the following cases for both always and never:
- Enum is empty (always passes for both always and never)
- Messages without scopes (always passes for both always and never)
- Always - messages with one or multiple scopes
- Never - messages with scopes
/cc @karl-run maybe can have a look as well Thanks @joberstein ! Without people like you projects like commitlint couldn't continue. |
when = 'always', | ||
value = [] | ||
) => { | ||
if (!parsed.scope) { | ||
if (!scope || !value.length) { |
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.
The value.length check was further down before; I can't reason out a case where "scopeEnum(..., 'never', [])" should fail, which was the original behavior, but just wanted to call this out.
value.length === 0 || | ||
scopeSegments.every((scope) => ensure.enum(scope, value)); | ||
if (when === 'never') { | ||
isValid = !messageScopes.some(isScopeInEnum); |
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.
Main logic change, essentially from "!messageScopes.every(isScopeInEnum)"
Thanks @joberstein ! |
Motivation and Context
Resolves issue #3779 - see for more context
Usage examples
How Has This Been Tested?
Types of changes
Checklist: