Skip to content

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

@MichaelGoff

Description

@MichaelGoff

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';}`.

Metadata

Metadata

Assignees

Labels

A-linterArea - LinterC-bugCategory - Bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions