Rule Change: Make max-lines-per-function only reports lines that exceed the limit, not all
See original GitHub issueWhat rule do you want to change?
max-lines-per-function
What change to do you want to make?
Generate fewer warnings
How do you think the change should be implemented?
A new default behavior
Example code
/* eslint max-lines-per-function: ["error", {"max": 3}] */
export function bulkyFunction() {
// line 1
// line 2
// line 3
}
What does the rule currently do for this code?
Currently it will report the range of line numbers from the beginning of the function to the very last line of it.
What will the rule do after it’s changed?
Following the same spirit of max-lines
implemented in #13318, we should only report those lines which exceed the limit.
With this example, it should only report line 4 and 5.
Participation
- I am willing to submit a pull request to implement this change.
Additional comments
The current default is annoying because once the function exceeds even a single line, the whole function is highlighted by the editor and other important errors may be suppressed as a result.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:38 (30 by maintainers)
Top Results From Across the Web
New `max-lines-per-function` rule · Issue #9842 - GitHub
Please describe what the rule should do: It should allow a configurable limit of the max number of lines per function, much like...
Read more >max-lines-per-function - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >The 80/24 Rule | Hacker News
I have an extremely hard time dealing with the concept of a hard line/column number limit, because everything is a grey area to...
Read more >Limit issues of same check per line in SonarQube
I've created some custom rules (checks) and one of them reports the same issue in the same line several times. This makes sense...
Read more >max-line-length - Rule
Rule : max-line-length. Requires lines to be under a certain max length. Rationale. Limiting the length of a line of code improves code...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@The-x-Theorist thanks. We already have @LilCthulu volunteering to work on this, so let’s give them the chance to complete the work first.
@nzakas Thanks! I’ll get started right away and keep you posted!