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: Make max-len ignoreStrings ignore JSXText (fixes #9954) #9985
Conversation
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.
Thanks for contributing to ESLint! This looks good to me, but I do have one question.
This change will make it so that text in between tags will also be ignored. Is this the desired behavior? The issue only mentions props, so I just wanted to double check.
Example:
var foo = <div className="this is a very long string">this is another very long string</div>;
I am not sure if it is desired behavior but I think var foo = <div className="this is a very long string"> short </div>; should be ignored but var foo = <div>this is another very long string</div>; should not be ignored (since this case is more avoidable and we usually expect strings to be in quotes) How about an additional check if the token is surrounded by quotes? |
Looked into this a little more, and given the description of the option (
I think we might be able to just check if the |
Updated to check if |
I agree with #9985 (comment); a child node is not a string, even tho it's also 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.
LGTM. Thanks for contributing to ESLint!
Thanks for contributing! |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
Fixes #9954.
What changes did you make? (Give an overview)
Previously,
getAllStrings
only filter for tokens with typeString
. The filter should check if the token type isJSXText
as well.Is there anything you'd like reviewers to focus on?
Nothing in particular.