footer-leading-blank should pass if the footer has a leading blank line
footer-leading-blank returns a warning if the footer has a leading blank line
and is present.
If no footer exists no warning is returned
Author: Gregor Adams <[email protected]>
Date: Thu Feb 22 16:32:55 2018 +0100
docs(plugins): fix old docs
Config -> Plugins
closes #21
16:40 $ commitlint -e
â§— input: docs(plugins): fix old docs
âš footer must have leading blank line [footer-leading-blank]
âš found 0 problems, 1 warnings
commitlint.config.js
{
"extends": [
"@commitlint/config-conventional"
]
}
| Executable | Version |
| ---: | :--- |
| commitlint --version | 6.1.0 |
| git --version | 2.16.1 |
| node --version | v8.9.4 |
This problem is also present in version 7.0.0. I had the warning with the following commit message:
feat: mail is now created by the supplied template function
Instead of supplying all mail fields in the queue the information from the queue is given to a
template function. This helps to prevent creating open mail servers that can be abused for spam.
Also refactored the tests to a more traditional style.
BREAKING CHANGE: The `template` option is required.
When I look at the pasted commit message I see some leading spaces, but I guess that's just formatting. When I git commit --amend that commit it opens in nano without leading spaces.
I'm also running into this issue. It happens whenever I'm adding any breaking change or issue #.
cz-customizable.7.0.0.I freed up some time and started debugging this issue. Thanks for providing examples, these were very clear. Basically, the issue is related to the multi-newline between the header/subject and body.
None of the existing tests for footer-leading-blank contained multiple newlines between the body and feature. This means that a commit like test: something\nbody, is being transformed to array ["something", "body"].
Now, if we take the first example (docs(plugins): fix old docs\n\nConfig -> Plugins\n\ncloses #21) and convert it to array we get something like this. ["fix old docs", "", "Config -> Plugins", "", "closes #21"]. I don't think these empty strings are wrong, they still correctly represents a new line. But the way the footer-leading-blank extracts the footer doesn't work as expected in this example.
On this line you can see that the footer is being extracted using the body's length. But it does not take possible extra whitelines (or "body offset") into account, it simply adds 1 which again is not correct for this example.
I've written a fix, an I'm creating a PR now! 😄
You can see the full differences in this table, pay close attention to the starting line of the body for both.
line | without double line | with double line
--- | --- | ---
0 | something | fix old docs
1 | body |
2 | | Config -> Plugins
3 | |
4 | | closes #21