Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max-statements-per-line: complains on if when curly-rule adds missing { #295

Open
3 of 5 tasks
jgburet opened this issue Mar 13, 2024 · 1 comment
Open
3 of 5 tasks

Comments

@jgburet
Copy link

jgburet commented Mar 13, 2024

Validations

Describe the bug

Hey,
I'm not sure if this should be added to #211 or if that's a different issue

The rule max-statements-per-line (with the default max: 1) complains on if (v) { console.log(); }.
These braces are added when the rule curly is present with "all" or "multi", "consistent" (when the else has multiple statements within its braces).

I'm expecting the rule to accept the block because it contains only a single statement.

Reproduction:

extends:
  - eslint:recommended
  - plugin:@typescript-eslint/strict-type-checked
  - plugin:@typescript-eslint/stylistic-type-checked
parser: "@typescript-eslint/parser"
parserOptions:
  ecmaVersion: latest
  sourceType: module
  project:
    - "tsconfig.json"
    - "./**/tsconfig.json"
plugins:
  - "@typescript-eslint"
  - "@stylistic"
rules:
  curly:
    - warn
    - "multi"
    - "consistent"
  "@stylistic/max-statements-per-line":
    - error
    - max: 1
    if (v) { console.log("hyel"); }
    else {
        console.log("");
        console.log( );
    }

Reproduction

https://stackblitz.com/edit/github-pwcljb?file=eslint.config.js
(It doesn't show in Stackblitz because the file keeps getting formatted on save...)

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@m-shum
Copy link

m-shum commented Mar 20, 2024

It would be really nice if we could have this rule auto-fixed the same way it's autofixed on stackblitz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants