Skip to content

linter: eslint/no-cond-assign with always flags conditional expression in ternary expression #22760

@jeanne-cai

Description

@jeanne-cai

What version of Oxlint are you using?

1.67.0

What command did you run?

yarn oxlint -c oxlint.config.mjs

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

import { defineConfig } from 'oxlint';

export default defineConfig({
    categories: {
        correctness: 'off',
    },
    rules: {
        'eslint/no-cond-assign': ['error', 'always'],
    },
});

What happened?

The rule flags assignment expressions in ternary branches as conditions, but they should not be.

To reproduce:

// assignment: not used as a condition, so it is not flagged
const b = (a += 3);

// ternary: also not used as a condition, but still flagged
a = a ? (a += 5) : 1;

Output:

  × eslint(no-cond-assign): Expected a conditional expression and instead saw an assignment
   ╭─[test.ts:5:12]
 4 │ // ternary: also not used as a condition, but still flagged
 5 │ a = a ? (a += 5) : 1;
   ·            ──
   ╰────
  help: Consider wrapping the assignment in additional parentheses

Found 0 warnings and 1 error.
Finished in 86ms on 1 file with 1 rules using 16 threads.

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