From 6ef1bd8cead604d4c5fabd0935d944b1dcf96ab2 Mon Sep 17 00:00:00 2001 From: Anix Date: Mon, 18 May 2020 14:03:52 +0000 Subject: [PATCH 1/6] Update: max-lines reporting loc refactore (refs #12334) --- lib/rules/max-lines.js | 41 +++++-- tests/lib/rules/max-lines.js | 211 +++++++++++++++++++++++++++++++++-- 2 files changed, 232 insertions(+), 20 deletions(-) diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 299377bc2dd..4ee3e5b9231 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -53,7 +53,8 @@ module.exports = { } ], messages: { - exceed: "File has too many lines ({{actual}}). Maximum allowed is {{max}}." + exceed: + "File has too many lines ({{actual}}). Maximum allowed is {{max}}." } }, @@ -61,7 +62,10 @@ module.exports = { const option = context.options[0]; let max = 300; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max")) { + if ( + typeof option === "object" && + Object.prototype.hasOwnProperty.call(option, "max") + ) { max = option.max; } else if (typeof option === "number") { max = option; @@ -94,7 +98,9 @@ module.exports = { token = comment; do { - token = sourceCode.getTokenBefore(token, { includeComments: true }); + token = sourceCode.getTokenBefore(token, { + includeComments: true + }); } while (isCommentNodeType(token)); if (token && astUtils.isTokenOnSameLine(token, comment)) { @@ -103,7 +109,9 @@ module.exports = { token = comment; do { - token = sourceCode.getTokenAfter(token, { includeComments: true }); + token = sourceCode.getTokenAfter(token, { + includeComments: true + }); } while (isCommentNodeType(token)); if (token && astUtils.isTokenOnSameLine(comment, token)) { @@ -118,7 +126,10 @@ module.exports = { return { "Program:exit"() { - let lines = sourceCode.lines.map((text, i) => ({ lineNumber: i + 1, text })); + let lines = sourceCode.lines.map((text, i) => ({ + lineNumber: i + 1, + text + })); if (skipBlankLines) { lines = lines.filter(l => l.text.trim() !== ""); @@ -127,14 +138,28 @@ module.exports = { if (skipComments) { const comments = sourceCode.getAllComments(); - const commentLines = lodash.flatten(comments.map(comment => getLinesWithoutCode(comment))); + const commentLines = lodash.flatten( + comments.map(comment => getLinesWithoutCode(comment)) + ); - lines = lines.filter(l => !lodash.includes(commentLines, l.lineNumber)); + lines = lines.filter( + l => !lodash.includes(commentLines, l.lineNumber) + ); } + const loc = { + start: { + line: max + 1, + column: 0 + }, + end: { + line: lines.length, + column: 0 + } + }; if (lines.length > max) { context.report({ - loc: { line: 1, column: 0 }, + loc, messageId: "exceed", data: { max, diff --git a/tests/lib/rules/max-lines.js b/tests/lib/rules/max-lines.js index 2929551539a..404188ecfea 100644 --- a/tests/lib/rules/max-lines.js +++ b/tests/lib/rules/max-lines.js @@ -9,10 +9,8 @@ //------------------------------------------------------------------------------ const rule = require("../../../lib/rules/max-lines"), - { RuleTester } = require("../../../lib/rule-tester"); - //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ @@ -79,17 +77,38 @@ ruleTester.run("max-lines", rule, { { code: "var xyz;\nvar xyz;\nvar xyz;", options: [2], - errors: [{ messageId: "exceed", data: { max: 2, actual: 3 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 3 }, + line: 3, + endLine: 3 + } + ] }, { code: "/* a multiline comment\n that goes to many lines*/\nvar xy;\nvar xy;", options: [2], - errors: [{ messageId: "exceed", data: { max: 2, actual: 4 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + endLine: 4 + } + ] }, { code: "//a single line comment\nvar xy;\nvar xy;", options: [2], - errors: [{ messageId: "exceed", data: { max: 2, actual: 3 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 3 }, + line: 3, + endLine: 3 + } + ] }, { code: [ @@ -100,7 +119,14 @@ ruleTester.run("max-lines", rule, { "var y;" ].join("\n"), options: [{ max: 2 }], - errors: [{ messageId: "exceed", data: { max: 2, actual: 5 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 5 }, + line: 3, + endLine: 5 + } + ] }, { code: [ @@ -114,7 +140,14 @@ ruleTester.run("max-lines", rule, { " long comment*/" ].join("\n"), options: [{ max: 2, skipComments: true }], - errors: [{ messageId: "exceed", data: { max: 2, actual: 4 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + endLine: 4 + } + ] }, { code: [ @@ -123,7 +156,14 @@ ruleTester.run("max-lines", rule, { "var z;" ].join("\n"), options: [{ max: 2, skipComments: true }], - errors: [{ messageId: "exceed", data: { max: 2, actual: 3 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 3 }, + line: 3, + endLine: 3 + } + ] }, { code: [ @@ -133,7 +173,14 @@ ruleTester.run("max-lines", rule, { "var z;" ].join("\n"), options: [{ max: 2, skipComments: true }], - errors: [{ messageId: "exceed", data: { max: 2, actual: 3 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 3 }, + line: 3, + endLine: 3 + } + ] }, { code: [ @@ -147,17 +194,157 @@ ruleTester.run("max-lines", rule, { " long comment*/" ].join("\n"), options: [{ max: 2, skipBlankLines: true }], - errors: [{ messageId: "exceed", data: { max: 2, actual: 6 } }] + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 6 }, + line: 3, + endLine: 6 + } + ] }, { code: "AAAAAAAA\n".repeat(301).trim(), options: [{}], - errors: [{ messageId: "exceed", data: { max: 300, actual: 301 } }] + errors: [ + { + messageId: "exceed", + data: { max: 300, actual: 301 }, + line: 301, + endLine: 301 + } + ] }, { code: "A", options: [{ max: 0 }], - errors: [{ messageId: "exceed", data: { max: 0, actual: 1 } }] + errors: [ + { + messageId: "exceed", + data: { max: 0, actual: 1 }, + line: 1, + endLine: 1 + } + ] + }, + { + code: ["var a = 'a'; ", "var x", "var c;", "console.log"].join( + "\n" + ), + options: [{ max: 2 }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + column: 1, + endLine: 4, + endColumn: 1 + } + ] + }, + { + code: "var a = 'a',\nc,\nx;\r", + options: [{ max: 2 }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + column: 1, + endLine: 4, + endColumn: 1 + } + ] + }, + { + code: "var a = 'a',\nc,\nx;\n", + options: [{ max: 2 }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + column: 1, + endLine: 4, + endColumn: 1 + } + ] + }, + { + code: "\n\nvar a = 'a',\nc,\nx;\n", + options: [{ max: 2, skipBlankLines: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 3 }, + line: 3, + column: 1, + endLine: 3, + endColumn: 1 + } + ] + }, + { + code: [ + "var a = 'a'; ", + "var x", + "var c;", + "console.log", + "// some block ", + "// comments" + ].join("\n"), + options: [{ max: 2, skipComments: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + column: 1, + endLine: 4, + endColumn: 1 + } + ] + }, + { + code: [ + "var a = 'a'; ", + "var x", + "var c;", + "console.log", + "/* block comments */" + ].join("\n"), + options: [{ max: 2, skipComments: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + column: 1, + endLine: 4, + endColumn: 1 + } + ] + }, + { + code: [ + "var a = 'a'; ", + "var x", + "var c;", + "console.log", + "/** block \n\n comments */" + ].join("\n"), + options: [{ max: 2, skipComments: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 3, + column: 1, + endLine: 4, + endColumn: 1 + } + ] } ] }); From a04a769a3fb10ff31b22ef05c12b80d51b238989 Mon Sep 17 00:00:00 2001 From: Anix Date: Thu, 21 May 2020 14:50:22 +0000 Subject: [PATCH 2/6] Update: changed loc position --- lib/rules/max-lines.js | 13 ++- tests/lib/rules/max-lines.js | 156 +++++++++++++++++++++++++++-------- 2 files changed, 132 insertions(+), 37 deletions(-) diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 4ee3e5b9231..85d3d58dab0 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -131,6 +131,8 @@ module.exports = { text })); + let startLine = 0; + if (skipBlankLines) { lines = lines.filter(l => l.text.trim() !== ""); } @@ -146,13 +148,20 @@ module.exports = { l => !lodash.includes(commentLines, l.lineNumber) ); } + + lines.forEach((line, i) => { + if (max + 1 === i + 1) { + startLine = line.lineNumber; + } + }); + const loc = { start: { - line: max + 1, + line: startLine, column: 0 }, end: { - line: lines.length, + line: sourceCode.lines.length + 1, column: 0 } }; diff --git a/tests/lib/rules/max-lines.js b/tests/lib/rules/max-lines.js index 404188ecfea..782b79a9f5b 100644 --- a/tests/lib/rules/max-lines.js +++ b/tests/lib/rules/max-lines.js @@ -82,7 +82,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 3 + endLine: 4 } ] }, @@ -94,7 +94,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 + endLine: 5 } ] }, @@ -106,7 +106,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 3 + endLine: 4 } ] }, @@ -124,7 +124,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 5 }, line: 3, - endLine: 5 + endLine: 6 } ] }, @@ -144,8 +144,8 @@ ruleTester.run("max-lines", rule, { { messageId: "exceed", data: { max: 2, actual: 4 }, - line: 3, - endLine: 4 + line: 4, + endLine: 9 } ] }, @@ -161,7 +161,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 3 + endLine: 4 } ] }, @@ -177,8 +177,8 @@ ruleTester.run("max-lines", rule, { { messageId: "exceed", data: { max: 2, actual: 3 }, - line: 3, - endLine: 3 + line: 4, + endLine: 5 } ] }, @@ -198,8 +198,8 @@ ruleTester.run("max-lines", rule, { { messageId: "exceed", data: { max: 2, actual: 6 }, - line: 3, - endLine: 6 + line: 4, + endLine: 9 } ] }, @@ -211,7 +211,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 300, actual: 301 }, line: 301, - endLine: 301 + endLine: 302 } ] }, @@ -223,7 +223,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 0, actual: 1 }, line: 1, - endLine: 1 + endLine: 2 } ] }, @@ -237,9 +237,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - column: 1, - endLine: 4, - endColumn: 1 + + endLine: 5 + } ] }, @@ -251,9 +251,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - column: 1, - endLine: 4, - endColumn: 1 + + endLine: 5 + } ] }, @@ -265,9 +265,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - column: 1, - endLine: 4, - endColumn: 1 + + endLine: 5 + } ] }, @@ -278,10 +278,10 @@ ruleTester.run("max-lines", rule, { { messageId: "exceed", data: { max: 2, actual: 3 }, - line: 3, - column: 1, - endLine: 3, - endColumn: 1 + line: 5, + + endLine: 7 + } ] }, @@ -300,9 +300,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - column: 1, - endLine: 4, - endColumn: 1 + + endLine: 7 + } ] }, @@ -320,9 +320,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - column: 1, - endLine: 4, - endColumn: 1 + + endLine: 6 + } ] }, @@ -340,11 +340,97 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - column: 1, - endLine: 4, - endColumn: 1 + + endLine: 8 + } ] + }, + { + code: [ + "var a = 'a'; ", + "var x", + "\n", + "var c;", + "console.log", + "\n" + ].join("\n"), + options: [{ max: 2, skipBlankLines: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 5, + + endLine: 9 + + } + ] + }, + { + code: [ + "var a = 'a'; ", + "\n", + "var x", + "var c;", + "console.log", + "\n" + ].join("\n"), + options: [{ max: 2, skipBlankLines: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 5, + + endLine: 9 + + } + ] + }, + { + code: [ + "var a = 'a'; ", + "//", + "var x", + "var c;", + "console.log", + "//" + ].join("\n"), + options: [{ max: 2, skipComments: true }], + errors: [ + { + messageId: "exceed", + data: { max: 2, actual: 4 }, + line: 4, + + endLine: 7 + + } + ] + }, + { + code: ["// hello world", "/*hello", " world 2 */", "var a,", "b", "// hh", "c,", "e,", "f;"].join("\n"), + options: [{ max: 2, skipComments: true }], + errors: [{ + line: 7, + + data: { max: 2, actual: 5 }, + messageId: "exceed", + endLine: 10 + + }] + }, + { + code: ["", "var x = '';", "", "// comment", "", "var b = '',", "c,", "d,", "e", "", "// comment"].join("\n"), + options: [{ max: 2, skipComments: true, skipBlankLines: true }], + errors: [{ + data: { max: 2, actual: 5 }, + messageId: "exceed", + line: 7, + endLine: 12 + }] } + ] }); From fb61944e35407b4f9965a3d015e841846a79b4ff Mon Sep 17 00:00:00 2001 From: Anix Date: Mon, 25 May 2020 07:25:43 +0000 Subject: [PATCH 3/6] Update: updated startline logic and end loc --- lib/rules/max-lines.js | 13 +++++------ tests/lib/rules/max-lines.js | 44 ++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 85d3d58dab0..83028af5a64 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -149,11 +149,10 @@ module.exports = { ); } - lines.forEach((line, i) => { - if (max + 1 === i + 1) { - startLine = line.lineNumber; - } - }); + + if (lines.length > max) { + startLine = lines[max].lineNumber; + } const loc = { start: { @@ -161,8 +160,8 @@ module.exports = { column: 0 }, end: { - line: sourceCode.lines.length + 1, - column: 0 + line: sourceCode.lines.length, + column: lodash.last(sourceCode.lines).length } }; diff --git a/tests/lib/rules/max-lines.js b/tests/lib/rules/max-lines.js index 782b79a9f5b..744e5d9d709 100644 --- a/tests/lib/rules/max-lines.js +++ b/tests/lib/rules/max-lines.js @@ -82,7 +82,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 4 + endLine: 3 } ] }, @@ -94,7 +94,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 5 + endLine: 4 } ] }, @@ -106,7 +106,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 4 + endLine: 3 } ] }, @@ -124,7 +124,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 5 }, line: 3, - endLine: 6 + endLine: 5 } ] }, @@ -145,7 +145,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 4, - endLine: 9 + endLine: 8 } ] }, @@ -161,7 +161,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 4 + endLine: 3 } ] }, @@ -178,7 +178,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 4, - endLine: 5 + endLine: 4 } ] }, @@ -199,7 +199,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 6 }, line: 4, - endLine: 9 + endLine: 8 } ] }, @@ -211,7 +211,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 300, actual: 301 }, line: 301, - endLine: 302 + endLine: 301 } ] }, @@ -223,7 +223,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 0, actual: 1 }, line: 1, - endLine: 2 + endLine: 1 } ] }, @@ -238,7 +238,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 3, - endLine: 5 + endLine: 4 } ] @@ -252,7 +252,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 3, - endLine: 5 + endLine: 4 } ] @@ -266,7 +266,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 3, - endLine: 5 + endLine: 4 } ] @@ -280,7 +280,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 3 }, line: 5, - endLine: 7 + endLine: 6 } ] @@ -301,7 +301,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 3, - endLine: 7 + endLine: 6 } ] @@ -321,7 +321,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 3, - endLine: 6 + endLine: 5 } ] @@ -341,7 +341,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 3, - endLine: 8 + endLine: 7 } ] @@ -362,7 +362,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 5, - endLine: 9 + endLine: 8 } ] @@ -383,7 +383,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 5, - endLine: 9 + endLine: 8 } ] @@ -404,7 +404,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 4 }, line: 4, - endLine: 7 + endLine: 6 } ] @@ -417,7 +417,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 5 }, messageId: "exceed", - endLine: 10 + endLine: 9 }] }, @@ -428,7 +428,7 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 5 }, messageId: "exceed", line: 7, - endLine: 12 + endLine: 11 }] } From 2000e42d8cc023add5715757d46bdafc8d93b449 Mon Sep 17 00:00:00 2001 From: Anix Date: Wed, 27 May 2020 07:13:39 +0000 Subject: [PATCH 4/6] Chore: refactor --- lib/rules/max-lines.js | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 83028af5a64..f33adbdb5b6 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -131,8 +131,6 @@ module.exports = { text })); - let startLine = 0; - if (skipBlankLines) { lines = lines.filter(l => l.text.trim() !== ""); } @@ -149,23 +147,18 @@ module.exports = { ); } - if (lines.length > max) { - startLine = lines[max].lineNumber; - } - - const loc = { - start: { - line: startLine, - column: 0 - }, - end: { - line: sourceCode.lines.length, - column: lodash.last(sourceCode.lines).length - } - }; + const loc = { + start: { + line: lines[max].lineNumber, + column: 0 + }, + end: { + line: sourceCode.lines.length, + column: lodash.last(sourceCode.lines).length + } + }; - if (lines.length > max) { context.report({ loc, messageId: "exceed", From e52159c314091421d27edc8a443ba13296899d8f Mon Sep 17 00:00:00 2001 From: Anix Date: Sat, 13 Jun 2020 17:21:15 +0000 Subject: [PATCH 5/6] Chore: tests error property ordering --- tests/lib/rules/max-lines.js | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/tests/lib/rules/max-lines.js b/tests/lib/rules/max-lines.js index 744e5d9d709..0e3268a4542 100644 --- a/tests/lib/rules/max-lines.js +++ b/tests/lib/rules/max-lines.js @@ -237,9 +237,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 - } ] }, @@ -251,9 +249,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 - } ] }, @@ -265,9 +261,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 - } ] }, @@ -279,9 +273,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 5, - endLine: 6 - } ] }, @@ -300,9 +292,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 6 - } ] }, @@ -320,9 +310,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 5 - } ] }, @@ -340,9 +328,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 7 - } ] }, @@ -361,9 +347,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 5, - endLine: 8 - } ] }, @@ -382,9 +366,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 5, - endLine: 8 - } ] }, @@ -403,9 +385,7 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 4, - endLine: 6 - } ] }, @@ -413,10 +393,9 @@ ruleTester.run("max-lines", rule, { code: ["// hello world", "/*hello", " world 2 */", "var a,", "b", "// hh", "c,", "e,", "f;"].join("\n"), options: [{ max: 2, skipComments: true }], errors: [{ - line: 7, - data: { max: 2, actual: 5 }, messageId: "exceed", + line: 7, endLine: 9 }] From 92e4b3d006787c4a09fba4979d460e6dc77f3ed1 Mon Sep 17 00:00:00 2001 From: Anix Date: Sun, 14 Jun 2020 07:40:32 +0000 Subject: [PATCH 6/6] Chore: tests re-ordering --- tests/lib/rules/max-lines.js | 88 +++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 22 deletions(-) diff --git a/tests/lib/rules/max-lines.js b/tests/lib/rules/max-lines.js index 0e3268a4542..b7c255e9322 100644 --- a/tests/lib/rules/max-lines.js +++ b/tests/lib/rules/max-lines.js @@ -82,7 +82,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 3 + column: 1, + endLine: 3, + endColumn: 9 } ] }, @@ -94,7 +96,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 + column: 1, + endLine: 4, + endColumn: 8 } ] }, @@ -106,7 +110,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 3 + column: 1, + endLine: 3, + endColumn: 8 } ] }, @@ -124,7 +130,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 5 }, line: 3, - endLine: 5 + column: 1, + endLine: 5, + endColumn: 7 } ] }, @@ -145,7 +153,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 4, - endLine: 8 + column: 1, + endLine: 8, + endColumn: 16 } ] }, @@ -161,7 +171,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 3, - endLine: 3 + column: 1, + endLine: 3, + endColumn: 7 } ] }, @@ -178,7 +190,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 4, - endLine: 4 + column: 1, + endLine: 4, + endColumn: 7 } ] }, @@ -199,7 +213,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 6 }, line: 4, - endLine: 8 + column: 1, + endLine: 8, + endColumn: 16 } ] }, @@ -211,7 +227,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 300, actual: 301 }, line: 301, - endLine: 301 + column: 1, + endLine: 301, + endColumn: 9 } ] }, @@ -223,7 +241,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 0, actual: 1 }, line: 1, - endLine: 1 + column: 1, + endLine: 1, + endColumn: 2 } ] }, @@ -237,7 +257,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 + column: 1, + endLine: 4, + endColumn: 12 } ] }, @@ -249,7 +271,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 + column: 1, + endLine: 4, + endColumn: 1 } ] }, @@ -261,7 +285,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 4 + column: 1, + endLine: 4, + endColumn: 1 } ] }, @@ -273,7 +299,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 3 }, line: 5, - endLine: 6 + column: 1, + endLine: 6, + endColumn: 1 } ] }, @@ -292,7 +320,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 6 + column: 1, + endLine: 6, + endColumn: 12 } ] }, @@ -310,7 +340,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 5 + column: 1, + endLine: 5, + endColumn: 21 } ] }, @@ -328,7 +360,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 3, - endLine: 7 + column: 1, + endLine: 7, + endColumn: 13 } ] }, @@ -347,7 +381,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 5, - endLine: 8 + column: 1, + endLine: 8, + endColumn: 1 } ] }, @@ -366,7 +402,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 5, - endLine: 8 + column: 1, + endLine: 8, + endColumn: 1 } ] }, @@ -385,7 +423,9 @@ ruleTester.run("max-lines", rule, { messageId: "exceed", data: { max: 2, actual: 4 }, line: 4, - endLine: 6 + column: 1, + endLine: 6, + endColumn: 3 } ] }, @@ -396,7 +436,9 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 5 }, messageId: "exceed", line: 7, - endLine: 9 + column: 1, + endLine: 9, + endColumn: 3 }] }, @@ -407,7 +449,9 @@ ruleTester.run("max-lines", rule, { data: { max: 2, actual: 5 }, messageId: "exceed", line: 7, - endLine: 11 + column: 1, + endLine: 11, + endColumn: 11 }] }