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: max-len will warn indented comment lines (fixes #6322) #6324
Conversation
LGTM |
@@ -157,10 +157,12 @@ module.exports = { | |||
*/ | |||
function isFullLineComment(line, lineNumber, comment) { | |||
var start = comment.loc.start, | |||
end = comment.loc.end; | |||
end = comment.loc.end, | |||
isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim(); |
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.
Reusing this from the no-inline-comments
rule
eslint/lib/rules/no-inline-comments.js
Line 39 in cd1b057
var preamble = startLine.slice(0, node.loc.start.column).trim(); |
@@ -157,11 +157,14 @@ module.exports = { | |||
*/ | |||
function isFullLineComment(line, lineNumber, comment) { | |||
var start = comment.loc.start, | |||
end = comment.loc.end; | |||
end = comment.loc.end, | |||
isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim(), |
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.
Reusing this from the no-inline-comments rule
eslint/lib/rules/no-inline-comments.js
Line 39 in cd1b057
var preamble = startLine.slice(0, node.loc.start.column).trim(); |
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.
That's a pretty arcane bit of code- would it be worth extracting that to a place like ast-utils?
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.
Could be - it's pretty niche (really only useful to see if the comment is the first thing on that line)
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.
Other rules (such as lines-around-comment) are able to use sourceCode.getTokenBefore
and could check the location that way - in this rule I only had access to the line, so I thought this was a pretty elegant solution.
Not sure why my comments got all messed up - it's hiding the wrong one for some reason.
LGTM |
LGTM |
No description provided.