eslint-plugin-no-mixed-operators
v1.1.1
Published
Fixable no-mixed-operators rule for eslint
Downloads
15,570
Readme
eslint-plugin-no-mixed-operators
Fixable no-mixed-operators rule for eslint.
Why
The plugin originally comes from the need of supporting prettier to work with eslint. But since eslint/eslint#8916 didn't get enough consensus from the team, I figured to create a drop-in replaceable plugin myself.
Installation
yarn add -D eslint-plugin-no-mixed-operators
OR
npm install --save-dev eslint-plugin-no-mixed-operators
Usage
Use it like a regular plugin and disable the original one if it's already enabled.
// .eslintrc
{
"plugins": ["no-mixed-operators"],
"rules": [
"no-mixed-operators": "off",
"no-mixed-operators/no-mixed-operators": "error"
]
}
Then you can fix the code with --fix
via eslint CLI.
eslint --fix .
Example
Considered the following code
a && b + c - d / e || f
will automatically be fixed to
(a && b + c - (d / e)) || f
Options
All original options are available.
Running Tests
yarn test # npm test
Running Demo
cd demo # change to the demo directory
yarn # npm install
yarn test # npm test
See demo/index.js
for fixed changes.
Author
Kai Hao