eslint-plugin-putout 14.1.0 → 14.2.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
CHANGED
|
@@ -81,6 +81,10 @@ Then configure the rules you want to use under the rules section.
|
|
|
81
81
|
|
|
82
82
|
- ✅ [Add newlines between types in union](/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union#readme)
|
|
83
83
|
|
|
84
|
+
### ESM
|
|
85
|
+
|
|
86
|
+
- ✅ [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved#readme)
|
|
87
|
+
|
|
84
88
|
### Formatting
|
|
85
89
|
|
|
86
90
|
- ✅ [Add newline before function call](/packages/eslint-plugin-putout/lib/add-newline-before-function-call#readme)
|
|
@@ -104,7 +108,7 @@ Then configure the rules you want to use under the rules section.
|
|
|
104
108
|
- ✅ [Remove empty specifiers](/packages/eslint-plugin-putout/lib/remove-empty-specifiers#readme)
|
|
105
109
|
- ✅ [Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array#readme)
|
|
106
110
|
- ✅ [Object init](/packages/eslint-plugin-putout/lib/object-init#readme)
|
|
107
|
-
- ✅ [
|
|
111
|
+
- ✅ [Nonblock statement body newline](/packages/eslint-plugin-putout/lib/non-block-statement-body-newline#readme)
|
|
108
112
|
|
|
109
113
|
### Safe mode
|
|
110
114
|
|
package/lib/index.js
CHANGED
|
@@ -42,6 +42,7 @@ module.exports.rules = {
|
|
|
42
42
|
...getWrapRule('tape-add-newline-before-assertion'),
|
|
43
43
|
...getWrapRule('tape-add-newline-between-tests'),
|
|
44
44
|
...getWrapRule('tape-remove-newline-before-t-end'),
|
|
45
|
+
...getWrapRule('nonblock-statement-body-newline'),
|
|
45
46
|
...getRule('putout'),
|
|
46
47
|
...getRule('remove-empty-newline-after-import'),
|
|
47
48
|
};
|
|
@@ -83,6 +84,7 @@ const recommended = {
|
|
|
83
84
|
'putout/tape-add-newline-before-assertion': 'error',
|
|
84
85
|
'putout/tape-add-newline-between-tests': 'error',
|
|
85
86
|
'putout/tape-remove-newline-before-t-end': 'error',
|
|
87
|
+
'putout/nonblock-statement-body-newline': 'error',
|
|
86
88
|
'putout/putout': 'error',
|
|
87
89
|
|
|
88
90
|
'node/no-unsupported-features/es-syntax': 'off',
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# keyword-spacing
|
|
2
2
|
|
|
3
|
-
When
|
|
3
|
+
When 🐊[**Putout**](https://github.com/coderaiser/putout) removes unused variable in `catch` [eslint keyword spacing](https://eslint.org/docs/rules/keyword-spacing) can't handle [optional catch binding](https://github.com/tc39/proposal-optional-catch-binding) correctly. This rule adds spaces around `catch`.
|
|
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
|
-
try
|
|
13
|
-
} catch
|
|
10
|
+
try{
|
|
11
|
+
} catch{
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
try {
|
|
17
|
-
}
|
|
15
|
+
}catch{
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
try {
|
|
21
|
-
}
|
|
19
|
+
}catch(error) {
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
if(a) {
|
|
@@ -33,7 +31,7 @@ async () => {
|
|
|
33
31
|
};
|
|
34
32
|
```
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
## ✅ Example of correct code
|
|
37
35
|
|
|
38
36
|
```js
|
|
39
37
|
try {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# nonblock-statement-body-newline
|
|
2
|
+
|
|
3
|
+
Remove newline inside statement body. Part of [**eslint-plugin-putout**](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
|
|
4
|
+
|
|
5
|
+
## ❌ Example of incorrect code
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
if (a)
|
|
9
|
+
|
|
10
|
+
b();
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## ✅ Example of correct code
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
if (a)
|
|
17
|
+
b();
|
|
18
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {types} = require('putout');
|
|
4
|
+
const {isExpressionStatement} = types;
|
|
5
|
+
|
|
6
|
+
const reg = /\)\n(\s+)?\n/;
|
|
7
|
+
|
|
8
|
+
module.exports.report = () => `Remove newline`;
|
|
9
|
+
|
|
10
|
+
module.exports.fix = ({text}) => {
|
|
11
|
+
return text.replace(reg, ')\n');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports.include = () => [
|
|
15
|
+
'IfStatement',
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
module.exports.filter = ({node, text}) => {
|
|
19
|
+
const {consequent} = node;
|
|
20
|
+
|
|
21
|
+
if (!isExpressionStatement(consequent))
|
|
22
|
+
return false;
|
|
23
|
+
|
|
24
|
+
return reg.test(text);
|
|
25
|
+
};
|
|
26
|
+
|