Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/oxc_linter/src/rules/no_mixed_operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const PRECEDENCES: [u8; 27] = [
4, 3,
9, 9,
2,
9,
3
];

const ARITHMETIC: &[&str] = &OPERATORS[..6];
Expand Down Expand Up @@ -296,6 +296,7 @@ fn test() {
("x ? a && b : 0", Some(json!([{ "groups": [["&&", "||", "?:"]] }]))),
("x ? 0 : a && b", Some(json!([{ "groups": [["&&", "||", "?:"]] }]))),
("a + b ?? c", Some(json!([{ "groups": [["+", "??"]] }]))),
("a in b ?? c", Some(json!([{ "groups": [["in", "??"]] }]))),
];

Tester::new(NoMixedOperators::NAME, pass, fail).test_and_snapshot();
Expand Down
7 changes: 7 additions & 0 deletions crates/oxc_linter/src/snapshots/no_mixed_operators.snap
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ expression: no_mixed_operators
╰────
help: Use parentheses to clarify the intended order of operations.

⚠ eslint(no-mixed-operators): Unexpected mix of in with ??
╭─[no_mixed_operators.tsx:1:1]
1 │ a in b ?? c
· ── ──
╰────
help: Use parentheses to clarify the intended order of operations.