Skip to content

linter: Incorrect "unused expression" for a ternary with expressions. #23653

Description

@Pomax

What version of Oxlint are you using?

1.70.0

What command did you run?

oxlint@latest --fix --fix-suggestions --fix-dangerously

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

The whole reason I'm using oxlint is so that I don't need yet another config file polluting small codebases

What happened?

Oxlint incorrectly flags a ternary as being "unused" when it more than obviously executes either one of two possible expressions.

export function tty(query, question = false, raw = false) {
  return new Promise((resolve) => {
    stdin.once(`data`, (data) => {
      resolve(util.inspect(data.toString()));
    });
    
    raw ? write(query) : ansi(query, question);
  });
}

It flags the truthy ? expression : expression part as unused, which makes no sense whatsoever

  ⚠ eslint(no-unused-expressions): Expected expression to be used
    ╭─[tty.js:56:5]
 55 │     });
 56 │     raw ? write(query) : ansi(query, question);
    ·     ───────────────────────────────────────────
 57 │   });
    ╰────
  help: Consider using this expression or removing it

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions