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

linter: curly set to multi-line triggers false positive on single line else #9600

Open
MichaelGoff opened this issue Mar 7, 2025 · 3 comments
Labels
A-linter Area - Linter C-bug Category - Bug

Comments

@MichaelGoff
Copy link

What version of Oxlint are you using?

0.15.13

What command did you run?

npx oxlint

What does your .oxlintrc.json config file look like?

{
  "env": {
    "browser": true
  },
  "categories": {
    "correctness": "error"
  },
  "rules": {
    "curly": ["error", "multi-line"]
  }
}

What happened?

The following snippet passes eslint when set to curly: ['error', 'multi-line'] but fails in oxlint.

I expect this single line else to be okay when set to 'multi-line'

  const isIterable = (obj: any) : obj is Iterable<IgnoreRule> => {
    if (obj === null) return false;
    else if (typeof obj === 'string') return false;
    else return typeof value[Symbol.iterator] === 'function';
  };

Oxlint output:

  × eslint(curly): Expected { after 'else'.
    ╭─[src/testFile.ts:88:10]
 87 │     else if (typeof obj === 'string') return false;
 88 │     else return typeof value[Symbol.iterator] === 'function';
    ·          ────────────────────────────────────────────────────
 89 │   };
    ╰────
  help: Replace `return typeof value[Symbol.iterator] === 'function';` with `{return typeof value[Symbol.iterator] === 'function';}`.
@MichaelGoff MichaelGoff added A-linter Area - Linter C-bug Category - Bug labels Mar 7, 2025
@heygsc
Copy link
Contributor

heygsc commented Mar 10, 2025

It's a bit strange, I tried testing with or without parentheses in the source code, but both cargo test passed.

@MichaelGoff
Copy link
Author

Here's a minimal reproduction https://github.com/MichaelGoff/oxlint-curly-multiline-issue

npx oxlint throws the error

I'm on Windows 10 using Node 22.11.0 if that's relevant.

@heygsc
Copy link
Contributor

heygsc commented Mar 12, 2025

mac arm64 + node 22.14.0, Found 0 warnings and 0 errors..

Maybe someone else will try again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-bug Category - Bug
Projects
None yet
Development

No branches or pull requests

2 participants