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

Fix: Make max-len ignoreStrings ignore JSXText (fixes #9954) #9985

Merged
merged 2 commits into from Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/max-len.js
Expand Up @@ -213,7 +213,7 @@ module.exports = {
* @returns {ASTNode[]} An array of string nodes.
*/
function getAllStrings() {
return sourceCode.ast.tokens.filter(token => token.type === "String");
return sourceCode.ast.tokens.filter(token => token.type === "String" || token.type === "JSXText");
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/max-len.js
Expand Up @@ -109,6 +109,11 @@ ruleTester.run("max-len", rule, {
code: "var str = \"this is a very long string\\\nwith continuation\\\nand with another very very long continuation\\\nand ending\";",
options: [29, 4, { ignoreStrings: true }]
},
{
code: "var foo = <div className=\"this is a very long string\"></div>;",
options: [29, 4, { ignoreStrings: true }],
parserOptions: { ecmaFeatures: { jsx: true } }
},
{
code: "var foo = veryLongIdentifier;\nvar bar = `this is a very long string`;",
options: [29, 4, { ignoreTemplateLiterals: true }],
Expand Down