eslint-plugin-putout 16.7.0 → 16.9.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.
|
@@ -54,6 +54,9 @@ module.exports.filter = ({text, node}) => {
|
|
|
54
54
|
if (/Statement/.test(node.parent.type))
|
|
55
55
|
return false;
|
|
56
56
|
|
|
57
|
+
if (isLongValues(node.elements))
|
|
58
|
+
return false;
|
|
59
|
+
|
|
57
60
|
if (node.elements.length < 5 && isShortValues(node.elements))
|
|
58
61
|
return false;
|
|
59
62
|
|
|
@@ -77,6 +80,15 @@ function isShortValues(elements) {
|
|
|
77
80
|
return true;
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
function isLongValues(elements) {
|
|
84
|
+
for (const {type, value} of elements) {
|
|
85
|
+
if (type === 'Literal' && isString(value) && value.includes(','))
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
function differentTypes({elements}) {
|
|
81
93
|
let hasLiteral = false;
|
|
82
94
|
let hasIdentifier = false;
|
package/lib/evaluate/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Evaluate
|
|
2
2
|
|
|
3
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
|
-
Provided code is processed with [`@putout/plugin-declare
|
|
4
|
+
Provided code is processed with [`@putout/plugin-declare`](https://github.com/coderaiser/putout/tree/master/packages/plugin-declare):
|
|
5
5
|
|
|
6
6
|
```js
|
|
7
7
|
__putout_evaluate: join('hello', ' ', 'world');
|
package/lib/evaluate/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const {
|
|
|
9
9
|
isRestElement,
|
|
10
10
|
isImportDeclaration,
|
|
11
11
|
isVariableDeclarator,
|
|
12
|
+
isAssignmentPattern,
|
|
12
13
|
} = types;
|
|
13
14
|
|
|
14
15
|
const NewLinesReg = /([\s,]+)?\n(\s+)?/g;
|
|
@@ -41,8 +42,15 @@ module.exports.filter = ({node, text, getText, getCommentsInside}) => {
|
|
|
41
42
|
if (AssignRegExp.test(parentText))
|
|
42
43
|
return false;
|
|
43
44
|
|
|
44
|
-
if (isVariableDeclarator(node) && /(const|let|var) {\n/.test(parentText))
|
|
45
|
+
if (isVariableDeclarator(node) && /(const|let|var) {\n/.test(parentText)) {
|
|
46
|
+
const [property] = node.id.properties;
|
|
47
|
+
const {value} = property;
|
|
48
|
+
|
|
49
|
+
if (isAssignmentPattern(value))
|
|
50
|
+
return false;
|
|
51
|
+
|
|
45
52
|
return true;
|
|
53
|
+
}
|
|
46
54
|
|
|
47
55
|
return false;
|
|
48
56
|
};
|