@putout/engine-runner 13.3.1 → 13.6.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 +9 -9
- package/lib/index.js +2 -0
- package/lib/replace/index.js +1 -1
- package/lib/replace/watermark.js +1 -1
- package/lib/store.js +6 -6
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -211,8 +211,8 @@ const {parse} = require('@putout/engin-parser');
|
|
|
211
211
|
|
|
212
212
|
const plugins = [{
|
|
213
213
|
rule: 'remove-debugger',
|
|
214
|
-
msg: '',
|
|
215
|
-
options: {},
|
|
214
|
+
msg: '', // optional
|
|
215
|
+
options: {}, // optional
|
|
216
216
|
plugin: {
|
|
217
217
|
include: () => ['debugger'],
|
|
218
218
|
fix: (path) => path.remove(),
|
|
@@ -223,11 +223,11 @@ const plugins = [{
|
|
|
223
223
|
const ast = parse('const m = "hi"; debugger');
|
|
224
224
|
const places = runPlugins({
|
|
225
225
|
ast,
|
|
226
|
-
shebang: false,
|
|
227
|
-
fix: true,
|
|
228
|
-
fixCount: 1,
|
|
226
|
+
shebang: false, // default
|
|
227
|
+
fix: true, // default
|
|
228
|
+
fixCount: 1, // default
|
|
229
229
|
plugins,
|
|
230
|
-
parser: 'babel',
|
|
230
|
+
parser: 'babel', // default
|
|
231
231
|
});
|
|
232
232
|
```
|
|
233
233
|
|
|
@@ -245,7 +245,7 @@ Let's talk about each of them.
|
|
|
245
245
|
|
|
246
246
|
### `listStore`
|
|
247
247
|
|
|
248
|
-
To save things as a list use `listStore`.
|
|
248
|
+
To save things as a list without duplicates use `listStore`.
|
|
249
249
|
Let's suppose you have such code:
|
|
250
250
|
|
|
251
251
|
```js
|
|
@@ -260,14 +260,14 @@ Let's process it!
|
|
|
260
260
|
```js
|
|
261
261
|
module.exports.traverse = ({listStore}) => ({
|
|
262
262
|
'debugger'(path) {
|
|
263
|
-
listStore(
|
|
263
|
+
listStore(path);
|
|
264
264
|
},
|
|
265
265
|
|
|
266
266
|
Program: {
|
|
267
267
|
exit() {
|
|
268
268
|
console.log(listStore());
|
|
269
269
|
// returns
|
|
270
|
-
['
|
|
270
|
+
[{type: 'DebuggerStatement'}, {type: 'DebuggerStatement'}];
|
|
271
271
|
// for code
|
|
272
272
|
'debugger; debugger';
|
|
273
273
|
},
|
package/lib/index.js
CHANGED
|
@@ -65,8 +65,10 @@ function runWithMerge({ast, fix, shebang, template, pluginsTraverse, merge}) {
|
|
|
65
65
|
traverse(ast, visitor);
|
|
66
66
|
|
|
67
67
|
const places = [];
|
|
68
|
+
|
|
68
69
|
for (const [rule, pull] of entries) {
|
|
69
70
|
const items = pull();
|
|
71
|
+
|
|
70
72
|
for (const {message, position} of items) {
|
|
71
73
|
places.push({
|
|
72
74
|
rule,
|
package/lib/replace/index.js
CHANGED
package/lib/replace/watermark.js
CHANGED
package/lib/store.js
CHANGED
|
@@ -8,21 +8,21 @@ const {
|
|
|
8
8
|
|
|
9
9
|
const toArray = (a) => Array.from(a);
|
|
10
10
|
|
|
11
|
-
module.exports.listStore = (list =
|
|
11
|
+
module.exports.listStore = (list = new Set()) => {
|
|
12
12
|
const fn = (...args) => {
|
|
13
13
|
if (!args.length)
|
|
14
|
-
return list;
|
|
14
|
+
return Array.from(list);
|
|
15
15
|
|
|
16
16
|
const [a] = args;
|
|
17
|
-
list.
|
|
17
|
+
list.add(a);
|
|
18
18
|
|
|
19
|
-
return list;
|
|
19
|
+
return Array.from(list);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
fn.clear = () => {
|
|
23
23
|
const a = list;
|
|
24
|
-
list =
|
|
25
|
-
return a;
|
|
24
|
+
list = new Set();
|
|
25
|
+
return Array.from(a);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return fn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-runner",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.6.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "run putout plugins",
|
|
@@ -42,11 +42,10 @@
|
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@babel/plugin-codemod-optional-catch-binding": "^7.7.4",
|
|
45
|
-
"@cloudcmd/stub": "^3.0.0",
|
|
46
45
|
"c8": "^7.5.0",
|
|
47
46
|
"eslint": "^8.0.1",
|
|
48
47
|
"eslint-plugin-node": "^11.0.0",
|
|
49
|
-
"eslint-plugin-putout": "^
|
|
48
|
+
"eslint-plugin-putout": "^15.0.0",
|
|
50
49
|
"just-camel-case": "^4.0.2",
|
|
51
50
|
"lerna": "^4.0.0",
|
|
52
51
|
"madrun": "^9.0.0",
|