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.

Fix max-statements-per-line

See original GitHub issue

While reviewing https://github.com/eslint/eslint/pull/7044, I find that max-statements-per-line has an undocumented and confusing behavior. For some reason, we allow an option of max: 0, which seems like a mistake (though intentional because there are tests). It looks like the only time this is triggered is when there’s an empty blocks statement and there’s a special case for that in the code: https://github.com/eslint/eslint/blob/master/lib/rules/max-statements-per-line.js#L167

This seems very broken because it doesn’t make sense to ever have max statements be 0 per line, and we already have no-empty to catch empty blocks.

I think we should fix this by:

  1. Ensuring max is 1 or larger
  2. Removing the empty block check

This would be semver-patch because we are reducing the number of warnings this rule produces.

@mysticatea @scriptdaemon

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
sstern6commented, Sep 6, 2016

@nzakas I would like to make a PR for this, this will be my first PR in the code base if you are ok with me taking this on.

Thank you

1reaction
nzakascommented, Sep 6, 2016

@btmills yes, what @ilyavolodin said. The minimum for max should be set to 1 in the schema.

Read more comments on GitHub >

github_iconTop Results From Across the Web

max-statements-per-line - ESLint - Pluggable JavaScript Linter
This rule enforces a maximum number of statements allowed per line. Options. max. The “max” object property is optional (default: 1). Examples of...
Read more >
max-statements-per-line: 2 · Issue #1431 - GitHub
I'd like to limit the number of statements per line. What do you think is the correct solution to this problem? { "max-statements-per-line": ......
Read more >
Max-statements-per-line - ESLint - W3cubDocs
This rule enforces a maximum number of statements allowed per line. Options. max. The “max” object property is optional (default: 1). Examples of...
Read more >
enforce a maximum file length (max-lines) - ESLint
Recommendations usually range from 100 to 500 lines. Rule Details. This rule enforces a maximum number of lines per file, in order to...
Read more >
ESLint rule to require one variable declaration statement per ...
I've tried one-var , one-var-declaration-per-line , and max-statements-per-line . From my experiments, max-statements-per-line is too aggressive ...
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