]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/rules/max-lines-per-function.js
import 8.23.1 source
[pve-eslint.git] / eslint / lib / rules / max-lines-per-function.js
index c1b945ca11abeb2926b0240d5e841810a8efc6a1..fad646cc0c31c7c9391648822a2b858b11ddabb1 100644 (file)
@@ -71,7 +71,7 @@ module.exports = {
         type: "suggestion",
 
         docs: {
-            description: "enforce a maximum number of lines of code in a function",
+            description: "Enforce a maximum number of lines of code in a function",
             recommended: false,
             url: "https://eslint.org/docs/rules/max-lines-per-function"
         },
@@ -80,7 +80,7 @@ module.exports = {
             OPTIONS_OR_INTEGER_SCHEMA
         ],
         messages: {
-            exceed: "{{name}} has exceeded the limit of lines allowed by {{linesExceed}}. Maximum allowed number of lines per function is {{maxLines}}."
+            exceed: "{{name}} has too many lines ({{lineCount}}). Maximum allowed is {{maxLines}}."
         }
     },
 
@@ -170,26 +170,18 @@ module.exports = {
                 return;
             }
             let lineCount = 0;
-            let comments = 0;
-            let blankLines = 0;
 
             for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
                 const line = lines[i];
 
                 if (skipComments) {
                     if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
-                        if (lineCount <= maxLines) {
-                            comments++;
-                        }
                         continue;
                     }
                 }
 
                 if (skipBlankLines) {
                     if (line.match(/^\s*$/u)) {
-                        if (lineCount <= maxLines) {
-                            blankLines++;
-                        }
                         continue;
                     }
                 }
@@ -199,21 +191,11 @@ module.exports = {
 
             if (lineCount > maxLines) {
                 const name = upperCaseFirst(astUtils.getFunctionNameWithKind(funcNode));
-                const linesExceed = lineCount - maxLines;
-
-                const loc = {
-                    start: {
-                        line: node.loc.start.line + maxLines + (comments + blankLines),
-                        column: 0
-                    },
-                    end: node.loc.end
-                };
 
                 context.report({
                     node,
-                    loc,
                     messageId: "exceed",
-                    data: { name, linesExceed, maxLines }
+                    data: { name, lineCount, maxLines }
                 });
             }
         }