eslint-plugin-putout 14.0.1 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/lib/add-newline-after-function-call/README.md +3 -5
- package/lib/align-spaces/README.md +4 -8
- package/lib/array-element-newline/README.md +6 -8
- package/lib/evaluate/README.md +3 -4
- package/lib/for-of-multiple-properties-destructuring/README.md +9 -10
- package/lib/long-properties-destructuring/README.md +5 -7
- package/lib/markdown.js +0 -2
- package/lib/multiple-properties-destructuring/README.md +7 -6
- package/lib/single-property-destructuring/README.md +6 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[CoverageURL]: https://coveralls.io/github/coderaiser/putout?branch=master
|
|
6
6
|
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/putout/badge.svg?branch=master&service=github
|
|
7
7
|
|
|
8
|
-
[
|
|
8
|
+
[**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).
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
npm i putout eslint eslint-plugin-putout -D
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
☝️*If you installed `eslint` globally (using the `-g` flag) then you must also install `putout` and `eslint-plugin-putout` globally.*
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
@@ -108,7 +108,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
108
108
|
|
|
109
109
|
### Safe mode
|
|
110
110
|
|
|
111
|
-
When using
|
|
111
|
+
When using 🐊**Putout** in IDE with `--fix` on save, or when you want to disable the most dangerous rules, use:
|
|
112
112
|
|
|
113
113
|
```json
|
|
114
114
|
{
|
|
@@ -121,12 +121,12 @@ When using 🐊`Putout` in IDE with `--fix` on save, or when you want to disable
|
|
|
121
121
|
}
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
Disabled
|
|
124
|
+
Disabled **ESLint** rules:
|
|
125
125
|
|
|
126
126
|
- [`no-useless-return`](https://eslint.org/docs/rules/no-useless-return#readme)
|
|
127
127
|
- [`putout/remove-newline-from-empty-object`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object#readme)
|
|
128
128
|
|
|
129
|
-
Disabled
|
|
129
|
+
Disabled 🐊**Putout** rules:
|
|
130
130
|
|
|
131
131
|
- 🐲[`remove-empty`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-remove-empty#readme);
|
|
132
132
|
- 🐲[`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v24.0.0/packages/plugin-nodejs#remove-process-exit#readme);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## Rule Details
|
|
1
|
+
# add-newline-after-function-call
|
|
4
2
|
|
|
5
3
|
This rule aims to add newline after function call.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
## ❌ Example of incorrect code
|
|
8
6
|
|
|
9
7
|
```js
|
|
10
8
|
export function parse() {
|
|
@@ -15,7 +13,7 @@ export function parse() {
|
|
|
15
13
|
}
|
|
16
14
|
```
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
## ✅ Example of correct code
|
|
19
17
|
|
|
20
18
|
```js
|
|
21
19
|
export function parse() {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# aling-spaces
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
When 🐊**Putout** processes files it can remove spaces from empty line, this `rule` fixes it.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
This rule aims to shorten destricturing of one property.
|
|
8
|
-
|
|
9
|
-
Examples of **incorrect** code for this rule:
|
|
5
|
+
## ❌ Example of incorrect code
|
|
10
6
|
|
|
11
7
|
```js
|
|
12
8
|
function hello() {
|
|
@@ -18,7 +14,7 @@ function hello() {
|
|
|
18
14
|
}
|
|
19
15
|
```
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
## ✅ Example of correct code
|
|
22
18
|
|
|
23
19
|
```js
|
|
24
20
|
function hello() {
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
Because [`array-element-newline`](https://eslint.org/docs/rules/array-element-newline) requires [`array-bracket-newline`](https://eslint.org/docs/rules/array-bracket-newline).
|
|
4
|
-
And `array-bracket-newline` and conflicts with [`object-braces-inside-array`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/objects-braces-inside-array).
|
|
5
|
-
|
|
6
|
-
## Rule Details
|
|
1
|
+
# array-elements-newline
|
|
7
2
|
|
|
8
3
|
This rule aims to add newlines between array elements.
|
|
4
|
+
It exists because [`array-element-newline`](https://eslint.org/docs/rules/array-element-newline) requires [`array-bracket-newline`](https://eslint.org/docs/rules/array-bracket-newline) which conflicts with [`object-braces-inside-array`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout/lib/objects-braces-inside-array#readme).
|
|
5
|
+
|
|
6
|
+
Part of [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
## ❌ Example of incorrect code
|
|
11
9
|
|
|
12
10
|
```js
|
|
13
11
|
const a = [1, 2, 3, 4, 5, 6, 7];
|
|
14
12
|
```
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
## ✅ Example of correct code
|
|
17
15
|
|
|
18
16
|
```js
|
|
19
17
|
const a = [
|
package/lib/evaluate/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# Evaluate
|
|
2
2
|
|
|
3
|
-
Evaluate expression started with `__putout_evaluate: `. Part of [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules)
|
|
4
|
-
|
|
3
|
+
Evaluate expression started with `__putout_evaluate: `. Part of [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
5
4
|
Provided code is processed with [`@putout/plugin-declare-undefined-variables`](https://github.com/coderaiser/putout/tree/master/packages/plugin-declare-undefined-variables):
|
|
6
5
|
|
|
7
6
|
```js
|
|
8
|
-
__putout_evaluate: join(
|
|
7
|
+
__putout_evaluate: join('hello', ' ', 'world');
|
|
9
8
|
```
|
|
10
9
|
|
|
11
10
|
and converted to:
|
|
@@ -13,7 +12,7 @@ and converted to:
|
|
|
13
12
|
```js
|
|
14
13
|
const fn = (__filename, __dirname, require) => {
|
|
15
14
|
const {join} = require('path');
|
|
16
|
-
return join(
|
|
15
|
+
return join('hello', ' ', 'world');
|
|
17
16
|
};
|
|
18
17
|
```
|
|
19
18
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# for-of-multiple-properties-destructuring
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This rule aims to shorten destructuring in `for-of` statements, keeping all properties in one line.
|
|
4
|
+
Part of [**eslint-plugin-putout**](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Examples of **incorrect** code for this rule:
|
|
6
|
+
## ❌ Example of incorrect code
|
|
8
7
|
|
|
9
8
|
```js
|
|
10
9
|
for ({
|
|
@@ -14,13 +13,13 @@ for ({
|
|
|
14
13
|
}
|
|
15
14
|
```
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Options
|
|
20
|
-
|
|
21
|
-
`maxProperties` - maximum properties count to work with.
|
|
16
|
+
## ✅ Example of correct code
|
|
22
17
|
|
|
23
18
|
```js
|
|
24
19
|
for ({username, password} of users) {
|
|
25
20
|
}
|
|
26
21
|
```
|
|
22
|
+
|
|
23
|
+
## Options
|
|
24
|
+
|
|
25
|
+
`maxProperties` - maximum properties count to work with, defaults to **8**.
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# long-properties-destructuring
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Keep each property on separate line when destructuring properties with name length **15** characters and more.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Part of [**eslint-plugin-putout**](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Examples of **incorrect** code for this rule:
|
|
7
|
+
## ❌ Example of incorrect code
|
|
10
8
|
|
|
11
9
|
```js
|
|
12
10
|
const {isIdentifier} = user;
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## ✅ Example of correct code
|
|
16
14
|
|
|
17
15
|
```js
|
|
18
16
|
const {
|
package/lib/markdown.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# multiple-properties-destructuring
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Keep each property on separate line when using multiple destructuring properties
|
|
4
|
+
In the same way as **ESLint** [object-property-newline](https://eslint.org/docs/rules/object-property-newline), but for destructuring.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Part of [**eslint-plugin-putout**](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## ❌ Example of incorrect code
|
|
8
9
|
|
|
9
10
|
```js
|
|
10
11
|
const {a, b, c} = user;
|
|
@@ -14,7 +15,7 @@ const {a, b, c} = user;
|
|
|
14
15
|
import {a, b, c} from 'user';
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
## ✅ Example of correct code
|
|
18
19
|
|
|
19
20
|
```js
|
|
20
21
|
const {
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
|
|
35
36
|
## Options
|
|
36
37
|
|
|
37
|
-
`minProperties` - minimum properties count to work with
|
|
38
|
+
`minProperties` - minimum properties count to work with, defaults: `2`.
|
|
38
39
|
|
|
39
40
|
```js
|
|
40
41
|
const {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# single-property-destructuring
|
|
2
2
|
|
|
3
|
-
When 🐊[
|
|
3
|
+
When 🐊[**Putout**](https://github.com/coderaiser/putout) removes unused variables declared as destructured properties, it keeps one property to take 3 lines, instead of 1.
|
|
4
|
+
This rule aims to shorten destructuring of one property, keeping curly braces in one line.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Part of [**eslint-plugin-putout**](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Examples of **incorrect** code for this rule:
|
|
8
|
+
## ❌ Example of incorrect code
|
|
10
9
|
|
|
11
10
|
```js
|
|
12
11
|
import {
|
|
@@ -19,7 +18,7 @@ const {
|
|
|
19
18
|
|
|
20
19
|
```
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
## ✅ Example of correct code
|
|
23
22
|
|
|
24
23
|
```js
|
|
25
24
|
import {password} from './user.js';
|