eslint-plugin-putout 11.6.0 → 11.7.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 +1 -5
- package/lib/no-unresolved/README.md +2 -3
- package/lib/remove-empty-newline-after-last-specifier/README.md +11 -0
- package/lib/remove-empty-newline-after-last-specifier/index.js +2 -1
- package/lib/remove-newline-from-empty-object/README.md +0 -1
- package/lib/single-property-destructuring/README.md +4 -0
- package/lib/single-property-destructuring/index.js +17 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
# eslint-plugin-putout [![NPM version][NPMIMGURL]][NPMURL] [![
|
|
1
|
+
# eslint-plugin-putout [![NPM version][NPMIMGURL]][NPMURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
2
2
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/eslint-plugin-putout.svg?style=flat&longCache=true
|
|
4
|
-
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/eslint-plugin-putout/master.svg?style=flat&longCache=true
|
|
5
|
-
[DependencyStatusIMGURL]: https://david-dm.org/coderaiser/eslint-plugin-putout.svg?path=packages/eslint-plugin-putout
|
|
6
4
|
[NPMURL]: https://npmjs.org/package/eslint-plugin-putout "npm"
|
|
7
|
-
[BuildStatusURL]: https://travis-ci.org/coderaiser/eslint-plugin-putout "Build Status"
|
|
8
|
-
[DependencyStatusURL]: https://david-dm.org/coderaiser/eslint-plugin-putout?path=packages/eslint-plugin-putout "Dependency Status"
|
|
9
5
|
[CoverageURL]: https://coveralls.io/github/coderaiser/putout?branch=master
|
|
10
6
|
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/putout/badge.svg?branch=master&service=github
|
|
11
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# check if path can be resolved and fix if cannot (no-unresolved)
|
|
2
2
|
|
|
3
|
-
Similar to [`no-unresolved`](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-unresolved.md) from
|
|
4
|
-
|
|
3
|
+
Similar to [`no-unresolved`](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-unresolved.md) from
|
|
4
|
+
[`eslint-plugin-putout`](https://github.com/import-js/eslint-plugin-import). But supports only `ESM` and have `autofix`.
|
|
5
5
|
|
|
6
6
|
## Rule Details
|
|
7
7
|
|
|
@@ -27,4 +27,3 @@ Examples of **correct** code for this rule:
|
|
|
27
27
|
import x from './y.js';
|
|
28
28
|
import dir from './dir/index.js';
|
|
29
29
|
```
|
|
30
|
-
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module.exports.category = 'import';
|
|
4
4
|
module.exports.report = () => 'Remove newline after last specifier';
|
|
5
5
|
|
|
6
|
-
const regExp = /\n\s+}/;
|
|
6
|
+
const regExp = /\n\n(\s+)?}/;
|
|
7
7
|
|
|
8
8
|
module.exports.filter = ({text}) => {
|
|
9
9
|
return regExp.test(text);
|
|
@@ -16,5 +16,6 @@ module.exports.fix = ({text}) => {
|
|
|
16
16
|
|
|
17
17
|
module.exports.include = () => [
|
|
18
18
|
'ImportDeclaration',
|
|
19
|
+
'ObjectExpression',
|
|
19
20
|
];
|
|
20
21
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
operator,
|
|
5
|
+
types,
|
|
6
|
+
} = require('putout');
|
|
7
|
+
|
|
4
8
|
const {
|
|
5
9
|
isRestElement,
|
|
6
10
|
isImportDeclaration,
|
|
@@ -10,6 +14,10 @@ const {
|
|
|
10
14
|
const NewLinesReg = /([\s,]+)?\n(\s+)?/g;
|
|
11
15
|
const AssignRegExp = /{\n?.*=.*\n?.*}/;
|
|
12
16
|
|
|
17
|
+
const {
|
|
18
|
+
compare,
|
|
19
|
+
} = operator;
|
|
20
|
+
|
|
13
21
|
module.exports.category = 'destructuring';
|
|
14
22
|
module.exports.report = () => 'Keep curly braces on one line when you have one destructuring property';
|
|
15
23
|
|
|
@@ -18,16 +26,19 @@ module.exports.include = () => [
|
|
|
18
26
|
'ImportDeclaration[specifiers.length=1]',
|
|
19
27
|
];
|
|
20
28
|
|
|
21
|
-
module.exports.filter = ({node, getText}) => {
|
|
22
|
-
const
|
|
29
|
+
module.exports.filter = ({node, text, getText}) => {
|
|
30
|
+
const parentText = getText(node.parent);
|
|
31
|
+
|
|
32
|
+
if (isImportDeclaration(node) && !compare(node.specifiers[0].local, node.specifiers[0].imported))
|
|
33
|
+
return false;
|
|
23
34
|
|
|
24
|
-
if (isImportDeclaration(node) && /import {\n/.test(
|
|
35
|
+
if (isImportDeclaration(node) && /import {\n/.test(text))
|
|
25
36
|
return true;
|
|
26
37
|
|
|
27
|
-
if (AssignRegExp.test(
|
|
38
|
+
if (AssignRegExp.test(parentText))
|
|
28
39
|
return false;
|
|
29
40
|
|
|
30
|
-
if (isVariableDeclarator(node) && /(const|let|var) {\n/.test(
|
|
41
|
+
if (isVariableDeclarator(node) && /(const|let|var) {\n/.test(parentText))
|
|
31
42
|
return true;
|
|
32
43
|
|
|
33
44
|
return false;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.7.0",
|
|
4
4
|
"description": "eslint plugin for putout",
|
|
5
5
|
"release": false,
|
|
6
6
|
"tag": false,
|
|
7
|
+
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout",
|
|
7
8
|
"changelog": false,
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|