Skip to content

Commit

Permalink
Fix: Make max-len ignoreStrings ignore JSXText (fixes eslint#9954)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachx committed Feb 17, 2018
1 parent 883a2a2 commit 19d3dfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit 19d3dfe

Please sign in to comment.