putout 22.5.5 → 22.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/ChangeLog CHANGED
@@ -1,3 +1,67 @@
1
+ 2021.12.12, v22.7.0
2
+
3
+ feature:
4
+ - (package) @putout/plugin-convert-comparison-to-boolean v2.0.0
5
+ - (@putout/operate) compute: add support of evaluate
6
+ - (@putout/plugin-convert-comparison-to-boolean) improve support of member expressions
7
+ - (@putout/plugin-convert-comparison-to-boolean) drop support of putout < 22
8
+ - (@putout/plugin-putout) check-replace-code: simplify
9
+ - (@putout/operate) compute: add support of Literal
10
+ - (@putout/plugin-putout) check-replace-code: use compute from operate
11
+ - (@putout/operate) add compute
12
+ - (@putout/plugin-putout) check-replace-code: add support of MemberExpression in computed property
13
+ - (@putout/plugin-convert-typeof-to-is-type) use getBindingPath from operate
14
+ - (@putout/operate) add getBinding, getBindingPath
15
+ - (@putout/operate) add getBinding
16
+ - (@putout/engine-runner) replace: validation output: ["__b"] ["__a"] -> ["__a"] -> ["__b"]
17
+ - (@putout/plugin-putout) add move-require-on-top-level
18
+ - (@putout/test) add support of createTest
19
+ - (@putout/engine-loader) is-enabled: use isBool
20
+ - (@putout/plugin-convert-typeof-to-is-type) improve binding search
21
+ - (@putout/plugin-putout) check-replace-code: exclude computed keys
22
+ - (@putout/plugin-convert-typeof-to-is-type) add support of isSymbol
23
+ - (@putout/plugin-declare-undefined-variables) add support of isSymbol
24
+
25
+ 2021.12.09, v22.6.2
26
+
27
+ fix:
28
+ - (eslint-plugin-putout) putout: traverse: use faster version
29
+
30
+ feature:
31
+ - (package) @putout/plugin-remove-useless-return v4.0.0
32
+ - (eslint-plugin-putout) safe: disable no-useless-return
33
+ - (@putout/plugin-remove-useless-return) report: Useless "return" should be avoided -> Avoid useless "return"
34
+ - (@putout/eslint-config) add space-in-parens
35
+ - (eslint-plugin-putout) putout: simplify according to https://github.com/eslint/eslint/issues/15394#issuecomment-989410995
36
+ - (package) @babel/traverse v7.16.3
37
+
38
+
39
+ 2021.12.08, v22.6.1
40
+
41
+ fix:
42
+ - (putout) transform: runPlugins: rm useless parser
43
+
44
+ feature:
45
+ - (@putout/plugin-declare-undefined-variables) wrap: add returns
46
+ - (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)
47
+ - (eslint-plugin-putout) putout: use generate, when recast cannot print
48
+
49
+
50
+ 2021.12.07, v22.6.0
51
+
52
+ feature:
53
+ - (putout) add exit code: CANNOT_LOAD_FORMATTER
54
+ - (package) @putout/formatter-json-lines v2.0.0
55
+ - (@putout/formatter-json-lines) convert to ESM (#91)
56
+ - (package) @putout/formatter-stream v3.0.0
57
+ - (package) @putout/formatter-json v2.0.0
58
+ - (package) @putout/formatter-json v2.0.0
59
+ - (package) @putout/formatter-json v2.0.0
60
+ - (package) @putout/formatter-json v2.0.0
61
+ - (@putout/formatter-json) convert to ESM (#91)
62
+ - (@putout/formatter-stream) convert to ESM (#91)
63
+
64
+
1
65
  2021.12.07, v22.5.5
2
66
 
3
67
  feature:
@@ -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.5",
3
+ "version": "22.7.0",
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",
@@ -58,12 +58,12 @@
58
58
  "@putout/formatter-codeframe": "^3.0.0",
59
59
  "@putout/formatter-dump": "^3.0.0",
60
60
  "@putout/formatter-frame": "^2.0.0",
61
- "@putout/formatter-json": "^1.0.0",
62
- "@putout/formatter-json-lines": "^1.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",
@@ -84,7 +84,7 @@
84
84
  "@putout/plugin-convert-assignment-to-comparison": "^1.0.0",
85
85
  "@putout/plugin-convert-bitwise-to-logical": "^1.0.0",
86
86
  "@putout/plugin-convert-commonjs-to-esm": "^6.0.0",
87
- "@putout/plugin-convert-comparison-to-boolean": "^1.0.0",
87
+ "@putout/plugin-convert-comparison-to-boolean": "^2.0.0",
88
88
  "@putout/plugin-convert-concat-to-flat": "^1.0.0",
89
89
  "@putout/plugin-convert-equal-to-strict-equal": "^1.0.0",
90
90
  "@putout/plugin-convert-esm-to-commonjs": "^3.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",