eslint-plugin-putout 11.9.0 → 11.13.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
@@ -5,7 +5,7 @@
5
5
  [CoverageURL]: https://coveralls.io/github/coderaiser/putout?branch=master
6
6
  [CoverageIMGURL]: https://coveralls.io/repos/coderaiser/putout/badge.svg?branch=master&service=github
7
7
 
8
- [`ESLint`](https://eslint.org) plugin for [🐊`Putout`](https://github.com/coderaiser/putout) with built-in rules from [@putout/eslint-config](https://github.com/coderaiser/eslint-plugin-putout/tree/master/packages/eslint-config).
8
+ [`ESLint`](https://eslint.org) plugin for 🐊[`Putout`](https://github.com/coderaiser/putout) with built-in rules from [@putout/eslint-config](https://github.com/coderaiser/eslint-plugin-putout/tree/master/packages/eslint-config).
9
9
 
10
10
  ## Installation
11
11
 
@@ -58,7 +58,7 @@ Then configure the rules you want to use under the rules section.
58
58
 
59
59
  ## Supported Rules
60
60
 
61
- - [putout](lib/putout)
61
+ - [Putout](lib/putout)
62
62
  - [Array element newline](/packages/eslint-plugin-putout/lib/array-element-newline)
63
63
  - [Single property destructuring](/packages/eslint-plugin-putout/lib/single-property-destructuring)
64
64
  - [Multiple properties destructuring](/packages/eslint-plugin-putout/lib/multiple-properties-destructuring)
@@ -78,8 +78,9 @@ Then configure the rules you want to use under the rules section.
78
78
  - [Object init](/packages/eslint-plugin-putout/lib/object-init)
79
79
  - [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved)
80
80
  - [Evaluate](/packages/eslint-plugin-putout/lib/evaluate)
81
- - [Tape: add new line before assertion]('/packages/eslint-plugin-putout/lib/tape-add-new-line-before-assertion)
82
- - [Tape: add new line between tests]('/packages/eslint-plugin-putout/lib/tape-add-new-line-between-tests)
81
+ - [Tape: add newline before assertion]('/packages/eslint-plugin-putout/lib/tape-add-new-line-before-assertion)
82
+ - [Tape: add newline between tests]('/packages/eslint-plugin-putout/lib/tape-add-new-line-between-tests)
83
+ - [Tape: remove newline before t.end()]('/packages/eslint-plugin-putout/lib/tape-remove-newline-before-t-end)
83
84
 
84
85
  ### Safe mode
85
86
 
@@ -11,16 +11,24 @@ module.exports.report = () => 'Add newlines between array elements';
11
11
 
12
12
  const regexp = /['\da-zA-Z]+, ['\da-zA-Z]/;
13
13
 
14
- const isESTreeLiteral = (a) => a.type === 'Literal';
14
+ const isSupportedNode = (a) => {
15
+ if (a.type === 'Literal')
16
+ return true;
17
+
18
+ if (a.type === 'Identifier')
19
+ return true;
20
+
21
+ return false;
22
+ };
15
23
 
16
24
  module.exports.filter = ({text, node}) => {
17
25
  if (isMemberExpression(node.parent))
18
26
  return false;
19
27
 
20
- const isAllPrimitives = node.elements
21
- .every(isESTreeLiteral);
28
+ const supported = node.elements
29
+ .every(isSupportedNode);
22
30
 
23
- if (!isAllPrimitives )
31
+ if (!supported)
24
32
  return false;
25
33
 
26
34
  if (!isVariableDeclarator(node.parent))
package/lib/index.js CHANGED
@@ -37,6 +37,7 @@ module.exports.rules = {
37
37
  ...getWrapRule('evaluate'),
38
38
  ...getWrapRule('tape-add-newline-before-assertion'),
39
39
  ...getWrapRule('tape-add-newline-between-tests'),
40
+ ...getWrapRule('tape-remove-newline-before-t-end'),
40
41
  ...getRule('putout'),
41
42
  };
42
43
 
@@ -71,6 +72,7 @@ const recommended = {
71
72
  'putout/evaluate': 'error',
72
73
  'putout/tape-add-newline-before-assertion': 'error',
73
74
  'putout/tape-add-newline-between-tests': 'error',
75
+ 'putout/tape-remove-newline-before-t-end': 'error',
74
76
  'putout/putout': 'error',
75
77
 
76
78
  'node/no-unsupported-features/es-syntax': 'off',
package/lib/json.js CHANGED
@@ -11,7 +11,6 @@ module.exports = [{
11
11
  'no-undef': 'off',
12
12
  'eol-last': 'off',
13
13
  'no-multi-spaces': 'off',
14
- 'putout/objects-braces-inside-array': 'off',
15
14
  },
16
15
  }, {
17
16
  files: 'package.json',
@@ -1,6 +1,6 @@
1
1
  # Putout (putout)
2
2
 
3
- [Putout](https://github.com/coderaiser/putout) used as eslint plugin.
3
+ 🐊[`Putout`](https://github.com/coderaiser/putout) used as eslint plugin.
4
4
 
5
5
  ## Rule Details
6
6
 
@@ -1,10 +1,10 @@
1
- # Add new line before assertion (add-newline-before-assertion)
1
+ # Add newline before assertion (add-newline-before-assertion)
2
2
 
3
- Add new line before `t.equal()` etc, for [supertape](https://github.com/coderaiser/supertape).
3
+ Add newline before `t.equal()` etc, for [supertape](https://github.com/coderaiser/supertape).
4
4
 
5
5
  ## Rule Details
6
6
 
7
- This rule aims to add new line before assertion.
7
+ This rule aims to add newline before assertion.
8
8
 
9
9
  Examples of **incorrect** code for this rule:
10
10
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports.category = 'tape';
4
- module.exports.report = () => 'Add new line before assertion';
4
+ module.exports.report = () => 'Add newline before assertion';
5
5
 
6
6
  const regexp = /;\n +?t\..*;\n +?t.end\(\);/;
7
7
 
@@ -1,10 +1,10 @@
1
- # Add new line between tests (add-newline-between-tests)
1
+ # Add newline between tests (add-newline-between-tests)
2
2
 
3
- Add new line between tests, for [supertape](https://github.com/coderaiser/supertape).
3
+ Add newline between tests, for [supertape](https://github.com/coderaiser/supertape).
4
4
 
5
5
  ## Rule Details
6
6
 
7
- This rule aims to add new line between tests.
7
+ This rule aims to add newline between tests.
8
8
 
9
9
  Examples of **incorrect** code for this rule:
10
10
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports.category = 'tape';
4
- module.exports.report = () => 'Add new line between tests';
4
+ module.exports.report = () => 'Add newline between tests';
5
5
 
6
6
  module.exports.filter = ({text, node, getText, getCommentsBefore}) => {
7
7
  if (!/^test(\.only|\.skip)?\(/.test(text))
@@ -0,0 +1,30 @@
1
+ # Remove newline before `t.end()` (remove-newline-before-t-end)
2
+
3
+ Remove newline before `t.end()`, for [supertape](https://github.com/coderaiser/supertape).
4
+
5
+ ## Rule Details
6
+
7
+ This rule aims to remove newline before `t.end()`.
8
+
9
+ Examples of **incorrect** code for this rule:
10
+
11
+ ```js
12
+ test('lint: do some check', (t) => {
13
+ const result = 1 + 2;
14
+
15
+ t.equal(result, 3);
16
+
17
+ t.end();
18
+ });
19
+ ```
20
+
21
+ Examples of **correct** code for this rule:
22
+
23
+ ```js
24
+ test('lint: do some check', (t) => {
25
+ const result = 1 + 2;
26
+
27
+ t.equal(result, 3);
28
+ t.end();
29
+ });
30
+ ```
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ module.exports.category = 'tape';
4
+ module.exports.report = () => 'Remove newline before t.end()';
5
+
6
+ const newlineReg = /\n( +)?\n +t.end\(\)/;
7
+
8
+ module.exports.filter = ({text}) => {
9
+ if (!/^test(\.only|\.skip)?\(/.test(text))
10
+ return false;
11
+
12
+ if (newlineReg.test(text))
13
+ return true;
14
+
15
+ return false;
16
+ };
17
+
18
+ module.exports.fix = ({text}) => {
19
+ return text.replace(newlineReg, '\n t.end()');
20
+ };
21
+
22
+ module.exports.include = () => [
23
+ 'CallExpression',
24
+ ];
25
+
package/lib/yaml.js CHANGED
@@ -4,6 +4,7 @@ module.exports = [{
4
4
  files: '*.{yml,yaml}{json}',
5
5
  rules: {
6
6
  'comma-spacing': 'off',
7
+ 'putout/objects-braces-inside-array': 'off',
7
8
  },
8
9
  }];
9
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "11.9.0",
3
+ "version": "11.13.0",
4
4
  "description": "eslint plugin for putout",
5
5
  "release": false,
6
6
  "tag": false,