question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule Change: Make max-lines-per-function only reports lines that exceed the limit, not all

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:38 (30 by maintainers)

github_iconTop GitHub Comments

2reactions
nzakascommented, Oct 7, 2021

@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.

2reactions
LilCthulucommented, Oct 6, 2021

@nzakas Thanks! I’ll get started right away and keep you posted!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found