ESLint plugin for πPutout
npm install eslint-plugin-putout[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 plugin for πPutout with built-in rules from @putout/eslint-config.
```
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.
To use putout as ESLint plugin you can use in eslint.config.js
`js
import putout from 'eslint-plugin-putout';
export default [
rules: {
'putout/putout': 'error',
},
plugins: {
putout,
},
];
`
Also you can import one of predefined preset:
- β
recommended - all rules enabled;
- β
safe - dangerous rules disabled;
- β
safeAlign - dangerous rules disabled + add whitespaces on empty lines;
Here is how it can look like:
`js
import {recommended} from 'eslint-plugin-putout';
export default recommended;
`
Or with defineConfig:
`js
import {defineConfig} from 'eslint/config';
import putout from 'eslint-plugin-putout';
export default defineConfig({
plugins: {
putout,
},
extends: [
"putout/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/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"
}
}
- β
add newline before assertion
- β
add newline between tests
- β
remove newline before t.end()
- β
Add newlines between types in union
- β
Object property newline
- β
Remove duplicate extension
- β
Add newlines between specifiers
- β
Add newline before return
- β
Add newline before function call
- β
Add newline after function call
- β
Align spaces
- β
Array element newline
- β
Single property destructuring
- β
Multiple properties destructuring
- β
For-of multiple properties destructuring
- β
Long properties destructuring
- β
Destructuring as function argument
- β
Newline function call arguments
- β
Function declaration paren newline
- β
Remove newline between declarations
- β
Remove newline after default import
- β
Remove newline from empty object
- β
Remove empty newline before first specifier
- β
Remove empty newline after last specifier
- β
Remove empty newline after last element
- β
Remove empty newline after import
- β
Remove empty specifiers
- β
Objects braces inside array
- β
Nonblock statement body newline
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
- β no-implicit-coercion
- β putout/remove-newline-from-empty-object
Disabled πPutout rules:
- β apply-template-literals;
- β convert-template-to-string;
- β remove-empty;
- β merge-duplicate-functions;
- β nodejs/remove-process-exit;
- β typescript/remove-unused-types;
- β remove-unused-expressions;
- β variables/remove-unused;
- β variables/remove-useless;
- β variables/remove-unreferenced;
- β remove-useless-arguments;
- β return/remove-useless;
- β remove-useless-spread;
- β tape/remove-skip;
- β tape/remove-only;
- β remove-console;
- β remove-debugger;
- β remove-unreachable-code;
- β for-of/for;
- β for-of/remove-useless;
- β for-of/remove-unused-variables;
- β maybe/noop;
- β remove-useless-push;
When you want to enable ability to align spaces on empty lines, while have all benefits of safe preset: use safeAlign.
When you need to support jsx in files using js extension, use:
`js
import {jsx} from 'eslint-plugin-putout;
export default jsx;
``
MIT