eslint-plugin-putout 12.9.1 → 12.12.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
@@ -101,22 +101,27 @@ When using 🐊`Putout` in IDE with `--fix` on save, or when you want to disable
101
101
  }
102
102
  ```
103
103
 
104
+ ### safe+align
105
+
106
+ When you want to enable ability to align spaces on empty lines, use `safe+align`.
107
+
104
108
  Disabled `ESLint` rules:
105
109
 
106
- - [no-useless-return](https://eslint.org/docs/rules/no-useless-return)
110
+ - [`no-useless-return`](https://eslint.org/docs/rules/no-useless-return)
111
+ - [`putout/remove-newline-from-empty-object`](https://eslint.org/docs/rules/no-useless-return)
107
112
 
108
113
  Disabled 🐊`Putout` rules:
109
114
 
110
- - [remove-empty](https://github.com/coderaiser/putout/tree/v22.0.0/packages/plugin-remove-empty);
111
- - [remove-unused-variables](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-variables);
112
- - [remove-unused-types](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-types);
113
- - [remove-unused-for-of-variables](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-for-of-variables);
114
- - [remove-unused-expressions](https://github.com/coderaiser/putout/tree/v22.0.0/packages);
115
- - [remove-useless-return](https://github.com/coderaiser/putout/tree/master/remove-useless-return);
116
- - [remove-useless-arguments](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments);
117
- - [remove-skip](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-skip);
118
- - [remove-only](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-only);
119
- - [remove-console](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-console);
120
- - [remove-debugger](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-debugger);
121
- - [remove-unreachable-code](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unreachable-code);
122
- - [convert-for-to-for-of](https://github.com/coderaiser/putout/tree/v22.0.0/packages/convert-for-to-for-of);
115
+ - [`remove-empty`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/plugin-remove-empty);
116
+ - [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-variables);
117
+ - [`remove-unused-types`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-types);
118
+ - [`remove-unused-for-of-variables`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-for-of-variables);
119
+ - [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v22.0.0/packages);
120
+ - [`remove-useless-return`](https://github.com/coderaiser/putout/tree/master/remove-useless-return);
121
+ - [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/remove-useless-arguments);
122
+ - [`remove-skip`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-skip);
123
+ - [`remove-only`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-only);
124
+ - [`remove-console`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-console);
125
+ - [`remove-debugger`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-debugger);
126
+ - [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unreachable-code);
127
+ - [`convert-for-to-for-of`](https://github.com/coderaiser/putout/tree/v22.0.0/packages/convert-for-to-for-of);
@@ -10,7 +10,7 @@ const {
10
10
  isArrayExpression,
11
11
  } = types;
12
12
 
13
- const regExp = /^;?\n( +)?\n +$/;
13
+ const regExp = /^;?\n( +)?\n( +)?/;
14
14
 
15
15
  module.exports.category = 'layout';
16
16
  module.exports.report = () => 'Add newline after function call';
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Rule Details
4
4
 
5
- This rule aims to add newline before function call.
5
+ This rule aims to add newline before `function call` and `assignment`.
6
6
 
7
7
  Examples of **incorrect** code for this rule:
8
8
 
@@ -12,6 +12,10 @@ export function parse() {
12
12
  const b = 2;
13
13
  fn();
14
14
  }
15
+
16
+ export function calc() {
17
+ const b = 2;
18
+ }
15
19
  ```
16
20
 
17
21
  Examples of **correct** code for this rule:
@@ -23,4 +27,8 @@ export function parse() {
23
27
 
24
28
  fn();
25
29
  }
30
+
31
+ export function calc() {
32
+ const b = 2;
33
+ }
26
34
  ```
@@ -11,7 +11,7 @@ const {
11
11
  const regExp = /^\n( +)?\n +$/;
12
12
 
13
13
  module.exports.category = 'typescript';
14
- module.exports.report = () => 'Add newline before function call';
14
+ module.exports.report = () => 'Add newline before expression';
15
15
 
16
16
  module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) => {
17
17
  if (!isExpressionStatement(node.parent))
@@ -69,5 +69,5 @@ module.exports.fix = ({text}) => {
69
69
 
70
70
  module.exports.include = () => [
71
71
  'CallExpression',
72
+ 'AssignmentExpression',
72
73
  ];
73
-
@@ -10,9 +10,7 @@ module.exports.report = () => {
10
10
  return `Unexpected new lines around arguments`;
11
11
  };
12
12
 
13
- module.exports.fix = ({text}) => {
14
- return fixNewLines(text);
15
- };
13
+ module.exports.fix = ({text}) => fixNewLines(text);
16
14
 
17
15
  module.exports.include = () => [
18
16
  'FunctionDeclaration',
package/lib/index.js CHANGED
@@ -99,6 +99,7 @@ const safe = {
99
99
  ...recommended.rules,
100
100
  'no-useless-return': 'off',
101
101
  'putout/align-spaces': 'off',
102
+ 'putout/remove-newline-from-empty-object': 'off',
102
103
  'putout/putout': ['error', {
103
104
  rules: {
104
105
  'remove-empty': 'off',
@@ -122,5 +123,12 @@ const safe = {
122
123
  module.exports.configs = {
123
124
  recommended,
124
125
  safe,
126
+ 'safe+align': {
127
+ ...safe,
128
+ rules: {
129
+ ...safe.rules,
130
+ 'putout/align-spaces': 'error',
131
+ },
132
+ },
125
133
  };
126
134
 
@@ -8,7 +8,12 @@ module.exports.report = () => 'Remove newline from empty object';
8
8
 
9
9
  const regExp = /\n/;
10
10
 
11
- module.exports.filter = ({text, node}) => {
11
+ module.exports.filter = ({text, node, getCommentsInside}) => {
12
+ const comments = getCommentsInside(node);
13
+
14
+ if (comments.length)
15
+ return false;
16
+
12
17
  if (isArrayExpression(node.parent))
13
18
  return false;
14
19
 
package/lib/wrap.js CHANGED
@@ -8,6 +8,7 @@ const prepare = (plugin, context, options) => (node) => {
8
8
  const getText = source.getText.bind(source);
9
9
  const getCommentsBefore = source.getCommentsBefore.bind(source);
10
10
  const getCommentsAfter = source.getCommentsAfter.bind(source);
11
+ const getCommentsInside = source.getCommentsInside.bind(source);
11
12
 
12
13
  const getSpacesBeforeNode = createGetSpacesBeforeNode({
13
14
  getText,
@@ -26,6 +27,7 @@ const prepare = (plugin, context, options) => (node) => {
26
27
  getText,
27
28
  getCommentsBefore,
28
29
  getCommentsAfter,
30
+ getCommentsInside,
29
31
  getSpacesBeforeNode,
30
32
  getSpacesAfterNode,
31
33
  filename,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "12.9.1",
3
+ "version": "12.12.0",
4
4
  "type": "commonjs",
5
5
  "description": "eslint plugin for putout",
6
6
  "release": false,