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
Improve inline comment merging #4950
Conversation
This now only starts a merge when the comment begins with `stylelint-` and either the first line contains `--` or the second line starts with `--`. The merge will end whenever another line starts with `stylelint-` to allow for adjacent stylelint commands.
lib/assignDisabledRanges.js
Outdated
if ( | ||
!( | ||
isInlineComment(comment) && | ||
comment.text.startsWith('stylelint-') && |
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 will match commits with stylelint-whatever
. Users could put stylelint plugins names in comments. I think we should change comments starting with stylelint-disable
and stylelint-enable
to eliminate problems.
Same applies for a stylelint-
check below.
lib/assignDisabledRanges.js
Outdated
* @param {PostcssComment} comment | ||
*/ | ||
function isStylelintCommand(comment) { | ||
return /^stylelint-(disable|enable)/.test(comment.text); |
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.
I just remembered that we have disableCommand
and enableCommand
in this file. I think we should use them instead of hardcoded values. What do you think?
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.
Yeah, that makes sense. Should I just call startsWith
with both or should I put a compiled RegExp in a global variable and use that? (since a regex literal couldn't be used in this case)
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.
I would choose startsWith
because it's easier to understand.
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.
Great job!
I've checked on https://github.com/twbs/bootstrap repository this changes. No more issues!
|
Fixes #4937.
This now only starts a merge when the comment begins with
stylelint-
and either the first line contains--
or the second line starts with--
.The merge will end whenever another line starts with
stylelint-
to allow for adjacent stylelint commands.