Skip to content

Commit

Permalink
Fix: max-len: ignoreTemplateLiterals: handle 3+ lines (fixes #7125)…
Browse files Browse the repository at this point in the history
… (#7138)
  • Loading branch information
ljharb authored and btmills committed Sep 16, 2016
1 parent 660e091 commit 28ddcf8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rules/max-len.js
Expand Up @@ -235,8 +235,9 @@ module.exports = {
* @private
*/
function groupByLineNumber(acc, node) {
ensureArrayAndPush(acc, node.loc.start.line, node);
ensureArrayAndPush(acc, node.loc.end.line, node);
for (let i = node.loc.start.line; i <= node.loc.end.line; ++i) {
ensureArrayAndPush(acc, i, node);
}
return acc;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/max-len.js
Expand Up @@ -100,6 +100,10 @@ ruleTester.run("max-len", rule, {
code: "var str = \"this is a very long string\\\nwith continuation\";",
options: [29, 4, { ignoreStrings: true }]
},
{
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 = veryLongIdentifier;\nvar bar = `this is a very long string`;",
options: [29, 4, { ignoreTemplateLiterals: true }],
Expand All @@ -110,6 +114,11 @@ ruleTester.run("max-len", rule, {
options: [29, 4, { ignoreTemplateLiterals: true }],
parserOptions
},
{
code: "var foo = veryLongIdentifier;\nvar bar = `this is a very long string\nand this is another line that is very long\nand here is another\n and another!`;",
options: [29, 4, { ignoreTemplateLiterals: true }],
parserOptions
},

// check indented comment lines - https://github.com/eslint/eslint/issues/6322
{
Expand Down

0 comments on commit 28ddcf8

Please sign in to comment.