eslint-plugin-putout 16.6.0 → 16.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.
@@ -5,9 +5,10 @@ const {
5
5
  isBlockStatement,
6
6
  isVariableDeclaration,
7
7
  isExpressionStatement,
8
+ isProgram,
8
9
  } = types;
9
10
 
10
- const regExp = /^\n( +)?\n +$/;
11
+ const regExp = /^\n( +)?\n( +)?$/;
11
12
 
12
13
  module.exports.report = () => 'Add newline before expression';
13
14
 
@@ -20,7 +21,7 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
20
21
 
21
22
  const {parent} = node.parent;
22
23
 
23
- if (!isBlockStatement(parent))
24
+ if (!isBlockStatement(parent) && !isProgram(parent))
24
25
  return false;
25
26
 
26
27
  const {body} = parent;
@@ -29,6 +30,9 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
29
30
  if (n < 3)
30
31
  return false;
31
32
 
33
+ if (body[0].expression === node)
34
+ return false;
35
+
32
36
  const spaces = getSpacesBeforeNode(node, text);
33
37
 
34
38
  if (!spaces)
@@ -55,6 +59,8 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
55
59
 
56
60
  return true;
57
61
  }
62
+
63
+ return false;
58
64
  };
59
65
 
60
66
  module.exports.fix = ({text}) => {
@@ -64,5 +70,4 @@ module.exports.fix = ({text}) => {
64
70
  module.exports.include = () => [
65
71
  'CallExpression',
66
72
  'AssignmentExpression',
67
- 'ReturnStatement',
68
73
  ];
@@ -26,6 +26,7 @@ const isSupportedNode = (a) => {
26
26
 
27
27
  return false;
28
28
  };
29
+
29
30
  module.exports.filter = ({text, node}) => {
30
31
  if (isMemberExpression(node.parent))
31
32
  return false;
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ const getRule = (a) => ({
13
13
  const getWrapRule = (a) => ({
14
14
  [a]: createPlugin(require(`./${a}`)),
15
15
  });
16
+
16
17
  module.exports.rules = {
17
18
  ...getWrapRule('array-element-newline'),
18
19
  ...getWrapRule('single-property-destructuring'),
@@ -128,6 +129,7 @@ const safe = {
128
129
  }],
129
130
  },
130
131
  };
132
+
131
133
  module.exports.configs = {
132
134
  recommended,
133
135
  'jsx': jsx.jsx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "16.6.0",
3
+ "version": "16.7.0",
4
4
  "type": "commonjs",
5
5
  "description": "ESLint plugin for 🐊Putout",
6
6
  "release": false,