eslint-plugin-putout

ESLint plugin for ๐Putout with built-in rules from @putout/eslint-config.
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
Plugin
To use putout
as ESLint plugin you can use in eslint.config.js
import putout from 'eslint-plugin-putout';
export default [
rules: {
'putout/putout': 'error',
},
plugins: {
putout,
},
];
Preset
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:
import {recommended} from 'eslint-plugin-putout';
export default recommended;
Or with defineConfig
:
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.
{
"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
๐ผ Supertape
TypeScript
ESM
Formatting
- โ 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
- โ Keyword spacing
- โ 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
Safe mode
When using ๐Putout in IDE with --fix
on save, or when you want to disable the most dangerous rules, use:
import {safe} from 'eslint-plugin-putout';
export default safe;
Disabled ESLint rules:
Disabled ๐Putout rules:
- โ
apply-template-literals
; - โ
convert-template-to-string
; - โ
remove-empty
; - โ
merge-duplicate-functions
; - โ
nodejs/remove-process-exit
; - โ
remove-unused-variables
; - โ
typescript/remove-unused-types
; - โ
remove-unused-expressions
; - โ
remove-unreferenced-variables
; - โ
remove-useless-arguments
; - โ
return/remove-useless
; - โ
remove-useless-spread
; - โ
remove-useless-variables
; - โ
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
;
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:
import {jsx} from 'eslint-plugin-putout;
export default jsx;
License
MIT