eslint-plugin-putout 11.3.0 → 11.4.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
@@ -49,6 +49,7 @@ Then configure the rules you want to use under the rules section.
49
49
  "putout/newline-function-call-arguments": "error",
50
50
  "putout/function-declaration-paren-newline": "error",
51
51
  "putout/remove-newline-after-default-import": "error",
52
+ "putout/remove-newline-from-empty-object": "error",
52
53
  "putout/remove-empty-newline-after-last-specifier": "error",
53
54
  "putout/objects-braces-inside-array": "error",
54
55
  "putout/object-init": "error"
@@ -69,6 +70,7 @@ Then configure the rules you want to use under the rules section.
69
70
  - [Newline function call arguments](/packages/eslint-plugin-putout/lib/newline-function-call-arguments)
70
71
  - [Function declaration paren newline](/packages/eslint-plugin-putout/lib/function-declaration-paren-newline)
71
72
  - [Remove newline after default import](/packages/eslint-plugin-putout/lib/remove-newline-after-default-import)
73
+ - [Remove newline from empty object](/packages/eslint-plugin-putout/lib/remove-newline-from-empty-object)
72
74
  - [Remove empty newline after last specifier](/packages/eslint-plugin-putout/lib/remove-empty-newline-after-last-specifier)
73
75
  - [Objects braces inside array](/packages/eslint-plugin-putout/lib/objects-braces-inside-array)
74
76
  - [Object init](/packages/eslint-plugin-putout/lib/object-init)
package/lib/index.js CHANGED
@@ -26,6 +26,7 @@ module.exports.rules = {
26
26
  ...getWrapRule('newline-function-call-arguments'),
27
27
  ...getWrapRule('function-declaration-paren-newline'),
28
28
  ...getWrapRule('remove-newline-after-default-import'),
29
+ ...getWrapRule('remove-newline-from-empty-object'),
29
30
  ...getWrapRule('remove-empty-newline-after-last-specifier'),
30
31
  ...getWrapRule('objects-braces-inside-array'),
31
32
  ...getWrapRule('object-init'),
@@ -56,6 +57,7 @@ const recommended = {
56
57
  'putout/newline-function-call-arguments': 'error',
57
58
  'putout/function-declaration-paren-newline': 'error',
58
59
  'putout/remove-newline-after-default-import': 'error',
60
+ 'putout/remove-newline-from-empty-object': 'error',
59
61
  'putout/remove-empty-newline-after-last-specifier': 'error',
60
62
  'putout/objects-braces-inside-array': 'error',
61
63
  'putout/object-init': 'error',
@@ -0,0 +1,19 @@
1
+ # Remove new line in empty object (remove-newline-from-empty-object)
2
+
3
+ ## Rule Details
4
+
5
+ This rule aims to remove newline from empty object.
6
+
7
+ Examples of **incorrect** code for this rule:
8
+
9
+ ```js
10
+ const a = {
11
+
12
+ };
13
+ ```
14
+
15
+ Examples of **correct** code for this rule:
16
+
17
+ ```js
18
+ const a = {};
19
+ ```
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ const {types} = require('putout');
4
+ const {isArrayExpression} = types;
5
+
6
+ module.exports.category = 'object';
7
+ module.exports.report = () => 'Remove newline from empty object';
8
+
9
+ const regExp = /\n/;
10
+
11
+ module.exports.filter = ({text, node}) => {
12
+ if (isArrayExpression(node.parent))
13
+ return false;
14
+
15
+ if (node.properties.length)
16
+ return false;
17
+
18
+ return regExp.test(text);
19
+ };
20
+
21
+ module.exports.fix = () => '{}';
22
+
23
+ module.exports.include = () => [
24
+ 'ObjectExpression',
25
+ ];
26
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "description": "eslint plugin for putout",
5
5
  "release": false,
6
6
  "tag": false,