eslint-plugin-putout 12.9.0 → 12.11.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,6 +101,10 @@ 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
110
  - [no-useless-return](https://eslint.org/docs/rules/no-useless-return)
@@ -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
-
package/lib/common.js CHANGED
@@ -3,11 +3,7 @@
3
3
  const {isImportDefaultSpecifier} = require('putout').types;
4
4
 
5
5
  module.exports.isCorrectLoc = (line, properties) => {
6
- const n = properties.length;
7
-
8
- for (let i = 0; i < n; i++) {
9
- const prop = properties[i];
10
-
6
+ for (const [i, prop] of properties.entries()) {
11
7
  if (prop.loc.start.line < i + line + 1)
12
8
  return false;
13
9
  }
@@ -16,14 +12,10 @@ module.exports.isCorrectLoc = (line, properties) => {
16
12
  };
17
13
 
18
14
  module.exports.isCorrectImportLoc = (line, specifiers) => {
19
- const n = specifiers.length;
20
-
21
15
  if (!isImportDefaultSpecifier(specifiers[0]))
22
16
  ++line;
23
17
 
24
- for (let i = 0; i < n; i++) {
25
- const spec = specifiers[i];
26
-
18
+ for (const [i, spec] of specifiers.entries()) {
27
19
  if (spec.loc.start.line < i + line)
28
20
  return false;
29
21
  }
@@ -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
@@ -122,5 +122,12 @@ const safe = {
122
122
  module.exports.configs = {
123
123
  recommended,
124
124
  safe,
125
+ 'safe+align': {
126
+ ...safe,
127
+ rules: {
128
+ ...safe.rules,
129
+ 'putout/align-spaces': 'error',
130
+ },
131
+ },
125
132
  };
126
133
 
@@ -9,7 +9,7 @@ This rule aims to fix eslint transform.
9
9
  Examples of **incorrect** code for this rule:
10
10
 
11
11
  ```js
12
- const onConnectError = squad(superFn('connect_error'),
12
+ const onConnectError = squad(superFn(connect_error),
13
13
  logWraped(isLog, importStr),
14
14
  addUrl(colorUrl),
15
15
  getDescription);
@@ -19,7 +19,7 @@ Examples of **correct** code for this rule:
19
19
 
20
20
  ```js
21
21
  const onConnectError = squad(
22
- superFn('connect_error'),
22
+ superFn(connect_error),
23
23
  logWraped(isLog, importStr),
24
24
  addUrl(colorUrl),
25
25
  getDescription,
@@ -10,6 +10,9 @@ module.exports.filter = ({node, text}) => {
10
10
  if (node.callee.type !== 'Identifier')
11
11
  return false;
12
12
 
13
+ if (text.includes(`'`))
14
+ return false;
15
+
13
16
  const {name} = node.callee;
14
17
 
15
18
  if (node.arguments.length < 3)
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "12.9.0",
3
+ "version": "12.11.0",
4
+ "type": "commonjs",
4
5
  "description": "eslint plugin for putout",
5
6
  "release": false,
6
7
  "tag": false,
7
- "homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout",
8
+ "homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme",
8
9
  "changelog": false,
9
10
  "repository": {
10
11
  "type": "git",