putout 22.5.4 → 22.6.2

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/ChangeLog CHANGED
@@ -1,3 +1,50 @@
1
+ 2021.12.09, v22.6.2
2
+
3
+ fix:
4
+ - (eslint-plugin-putout) putout: traverse: use faster version
5
+
6
+ feature:
7
+ - (package) @putout/plugin-remove-useless-return v4.0.0
8
+ - (eslint-plugin-putout) safe: disable no-useless-return
9
+ - (@putout/plugin-remove-useless-return) report: Useless "return" should be avoided -> Avoid useless "return"
10
+ - (@putout/eslint-config) add space-in-parens
11
+ - (eslint-plugin-putout) putout: simplify according to https://github.com/eslint/eslint/issues/15394#issuecomment-989410995
12
+ - (package) @babel/traverse v7.16.3
13
+
14
+
15
+ 2021.12.08, v22.6.1
16
+
17
+ fix:
18
+ - (putout) transform: runPlugins: rm useless parser
19
+
20
+ feature:
21
+ - (@putout/plugin-declare-undefined-variables) wrap: add returns
22
+ - (eslint-plugin-putout) putout: add ability to remove parent, it makes recast go crazy (https://github.com/eslint/eslint/blob/v8.4.0/lib/linter/linter.js#L964)
23
+ - (eslint-plugin-putout) putout: use generate, when recast cannot print
24
+
25
+
26
+ 2021.12.07, v22.6.0
27
+
28
+ feature:
29
+ - (putout) add exit code: CANNOT_LOAD_FORMATTER
30
+ - (package) @putout/formatter-json-lines v2.0.0
31
+ - (@putout/formatter-json-lines) convert to ESM (#91)
32
+ - (package) @putout/formatter-stream v3.0.0
33
+ - (package) @putout/formatter-json v2.0.0
34
+ - (package) @putout/formatter-json v2.0.0
35
+ - (package) @putout/formatter-json v2.0.0
36
+ - (package) @putout/formatter-json v2.0.0
37
+ - (@putout/formatter-json) convert to ESM (#91)
38
+ - (@putout/formatter-stream) convert to ESM (#91)
39
+
40
+
41
+ 2021.12.07, v22.5.5
42
+
43
+ feature:
44
+ - (package) @putout/formatter-frame v2.0.0
45
+ - (@putout/formatter-frame) convert to ESM (#91)
46
+
47
+
1
48
  2021.12.07, v22.5.4
2
49
 
3
50
  fix:
@@ -14,5 +14,6 @@ module.exports = {
14
14
  RULLER_WITH_FIX: 10,
15
15
  RULLER_NO_FILES: 11,
16
16
  INVALID_CONFIG: 12,
17
+ CANNOT_LOAD_FORMATTER: 13,
17
18
  };
18
19
 
@@ -11,3 +11,4 @@ export const UNHANDLED = 9;
11
11
  export const RULLER_WITH_FIX = 10;
12
12
  export const RULLER_NO_FILES = 11;
13
13
  export const INVALID_CONFIG = 12;
14
+ export const CANNOT_LOAD_FORMATTER = 13;
@@ -3,12 +3,16 @@
3
3
  const {createSimport} = require('simport');
4
4
  const tryToCatch = require('try-to-catch');
5
5
 
6
- const {NO_FORMATTER} = require('./exit-codes');
6
+ const {
7
+ NO_FORMATTER,
8
+ CANNOT_LOAD_FORMATTER,
9
+ } = require('./exit-codes');
7
10
 
8
11
  const simport = createSimport(__filename);
9
12
  const stub = () => () => {};
10
13
 
11
14
  const {isArray} = Array;
15
+ const {assign} = Object;
12
16
  const maybeArray = (a) => isArray(a) ? a : [a, {}];
13
17
 
14
18
  module.exports.getFormatter = async (formatter, exit) => {
@@ -22,23 +26,46 @@ module.exports.getFormatter = async (formatter, exit) => {
22
26
 
23
27
  module.exports.getReporter = getReporter;
24
28
  async function getReporter(name, exit) {
25
- let e;
26
- let reporter;
27
-
28
- if (name === 'none') {
29
+ if (name === 'none')
29
30
  return stub();
30
- }
31
31
 
32
- [e, reporter] = await tryToCatch(simport, `@putout/formatter-${name}`);
32
+ const [error, reporter] = await loadFormatter([
33
+ `@putout/formatter-${name}`,
34
+ `putout-formatter-${name}`,
35
+ ]);
33
36
 
34
- if (!e)
37
+ if (reporter)
35
38
  return reporter;
36
39
 
37
- [e, reporter] = await tryToCatch(simport, `putout-formatter-${name}`);
40
+ if (error.code === 'ERR_MODULE_NOT_FOUND')
41
+ return exit(NO_FORMATTER, error);
38
42
 
39
- if (!e)
40
- return reporter;
41
-
42
- exit(NO_FORMATTER, e);
43
+ exit(CANNOT_LOAD_FORMATTER, error);
43
44
  }
44
45
 
46
+ async function loadFormatter(names) {
47
+ let e;
48
+ let reporter;
49
+
50
+ for (const name of names) {
51
+ [e, reporter] = await tryToCatch(simport, name);
52
+
53
+ if (!e)
54
+ return [null, reporter];
55
+
56
+ if (e.code === 'ERR_MODULE_NOT_FOUND')
57
+ continue;
58
+
59
+ assign(e, {
60
+ message: `${name}: ${e.message}`,
61
+ });
62
+
63
+ return [e];
64
+ }
65
+
66
+ assign(e, {
67
+ message: e.message.replace(/\simported.*/, ''),
68
+ });
69
+
70
+ return [e];
71
+ }
package/lib/putout.js CHANGED
@@ -84,7 +84,6 @@ function transform(ast, source, opts) {
84
84
  rules,
85
85
  fix,
86
86
  fixCount,
87
- parser,
88
87
  loadPlugins,
89
88
  runPlugins,
90
89
  } = opts;
@@ -102,7 +101,6 @@ function transform(ast, source, opts) {
102
101
  fix,
103
102
  fixCount,
104
103
  plugins,
105
- parser,
106
104
  });
107
105
 
108
106
  return places;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "22.5.4",
3
+ "version": "22.6.2",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "🐊 Pluggable and configurable code transformer with built-in eslint, babel plugins and jscodeshift codemods support of js, jsx typescript, flow files, markdown, yaml and json",
6
6
  "homepage": "http://github.com/coderaiser/putout",
@@ -57,13 +57,13 @@
57
57
  "@putout/engine-runner": "^11.0.0",
58
58
  "@putout/formatter-codeframe": "^3.0.0",
59
59
  "@putout/formatter-dump": "^3.0.0",
60
- "@putout/formatter-frame": "^1.0.0",
61
- "@putout/formatter-json": "^1.0.0",
62
- "@putout/formatter-json-lines": "^1.0.0",
60
+ "@putout/formatter-frame": "^2.0.0",
61
+ "@putout/formatter-json": "^2.0.0",
62
+ "@putout/formatter-json-lines": "^2.0.0",
63
63
  "@putout/formatter-memory": "^2.0.0",
64
64
  "@putout/formatter-progress": "^3.0.0",
65
65
  "@putout/formatter-progress-bar": "^2.0.0",
66
- "@putout/formatter-stream": "^2.0.0",
66
+ "@putout/formatter-stream": "^3.0.0",
67
67
  "@putout/operate": "^6.0.0",
68
68
  "@putout/operator-add-args": "^1.0.0",
69
69
  "@putout/operator-declare": "^2.0.0",
@@ -154,7 +154,7 @@
154
154
  "@putout/plugin-remove-useless-mapping-modifiers": "^1.0.0",
155
155
  "@putout/plugin-remove-useless-new": "^1.0.0",
156
156
  "@putout/plugin-remove-useless-operand": "^1.0.0",
157
- "@putout/plugin-remove-useless-return": "^3.0.0",
157
+ "@putout/plugin-remove-useless-return": "^4.0.0",
158
158
  "@putout/plugin-remove-useless-spread": "^5.0.0",
159
159
  "@putout/plugin-remove-useless-template-expressions": "^1.0.0",
160
160
  "@putout/plugin-remove-useless-type-conversion": "^1.0.0",