@putout/engine-runner 13.4.0 → 13.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
@@ -211,8 +211,8 @@ const {parse} = require('@putout/engin-parser');
211
211
 
212
212
  const plugins = [{
213
213
  rule: 'remove-debugger',
214
- msg: '', // optional
215
- options: {}, // optional
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, // default
227
- fix: true, // default
228
- fixCount: 1, // default
226
+ shebang: false, // default
227
+ fix: true, // default
228
+ fixCount: 1, // default
229
229
  plugins,
230
- parser: 'babel', // default
230
+ parser: 'babel', // default
231
231
  });
232
232
  ```
233
233
 
@@ -117,6 +117,7 @@ function getStore(plugin, {fix, rule, shebang, msg, options}) {
117
117
  list.clear();
118
118
  upstore.clear();
119
119
  uplist.clear();
120
+
120
121
  return placesStore.clear();
121
122
  };
122
123
 
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const isString = (a) => typeof a === 'string';
4
-
5
3
  const {template} = require('@putout/engine-parser');
4
+
6
5
  const {
7
6
  remove,
8
7
  replaceWith,
@@ -14,9 +13,10 @@ const {
14
13
  setValues,
15
14
  } = require('@putout/compare');
16
15
  const debug = require('debug')('putout:runner:replace');
17
-
18
16
  const maybeArray = require('../maybe-array');
17
+
19
18
  const watermark = require('./watermark');
19
+ const isString = (a) => typeof a === 'string';
20
20
 
21
21
  const log = (from, path) => {
22
22
  debug.enabled && debug(`${from} -> ${path}\n`);
@@ -76,7 +76,7 @@ const fix = (from, to, path) => {
76
76
  if (mark.has())
77
77
  return;
78
78
 
79
- if (!compare(path, nodeFrom))
79
+ if (!compare(path, nodeFrom, {findUp: false}))
80
80
  return;
81
81
 
82
82
  const waysFrom = findVarsWays(nodeFrom);
@@ -14,7 +14,7 @@ module.exports = (from, to, path) => {
14
14
  highWatermark,
15
15
  } = create(from, to, path);
16
16
 
17
- const program = path.findParent(isProgram);
17
+ const program = path.findParent(isProgram) || path;
18
18
 
19
19
  const options = {
20
20
  watermark,
package/lib/run-fix.js CHANGED
@@ -4,7 +4,9 @@ const tryCatch = require('try-catch');
4
4
  const debug = require('debug')('putout:runner:fix');
5
5
  const {enabled} = debug;
6
6
  const {stringify} = JSON;
7
+
7
8
  const isFn = (a) => typeof a === 'function';
9
+ const getPath = (path) => path.path || path;
8
10
 
9
11
  const tryToFix = (fix, {path, position, options}) => {
10
12
  const [e] = tryCatch(fix, path, {options});
@@ -26,7 +28,9 @@ module.exports = (is, fix, {path, rule, position, options}) => {
26
28
  if (!is)
27
29
  return;
28
30
 
29
- enabled && debug(`fix: ${rule}`, position, path.toString());
31
+ if (enabled)
32
+ debug(`fix: ${rule}`, position, getPath(path).toString());
33
+
30
34
  validate('fix', fix);
31
35
 
32
36
  tryToFix(fix, {
package/lib/store.js CHANGED
@@ -22,6 +22,7 @@ module.exports.listStore = (list = new Set()) => {
22
22
  fn.clear = () => {
23
23
  const a = list;
24
24
  list = new Set();
25
+
25
26
  return Array.from(a);
26
27
  };
27
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-runner",
3
- "version": "13.4.0",
3
+ "version": "13.7.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "run putout plugins",
@@ -42,13 +42,12 @@
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": "^14.0.0",
48
+ "eslint-plugin-putout": "^15.0.0",
50
49
  "just-camel-case": "^4.0.2",
51
- "lerna": "^4.0.0",
50
+ "lerna": "^5.0.0",
52
51
  "madrun": "^9.0.0",
53
52
  "mock-require": "^3.0.3",
54
53
  "montag": "^1.0.0",