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
New: max-len
: ignoreStrings
+ignoreTemplateLiterals
(fixes #5805)
#7049
New: max-len
: ignoreStrings
+ignoreTemplateLiterals
(fixes #5805)
#7049
Conversation
@ljharb, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @nzakas and @kaicataldo to be potential reviewers |
LGTM |
@@ -185,6 +185,26 @@ SourceCode.prototype = { | |||
}, | |||
|
|||
/** | |||
* Retrieves an array containing all strings (" or ') in the source code. |
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 object is part of the public API, and I'd rather not expose these methods. Can you move these into local functions in the rule?
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.
Sure, I'd figured it was cleaner to expose it here, but I'll move them in.
b09d7a5
to
5b0b368
Compare
LGTM |
@@ -23,6 +23,8 @@ This rule has a number or object option: | |||
* `"ignoreComments": true` ignores all trailing comments and comments on their own line | |||
* `"ignoreTrailingComments": true` ignores only trailing comments | |||
* `"ignoreUrls": true` ignores lines that contain a URL | |||
* `"ignoreStrings": true` ignores lines that contain a string (" or ') |
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.
Maybe "contain a double-quoted or single-quoted string"?
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.
sure, sounds good
Raised a question about the use of |
5b0b368
to
6f65ba8
Compare
LGTM |
Thanks! Just one more thing (and I only thought of this just now, sorry): Can we test with a line continuation somehow? Since the code in each test case is itself a string, I think that would look something like this: "var str = \"a long string\\\nwith continuation\"";
// -----------------------^ Line continuation backslash
// -------------------------^ Literal newline within the string Thanks a lot! |
@platinumazure done |
6f65ba8
to
91df35f
Compare
LGTM |
Thanks, LGTM but would like another set of eyes on this. |
91df35f
to
26aaa2e
Compare
LGTM |
LGTM, but waiting another day for others to look |
@ilyavolodin What do you think? Is this ready to go? |
What issue does this pull request address?
#5805
What changes did you make? (Give an overview)
getAllStrings
andgetAllTemplateLiterals
to source-codemax-len
, and ignored lines that contained strings/template literals, matching the optionsIs there anything you'd like reviewers to focus on?
The overall approach.