Skip to content
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

Merged
merged 1 commit into from Sep 8, 2016

Conversation

ljharb
Copy link
Sponsor Contributor

@ljharb ljharb commented Sep 3, 2016

What issue does this pull request address?
#5805

What changes did you make? (Give an overview)

  • added getAllStrings and getAllTemplateLiterals to source-code
  • grouped both by line number in max-len, and ignored lines that contained strings/template literals, matching the options

Is there anything you'd like reviewers to focus on?
The overall approach.

@mention-bot
Copy link

@ljharb, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @nzakas and @kaicataldo to be potential reviewers

@eslintbot
Copy link

LGTM

@@ -185,6 +185,26 @@ SourceCode.prototype = {
},

/**
* Retrieves an array containing all strings (" or ') in the source code.
Copy link
Member

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?

Copy link
Sponsor Contributor Author

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.

@ljharb ljharb force-pushed the ljharb/max_len_ignore_strings branch from b09d7a5 to 5b0b368 Compare September 3, 2016 21:56
@eslintbot
Copy link

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 ')
Copy link
Member

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"?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, sounds good

@platinumazure
Copy link
Member

Raised a question about the use of Array.isArray(obj, propName). Everything else LGTM.

@ljharb ljharb force-pushed the ljharb/max_len_ignore_strings branch from 5b0b368 to 6f65ba8 Compare September 6, 2016 00:20
@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member

platinumazure commented Sep 6, 2016

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!

@ljharb
Copy link
Sponsor Contributor Author

ljharb commented Sep 6, 2016

@platinumazure done

@ljharb ljharb force-pushed the ljharb/max_len_ignore_strings branch from 6f65ba8 to 91df35f Compare September 6, 2016 00:33
@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member

Thanks, LGTM but would like another set of eyes on this.

@ljharb ljharb force-pushed the ljharb/max_len_ignore_strings branch from 91df35f to 26aaa2e Compare September 6, 2016 16:27
@eslintbot
Copy link

LGTM

@ilyavolodin
Copy link
Member

LGTM, but waiting another day for others to look

@platinumazure
Copy link
Member

@ilyavolodin What do you think? Is this ready to go?

@ilyavolodin ilyavolodin merged commit 6d97c18 into eslint:master Sep 8, 2016
@ljharb ljharb deleted the ljharb/max_len_ignore_strings branch September 8, 2016 17:29
jaylaw81 pushed a commit to appirio-digital/ads-best-practices that referenced this pull request Sep 19, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants