-
Notifications
You must be signed in to change notification settings - Fork 913
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
Empty body with breaking changes field present #2813
Comments
I believe this particular row is the issue:
I think that skipping a body message actually puts an empty string to the variable and therefore the mentioned row will always evaluate as "not falsy (it is not null nor undefined)" for the body, hence skipping breakingBody and issuesBody. Simply changing it from "??" to "||" should solve this issue. The following was taken from the official documentation of nullish coalescing operators. Please, check the last example as it shows this behavior in action. Assigning a default value to a variableEarlier, when one wanted to assign a default value to a variable, a common pattern was to use the logical OR operator (||):
However, due to || being a boolean logical operator, the left hand-side operand was coerced to a boolean for the evaluation and any falsy value (0, '', NaN, null, undefined) was not returned. This behavior may cause unexpected consequences if you consider 0, '', or NaN as valid values.
The nullish coalescing operator avoids this pitfall by only returning the second operand when the first one evaluates to either null or undefined (but no other falsy values):
|
Hey @honzamelena , thanks for the digging! Wanna give it a try and create PR for this? |
@escapedcat I'll try to have a look at it in the upcoming days. |
Will be in the next release |
Expected Behavior
body
field empty.breaking changes
(y) optionbreakingBody
message be displayedbody
text be added to commit messageCurrent Behavior
breakingBody
promptAffected packages
Possible Solution
Steps to Reproduce (for bugs)
git commit
y
when prompt ask if there are breaking changesbreakingBody
message is displayedcommitlint.config.js
```js ```Context
Your Environment
commitlint --version
git --version
node --version
The text was updated successfully, but these errors were encountered: