Config adjustment: Include more operators in `no-mixed-operators`
fregante opened this issue · 3 comments
fregante commented
Originally posted in eslint/eslint#14975
What rule do you want to change?
no-mixed-operators
:
Please provide some example code that this change will affect:
a || b === c
a ?? b === c
What will the rule do after it's changed?
Suggest a fix:
a || (b === c)
a ?? (b === c)
fregante commented
XO currently just uses the rule’s default, but a change to it was rejected because it would be breaking.
Example config:
'no-mixed-operators': [
'error',
{
// Customize the defaults to force being explicit about use of null-coalescing operator because its precedence
// is unintuitive. See: https://eslint.org/docs/rules/no-mixed-operators
groups: [
// Conflicts with Prettier: https://github.com/prettier/prettier/issues/3968
// ["+", "-", "*", "/", "%", "**", "??"],
['&', '|', '^', '~', '<<', '>>', '>>>', '??'],
['==', '!=', '===', '!==', '>', '>=', '<', '<=', '??'],
['&&', '||', '??'],
['in', 'instanceof', '??'],
],
},
],
sindresorhus commented
👍 Pull request welcome.
sindresorhus commented
// Conflicts with Prettier: prettier/prettier#3968
That's not a concern here.