eslint-plugin-putout
Version:
ESLint plugin for πPutout
183 lines (140 loc) β’ 10.4 kB
Markdown
# eslint-plugin-putout [![NPM version][NPMIMGURL]][NPMURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
[NPMIMGURL]: https://img.shields.io/npm/v/eslint-plugin-putout.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/eslint-plugin-putout "npm"
[CoverageURL]: https://coveralls.io/github/coderaiser/putout?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/putout/badge.svg?branch=master&service=github
[**ESLint**](https://eslint.org) plugin for π[**Putout**](https://github.com/coderaiser/putout) with built-in rules from [**@putout/eslint-config**](https://github.com/coderaiser/putout/tree/master/packages/eslint-config#readme).
## Installation
```
npm i putout eslint eslint-plugin-putout -D
```
βοΈ*If you installed `eslint` globally (using the `-g` flag) then you must also install `putout` and `eslint-plugin-putout` globally.*
## Usage
Update `eslint.config.js` with:
```js
import {recommended} from 'eslint-plugin-putout';
export default recommended;
```
Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"putout/add-newlines-between-types-in-union": "error",
"putout/add-newlines-between-specifiers": "error",
"putout/add-newline-before-return": "error",
"putout/add-newline-before-function-call": "error",
"putout/add-newline-after-function-call": "error",
"putout/putout": "error",
"putout/array-element-newline": "error",
"putout/single-property-destructuring": "error",
"putout/multiple-properties-destructuring": "error",
"putout/long-properties-destructuring": "error",
"putout/destructuring-as-function-argument": "error",
"putout/align-spaces": "error",
"putout/keyword-spacing": "error",
"putout/newline-function-call-arguments": "error",
"putout/function-declaration-paren-newline": "error",
"putout/remove-newline-after-default-import": "error",
"putout/remove-newline-between-declarations": "error",
"putout/remove-newline-from-empty-object": "error",
"putout/remove-empty-newline-before-first-specifier": "error",
"putout/remove-empty-newline-after-last-specifier": "error",
"putout/remove-empty-newline-after-last-element": "error",
"putout/remove-empty-newline-after-import": "error",
"putout/remove-empty-specifiers": "error",
"putout/objects-braces-inside-array": "error",
"putout/object-property-newline": "error",
"putout/tape-add-newline-between-tests": "error",
"putout/tape-add-newline-before-assertion": "error",
"putout/tape-remove-newline-before-t-end": "error"
}
}
```
## Rules
### π [Putout](https://github.com/coderaiser/putout#readme)
- β
[Putout](/packages/eslint-plugin-putout/lib/putout#readme)
- β
[Evaluate](/packages/eslint-plugin-putout/lib/evaluate#readme)
### πΌ [Supertape](https://github.com/coderaiser/supertape#readme)
- β
[add newline before assertion](/packages/eslint-plugin-putout/lib/tape-add-newline-before-assertion#readme)
- β
[add newline between tests](/packages/eslint-plugin-putout/lib/tape-add-newline-between-tests#readme)
- β
[remove newline before `t.end()`](/packages/eslint-plugin-putout/lib/tape-remove-newline-before-t-end#readme)
### TypeScript
- β
[Add newlines between types in union](/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union#readme)
- β
[Object property newline](/packages/eslint-plugin-putout/lib/object-property-newline#readme)
### ESM
- β
[No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved#readme)
- β
[Remove duplicate extension](/packages/eslint-plugin-putout/lib/remove-duplicate-extensions#readme)
- β
[Add newlines between specifiers](/packages/eslint-plugin-putout/lib/add-newlines-between-specifiers#readme)
### Formatting
- β
[Add newline before return](/packages/eslint-plugin-putout/lib/add-newline-before-return#readme)
- β
[Add newline before function call](/packages/eslint-plugin-putout/lib/add-newline-before-function-call#readme)
- β
[Add newline after function call](/packages/eslint-plugin-putout/lib/add-newline-after-function-call#readme)
- β
[Align spaces](/packages/eslint-plugin-putout/lib/align-spaces#readme)
- β
[Array element newline](/packages/eslint-plugin-putout/lib/array-element-newline#readme)
- β
[Single property destructuring](/packages/eslint-plugin-putout/lib/single-property-destructuring#readme)
- β
[Multiple properties destructuring](/packages/eslint-plugin-putout/lib/multiple-properties-destructuring#readme)
- β
[For-of multiple properties destructuring](/packages/eslint-plugin-putout/lib/for-of-multiple-properties-destructuring#readme)
- β
[Long properties destructuring](/packages/eslint-plugin-putout/lib/long-properties-destructuring#readme)
- β
[Destructuring as function argument](/packages/eslint-plugin-putout/lib/destructuring-as-function-argument#readme)
- β
[Keyword spacing](/packages/eslint-plugin-putout/lib/keyword-spacing#readme)
- β
[Newline function call arguments](/packages/eslint-plugin-putout/lib/newline-function-call-arguments#readme)
- β
[Function declaration paren newline](/packages/eslint-plugin-putout/lib/function-declaration-paren-newline#readme)
- β
[Remove newline between declarations](/packages/eslint-plugin-putout/lib/remove-newline-between-declarations#readme)
- β
[Remove newline after default import](/packages/eslint-plugin-putout/lib/remove-newline-after-default-import#readme)
- β
[Remove newline from empty object](/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object#readme)
- β
[Remove empty newline before first specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-before-first-specifier#readme)
- β
[Remove empty newline after last specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-specifier#readme)
- β
[Remove empty newline after last element](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-element#readme)
- β
[Remove empty newline after import](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-import#readme)
- β
[Remove empty specifiers](/packages/eslint-plugin-putout/lib/remove-empty-specifiers#readme)
- β
[Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array#readme)
- β
[Nonblock statement body newline](/packages/eslint-plugin-putout/lib/non-block-statement-body-newline#readme)
### Safe mode
When using π**Putout** in IDE with `--fix` on save, or when you want to disable the most dangerous rules, use:
```js
import {safe} from 'eslint-plugin-putout';
export default safe;
```
Disabled **ESLint** rules:
- β [`no-useless-return`](https://eslint.org/docs/rules/no-useless-return#readme)
- β [`no-implicit-coercion`](https://eslint.org/docs/rules/no-implicit-coercion#readme)
- β [`putout/remove-newline-from-empty-object`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object#readme)
Disabled π**Putout** rules:
- β [`apply-template-literals`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
- β [`remove-empty`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
- β [`merge-duplicate-functions`](https://github.com/coderaiser/putout/tree/v37.12.0/packages/plugin-merge-duplicate-functions#readme);
- β [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-nodejs#remove-process-exit#readme);
- β [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-variables#readme);
- β [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types#readme);
- β [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-expressions#readme);
- β [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreferenced-variables#readme);
- β [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#readme);
- β [`return/remove-useless`](https://github.com/coderaiser/putout/tree/v38.0.0/packages/plugin-return#remove-useless);
- β [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-spread/#readme);
- β [`remove-useless-variables`](https://github.com/coderaiser/putout/tree/v33.13.4/packages/plugin-remove-useless-variables#readme);
- β [`tape/remove-skip`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-skip);
- β [`tape/remove-only`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-only);
- β [`remove-console`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-console#readme);
- β [`remove-debugger`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-debugger#readme);
- β [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreachable-code#readme);
- β [`for-of/for`](https://github.com/coderaiser/putout/tree/v29.1.2/packages/plugin-convert-for-to-for-of#readme);
- β [`for-of/remove-useless`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-for-of#remove-useless);
- β [`for-of/remove-unused-variables`](https://github.com/coderaiser/putout/tree/29.7.1/packages/plugin-for-of#remove-unused-variables);
- β [`maybe/noop`](https://github.com/coderaiser/putout/tree/29.2.4/packages/plugin-maybe#noop);
- β [`remove-useless-push`](https://github.com/coderaiser/putout/tree/38.1.2/packages/plugin-remove-useless-push#readme);
### safeAlign
When you want to enable ability to align spaces on empty lines, while have all benefits of `safe` preset: use `safeAlign`.
### jsx
When you need to support `jsx` in files using `js` extension, use:
```js
import {jsx} from 'eslint-plugin-putout;
export default jsx;
```
### esm
If you want to use **ESM** plugins of π**Putout** you need to use `esm` preset:
```json
import {esm} from 'eslint-plugin-putout;
export default esm;
```
## License
MIT