eslint-plugin-putout 11.0.0 → 11.1.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
@@ -73,6 +73,7 @@ Then configure the rules you want to use under the rules section.
73
73
  - [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved)
74
74
  - [Evaluate](/packages/eslint-plugin-putout/lib/evaluate)
75
75
  - [Tape: add new line before assertion]('/packages/eslint-plugin-putout/lib/tape-add-new-line-before-assertion)
76
+ - [Tape: add new line between tests]('/packages/eslint-plugin-putout/lib/tape-add-new-line-between-tests)
76
77
 
77
78
  ### Safe mode
78
79
 
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ module.exports.rules = {
31
31
  ...getWrapRule('no-unresolved'),
32
32
  ...getWrapRule('evaluate'),
33
33
  ...getWrapRule('tape-add-newline-before-assertion'),
34
+ ...getWrapRule('tape-add-newline-between-tests'),
34
35
  ...getRule('putout'),
35
36
  };
36
37
 
@@ -59,6 +60,7 @@ const recommended = {
59
60
  'putout/no-unresolved': 'error',
60
61
  'putout/evaluate': 'error',
61
62
  'putout/tape-add-newline-before-assertion': 'error',
63
+ 'putout/tape-add-newline-between-tests': 'error',
62
64
  'putout/putout': 'error',
63
65
 
64
66
  'node/no-unsupported-features/es-syntax': 'off',
@@ -0,0 +1,42 @@
1
+ # Add new line between tests (add-newline-between-tests)
2
+
3
+ Add new line between tests, for [supertape](https://github.com/coderaiser/supertape).
4
+
5
+ ## Rule Details
6
+
7
+ This rule aims to add new line between tests.
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
+ t.end();
17
+ });
18
+ test('lint: do some check', (t) => {
19
+ const result = 1 + 2;
20
+
21
+ t.equal(result, 3);
22
+ t.end();
23
+ });
24
+ ```
25
+
26
+ Examples of **correct** code for this rule:
27
+
28
+ ```js
29
+ test('lint: do some check', (t) => {
30
+ const result = 1 + 2;
31
+
32
+ t.equal(result, 3);
33
+ t.end();
34
+ });
35
+
36
+ test('lint: do some check', (t) => {
37
+ const result = 1 + 2;
38
+
39
+ t.equal(result, 3);
40
+ t.end();
41
+ });
42
+ ```
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ module.exports.category = 'tape';
4
+ module.exports.report = () => 'Add new line between tests';
5
+
6
+ module.exports.filter = ({text, node, getText, getCommentsBefore}) => {
7
+ if (!/^test(\.only|\.skip)?\(/.test(text))
8
+ return false;
9
+
10
+ const comments = getCommentsBefore(node);
11
+
12
+ if (comments.length)
13
+ return false;
14
+
15
+ const [a] = getText(node, 2);
16
+
17
+ return a === ';';
18
+ };
19
+
20
+ module.exports.fix = ({text}) => {
21
+ return `\n${text}`;
22
+ };
23
+
24
+ module.exports.include = () => [
25
+ 'CallExpression ',
26
+ ];
27
+
package/lib/wrap.js CHANGED
@@ -6,6 +6,7 @@ const prepare = (plugin, context, options) => (node) => {
6
6
  const source = context.getSourceCode();
7
7
  const filename = context.getFilename();
8
8
  const getText = source.getText.bind(source);
9
+ const getCommentsBefore = source.getCommentsBefore.bind(source);
9
10
 
10
11
  const text = getText(node);
11
12
 
@@ -14,6 +15,7 @@ const prepare = (plugin, context, options) => (node) => {
14
15
  node,
15
16
  options,
16
17
  getText,
18
+ getCommentsBefore,
17
19
  filename,
18
20
  });
19
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "eslint plugin for putout",
5
5
  "release": false,
6
6
  "tag": false,