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-line-length rule #4169
fix max-line-length rule #4169
Conversation
So many changes, I don't understand what it does :( I wonder would this issue be fixed if it was updating RexExp to accept new lines: - const urlArgumentsLength = execall(/url\((.*)\)/gi, lineText).reduce(
+ const urlArgumentsLength = execall(/url\(([\s\S]*)\)/gi, lineText).reduce( |
vankop@5677f47 |
current code execute regex line-by-line thats why it falls ( |
const skippedSubStrings = []; | ||
let skippedSubStringsIndex = 0; | ||
|
||
EXCLUDED_PATTERNS.forEach(pattern => |
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.
all excluded patterns create array of excluded indexes, for instance:
url
(
"blabla"
)
will return [[7, 15]]
, where 7 is first "
and 15 is next after "blabla"
@@ -75,32 +116,21 @@ const rule = function(maxLength, options, context) { | |||
} | |||
|
|||
const rawLineLength = nextNewlineIndex - match.endIndex; | |||
const excludedLength = skippedSubStrings[skippedSubStringsIndex] |
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.
compute excluded substring length (for current line), for instance:
url(
\t\t"bla bla"\u0020);
will give excludedLength
equals to "bla bla".length
on line 2
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.
it is a bit tricky since
url("bla \
bla \
");
will give excludedLength
equals to "bla \\".length
on line 1
Math.min(end, endSubString) - Math.max(start, startSubString); | ||
|
||
// Current substring is out of range for next lines | ||
if (endSubString <= end) { |
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.
current line last index + 1 is over current excluded range end
]; | ||
|
||
// Excluded substring does not presented in current line | ||
if (end < startSubString) { |
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.
current excluded range is not presented on current line
} | ||
|
||
// Compute excluded substring size regarding to current line indexes | ||
const excluded = |
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.
Compute excluded substring size regarding to current line indexes =)
@hudochenkov i have add some explanation |
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.
LGTM
|
Fixes #4059
Nothing