Fix/3779: Adjust logic for 'never' scope-enum validation#3795
Fix/3779: Adjust logic for 'never' scope-enum validation#3795escapedcat merged 11 commits intoconventional-changelog:masterfrom
Conversation
…pendency for @commitlint/load
| @@ -1,139 +1,183 @@ | |||
| import parse from '@commitlint/parse'; | |||
There was a problem hiding this comment.
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. |
| value = [] | ||
| ) => { | ||
| if (!parsed.scope) { | ||
| if (!scope || !value.length) { |
There was a problem hiding this comment.
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.
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: