eslint-plugin-putout 19.2.0 β†’ 19.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
@@ -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');
@@ -0,0 +1,13 @@
1
+ import {findPlacesAsync} from 'putout';
2
+ import tryToCatch from 'try-to-catch';
3
+ import {runAsWorker} from 'synckit';
4
+ import parseOptions from 'putout/parse-options';
5
+
6
+ runAsWorker(async ({name, options, ast, text}) => {
7
+ const resultOptions = parseOptions({
8
+ name,
9
+ options,
10
+ });
11
+
12
+ return await tryToCatch(findPlacesAsync, ast, text, resultOptions);
13
+ });
@@ -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
 
@@ -14,8 +15,8 @@ const {parseError} = require('../parse-error');
14
15
 
15
16
  const cwd = process.cwd();
16
17
 
17
- const findPlacesSync = createSyncFn(require.resolve('./find-places'));
18
- const transformSync = createSyncFn(require.resolve('./transform'));
18
+ const findPlacesSync = createSyncFn(require.resolve('./find-places.mjs'));
19
+ const transformSync = createSyncFn(require.resolve('./transform.mjs'));
19
20
 
20
21
  const EMPTY_VISITORS = {};
21
22
 
@@ -0,0 +1,14 @@
1
+ import {transformAsync} from 'putout';
2
+ import {runAsWorker} from 'synckit';
3
+ import parseOptions from 'putout/parse-options';
4
+
5
+ runAsWorker(async ({name, options, ast, text}) => {
6
+ const resultOptions = parseOptions({
7
+ name,
8
+ options,
9
+ });
10
+
11
+ await transformAsync(ast, text, resultOptions);
12
+
13
+ return ast;
14
+ });
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "19.2.0",
3
+ "version": "19.4.0",
4
4
  "type": "commonjs",
5
5
  "description": "ESLint plugin for 🐊Putout",
6
6
  "release": false,
@@ -52,6 +52,7 @@
52
52
  "parse-import-specifiers": "^1.0.1",
53
53
  "synckit": "^0.8.5",
54
54
  "try-catch": "^3.0.0",
55
+ "try-to-catch": "^3.0.1",
55
56
  "typescript": "^5.0.4"
56
57
  },
57
58
  "devDependencies": {
@@ -65,8 +66,7 @@
65
66
  "mocha": "^10.0.0",
66
67
  "montag": "^1.0.0",
67
68
  "simport": "^1.2.0",
68
- "supertape": "^8.0.0",
69
- "try-to-catch": "^3.0.0"
69
+ "supertape": "^8.0.0"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">=16"
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const {findPlaces} = require('putout');
4
-
5
- const tryCatch = require('try-catch');
6
- const {runAsWorker} = require('synckit');
7
- const parseOptions = require('putout/parse-options');
8
-
9
- runAsWorker(({name, options, ast, text}) => {
10
- const resultOptions = parseOptions({
11
- name,
12
- options,
13
- });
14
-
15
- return tryCatch(findPlaces, ast, text, resultOptions);
16
- });
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- const {transform, print} = require('putout');
4
-
5
- const {runAsWorker} = require('synckit');
6
- const parseOptions = require('putout/parse-options');
7
-
8
- runAsWorker(({name, options, ast}) => {
9
- const resultOptions = parseOptions({
10
- name,
11
- options,
12
- });
13
-
14
- /*
15
- const places = transform(ast, text, {
16
- rules: updatedRules,
17
- plugins: parsePlugins(rules),
18
- });
19
- */
20
- /*
21
- const places = transform(ast, text, {
22
- rules: updatedRules,
23
- plugins: parsePlugins(rules),
24
- });
25
- */
26
- // if (!places.length)
27
- transform(ast, print(ast), resultOptions);
28
-
29
- return ast;
30
- });