mirror of
https://github.com/danbulant/oxc
synced 2026-05-22 21:58:36 +00:00
fix: nullish coalescing operator precedence (#240)
This commit is contained in:
parent
b11f774c41
commit
ab2ef4f89b
2 changed files with 9 additions and 1 deletions
|
|
@ -217,7 +217,7 @@ const PRECEDENCES: [u8; 27] = [
|
|||
4, 3,
|
||||
9, 9,
|
||||
2,
|
||||
9,
|
||||
3
|
||||
];
|
||||
|
||||
const ARITHMETIC: &[&str] = &OPERATORS[..6];
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue