question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include more operators in `no-mixed-operators`’s default config (by ESLint 8?)

See original GitHub issue

What rule do you want to change?

no-mixed-operators:

https://github.com/eslint/eslint/blob/c981fb1994cd04914042ced1980aa86b68ba7be9/lib/rules/no-mixed-operators.js#L25-L40

Does this change cause the rule to produce more or fewer warnings?

More

How will the change be implemented? (New option, new default behavior, etc.)?

New default

Please provide some example code that this change will affect:

a || b === c
a ?? b === c

What does the rule currently do for this code?

No error, unless configured.

What will the rule do after it’s changed?

Suggest a fix:

a || (b === c)
a ?? (b === c)

Are you willing to submit a pull request to implement this change?

Possibly

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Sep 8, 2021

I can’t say I understand why the operators are grouped the way they are, but it does seem intentional and your config does seem to be the correct way to override the default.

0reactions
fregantecommented, Oct 2, 2021

make me think this is a bug in the rule’s default behavior

I didn’t say it’s a bug, it just said it would be helpful to enable more warnings. Since it’s a new operator, it’s not clear what the result of a ?? b === c would be.

Given that the behavior seems intentional

Intentional how? It just allows more operators being mixed. 🤷‍♂️ It’s as “intentional” as the lack of a rule. The operator did not exist when the rule was written.

given we’re already at v8.0.0-rc.0, that would mean v9.

That’s unfortunate, it would be a simple change to bring in v8, hence the issue title.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Configuring ESLint - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Rules - ESLint - Pluggable JavaScript Linter
The "extends": "eslint:recommended" property in a configuration file ... Disallow assignment operators in conditional expressions ... default-param-last.
Read more >
Configuration Files (New) - ESLint - Pluggable JavaScript Linter
You can put your ESLint project configuration in a configuration file. You can include built-in rules, how you want them enforced, plugins with...
Read more >
ESLint's new config system, Part 2: Introduction to flat config
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found