eslint-plugin-putout 19.3.0 β†’ 19.5.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,43 +133,24 @@ 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
-
137
136
  - ❌ [`remove-empty`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme);
138
-
139
137
  - ❌ [`nodejs/remove-process-exit`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-nodejs#remove-process-exit#readme);
140
-
141
138
  - ❌ [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-variables#readme);
142
-
143
139
  - ❌ [`typescript/remove-unused-types`](https://github.com/coderaiser/putout/tree/v24.0.2/packages/plugin-typescript#remove-unused-types#readme);
144
-
145
140
  - ❌ [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-expressions#readme);
146
-
147
141
  - ❌ [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreferenced-variables#readme);
148
-
149
142
  - ❌ [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#readme);
150
-
151
143
  - ❌ [`remove-useless-return`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-return#readme);
152
-
153
144
  - ❌ [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-spread/#readme);
154
-
155
145
  - ❌ [`remove-useless-variables/rename`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-variables#rename);
156
-
157
146
  - ❌ [`remove-skip`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-skip);
158
-
159
147
  - ❌ [`remove-only`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-tape#remove-only);
160
-
161
148
  - ❌ [`remove-console`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-console#readme);
162
-
163
149
  - ❌ [`remove-debugger`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-debugger#readme);
164
-
165
150
  - ❌ [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreachable-code#readme);
166
-
167
151
  - ❌ [`for-of/for`](https://github.com/coderaiser/putout/tree/v29.1.2/packages/plugin-convert-for-to-for-of#readme);
168
-
169
152
  - ❌ [`for-of/remove-useless`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-for-of#remove-useless);
170
-
171
153
  - ❌ [`for-of/remove-unused-variables`](https://github.com/coderaiser/putout/tree/29.7.1/packages/plugin-for-of#remove-unused-variables);
172
-
173
154
  - ❌ [`maybe/noop`](https://github.com/coderaiser/putout/tree/29.2.4/packages/plugin-maybe#noop);
174
155
 
175
156
  ### safe+align
@@ -191,6 +172,21 @@ When you need to support `jsx` in files using `js` extension, use:
191
172
  }
192
173
  ```
193
174
 
175
+ ### esm
176
+
177
+ If you want to use **ESM** plugins of 🐊**Putout** you need to use `esm` preset:
178
+
179
+ ```json
180
+ {
181
+ "extends": [
182
+ "plugin:putout/esm"
183
+ ],
184
+ "plugins": [
185
+ "putout"
186
+ ]
187
+ }
188
+ ```
189
+
194
190
  ## Flat
195
191
 
196
192
  The time is came for a [FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/). To use it with `eslint-plugin-putout` add to `eslint.config.js`:
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const process = require('process');
3
4
  const tryCatch = require('try-catch');
4
5
 
5
6
  const {accessSync} = require('fs');
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const process = require('process');
3
4
  const tryCatch = require('try-catch');
4
5
  const {createSyncFn} = require('synckit');
5
6
 
@@ -1,8 +1,12 @@
1
1
  'use strict';
2
2
 
3
- module.exports.parseError = ({message}) => {
3
+ module.exports.parseError = ({code, message, name}) => {
4
4
  if (message.includes('buildError'))
5
5
  return 'Parser error';
6
6
 
7
+ if (code === 'ERR_REQUIRE_ESM') {
8
+ return `☝️ Looks like '${name}' is ESM, extend from 'plugin:putout/esm'`;
9
+ }
10
+
7
11
  return message;
8
12
  };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const process = require('process');
3
4
  const tryCatch = require('try-catch');
4
5
 
5
6
  const {
@@ -25,10 +25,10 @@ module.exports = {
25
25
  create(context) {
26
26
  return {
27
27
  ImportDeclaration(node) {
28
- const source = context.sourceCode;
29
- const text = source.getText(node);
28
+ const {sourceCode} = context;
29
+ const text = sourceCode.getText(node);
30
30
 
31
- const newline = source
31
+ const newline = sourceCode
32
32
  .getText(node, 0, 2)
33
33
  .replace(text, '');
34
34
 
@@ -38,7 +38,7 @@ module.exports = {
38
38
  if (newline !== '\n\n')
39
39
  return;
40
40
 
41
- const nextNode = context.getNodeByRangeIndex(node.range[1] + 2);
41
+ const nextNode = sourceCode.getNodeByRangeIndex(node.range[1] + 2);
42
42
 
43
43
  if (!nextNode || nextNode.type !== 'ImportDeclaration')
44
44
  return;
@@ -16,17 +16,17 @@ module.exports = {
16
16
  create(context) {
17
17
  return {
18
18
  VariableDeclaration(node) {
19
- const source = context.sourceCode;
20
- const text = source.getText(node);
19
+ const {sourceCode} = context;
20
+ const text = sourceCode.getText(node);
21
21
 
22
- const newline = source
22
+ const newline = sourceCode
23
23
  .getText(node, 0, 2)
24
24
  .replace(text, '');
25
25
 
26
26
  if (newline !== '\n\n')
27
27
  return;
28
28
 
29
- const nextNode = context.getNodeByRangeIndex(node.range[1] + 2);
29
+ const nextNode = sourceCode.getNodeByRangeIndex(node.range[1] + 2);
30
30
 
31
31
  if (!nextNode || nextNode.type !== 'VariableDeclaration')
32
32
  return;
@@ -39,10 +39,10 @@ module.exports = {
39
39
  if (nodeId.properties.length !== 1)
40
40
  return;
41
41
 
42
- const textId = source.getText(nodeId.properties[0].value);
42
+ const textId = sourceCode.getText(nodeId.properties[0].value);
43
43
 
44
44
  const nextNodeInit = nextNode.declarations[0].init;
45
- const nextTextInit = source.getText(nextNodeInit);
45
+ const nextTextInit = sourceCode.getText(nextNodeInit);
46
46
 
47
47
  if (textId !== nextTextInit)
48
48
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "19.3.0",
3
+ "version": "19.5.0",
4
4
  "type": "commonjs",
5
5
  "description": "ESLint plugin for 🐊Putout",
6
6
  "release": false,