eslint-plugin-putout 17.6.0 β†’ 17.7.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
@@ -133,24 +133,43 @@ Disabled **ESLint** rules:
133
133
  Disabled 🐊**Putout** rules:
134
134
 
135
135
  - ❌ [`apply-template-literals`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
136
+
136
137
  - ❌ [`remove-empty`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
138
+
137
139
  - ❌ [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-nodejs#remove-process-exit#readme);
140
+
138
141
  - ❌ [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-variables#readme);
142
+
139
143
  - ❌ [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types#readme);
140
- - ❌ [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-removeunused-expressions#readme);
141
- - ❌ [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/29.0.0/packages/plugin-remove-unreferenced-variables#readme);
144
+
145
+ - ❌ [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-expressions#readme);
146
+
147
+ - ❌ [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreferenced-variables#readme);
148
+
142
149
  - ❌ [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#readme);
150
+
143
151
  - ❌ [`remove-useless-return`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-return#readme);
144
- - ❌ [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-spread/#readme#readme);
145
- - ❌ [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-arguments#rename#readme);
152
+
153
+ - ❌ [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-spread/#readme);
154
+
155
+ - ❌ [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-variables#rename);
156
+
146
157
  - ❌ [`remove-skip`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-skip);
158
+
147
159
  - ❌ [`remove-only`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-only);
160
+
148
161
  - ❌ [`remove-console`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-console#readme);
162
+
149
163
  - ❌ [`remove-debugger`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-debugger#readme);
164
+
150
165
  - ❌ [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreachable-code#readme);
166
+
151
167
  - ❌ [`for-of/for`](https://github.com/coderaiser/putout/tree/v29.1.2/packages/plugin-convert-for-to-for-of#readme);
152
- - ❌ [`for-of/remove-useless`](https://github.com/coderaiser/putout/tree/v29.1.2/packages/plugin-remove-useless-for-of#readme);
153
- - ❌ [`for-of/remove-unused-variables`](https://github.com/coderaiser/putout/tree/29.1.2/packages/plugin-for-of#remove-unused-variables);
168
+
169
+ - ❌ [`for-of/remove-useless`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-for-of#remove-useless);
170
+
171
+ - ❌ [`for-of/remove-unused-variables`](https://github.com/coderaiser/putout/tree/29.7.1/packages/plugin-for-of#remove-unused-variables);
172
+
154
173
  - ❌ [`maybe/noop`](https://github.com/coderaiser/putout/tree/29.2.4/packages/plugin-maybe#noop);
155
174
 
156
175
  ### safe+align
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {isImportDeclaration} = require('putout').types;
4
+ const {parseImportSpecifiers} = require('parse-import-specifiers');
4
5
  const {
5
6
  isCorrectLoc,
6
7
  isCorrectImportLoc,
@@ -9,8 +10,15 @@ const {
9
10
  module.exports.category = 'destructuring';
10
11
  module.exports.report = () => 'Keep each property on separate lines when using multiple destructuring properties';
11
12
 
12
- module.exports.include = ({options}) => {
13
+ const parseOptions = (options) => {
13
14
  const {minProperties = 2} = options[0] || {};
15
+ return {
16
+ minProperties,
17
+ };
18
+ };
19
+
20
+ module.exports.include = ({options}) => {
21
+ const {minProperties} = parseOptions(options);
14
22
 
15
23
  return [
16
24
  `VariableDeclarator[id.type="ObjectPattern"][id.properties.length>${minProperties}]`,
@@ -18,16 +26,23 @@ module.exports.include = ({options}) => {
18
26
  ];
19
27
  };
20
28
 
21
- module.exports.filter = ({node}) => {
29
+ module.exports.filter = ({node}, options) => {
30
+ const {minProperties} = parseOptions(options);
31
+ const {line} = node.loc.start;
22
32
  const {
23
33
  id,
24
34
  specifiers,
25
35
  parent,
26
36
  } = node;
27
- const {line} = node.loc.start;
28
37
 
29
- if (isImportDeclaration(node))
38
+ if (isImportDeclaration(node)) {
39
+ const {defaults, imports} = parseImportSpecifiers(node.specifiers);
40
+
41
+ if (defaults.length === 1 && imports.length < minProperties)
42
+ return false;
43
+
30
44
  return !isCorrectImportLoc(line, specifiers);
45
+ }
31
46
 
32
47
  if (parent.parent && parent.parent.type === 'ForOfStatement')
33
48
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "17.6.0",
3
+ "version": "17.7.0",
4
4
  "type": "commonjs",
5
5
  "description": "ESLint plugin for 🐊Putout",
6
6
  "release": false,
@@ -49,8 +49,9 @@
49
49
  "@typescript-eslint/eslint-plugin": "^5.5.0",
50
50
  "@typescript-eslint/parser": "^5.4.0",
51
51
  "align-spaces": "^1.0.0",
52
- "eslint-plugin-n": "^15.2.4",
52
+ "eslint-plugin-n": "^16.0.0",
53
53
  "eslint-plugin-react": "^7.32.2",
54
+ "parse-import-specifiers": "^1.0.1",
54
55
  "try-catch": "^3.0.0",
55
56
  "typescript": "^5.0.4"
56
57
  },