Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevin940726/eslint-plugin-no-mixed-operators
Fixable no-mixed-operators rule for eslint
https://github.com/kevin940726/eslint-plugin-no-mixed-operators
eslint no-mixed-operators prettier prettier-eslint
Last synced: 9 days ago
JSON representation
Fixable no-mixed-operators rule for eslint
- Host: GitHub
- URL: https://github.com/kevin940726/eslint-plugin-no-mixed-operators
- Owner: kevin940726
- License: mit
- Created: 2018-04-05T17:01:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-10T15:47:16.000Z (over 6 years ago)
- Last Synced: 2024-10-29T01:19:58.900Z (19 days ago)
- Topics: eslint, no-mixed-operators, prettier, prettier-eslint
- Language: JavaScript
- Size: 52.7 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-no-mixed-operators
[![NPM](https://nodei.co/npm/eslint-plugin-no-mixed-operators.png)](https://nodei.co/npm/eslint-plugin-no-mixed-operators/)
Fixable no-mixed-operators rule for eslint.
## Why
The plugin originally comes from the need of supporting [prettier](https://github.com/prettier/prettier/issues/3968) to work with eslint. But since [eslint/eslint#8916](https://github.com/eslint/eslint/issues/8916) didn't get enough consensus from the team, I figured to create a drop-in replaceable plugin myself.
## Installation
```sh
yarn add -D eslint-plugin-no-mixed-operators
```OR
```sh
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.
```js
// .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.
```bash
eslint --fix .
```## Example
Considered the following code
```js
a && b + c - d / e || f
```will automatically be fixed to
```js
(a && b + c - (d / e)) || f
```## Options
All [original options](https://eslint.org/docs/rules/no-mixed-operators#options) are available.
## Running Tests
```sh
yarn test # npm test
```## Running Demo
```sh
cd demo # change to the demo directory
yarn # npm install
yarn test # npm test
```See `demo/index.js` for fixed changes.
## Author
Kai Hao