putout 26.0.0 β 26.1.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 +86 -32
- package/README.md +2 -2
- package/help.json +1 -1
- package/lib/cli/formatter.js +8 -52
- package/lib/cli/index.js +4 -1
- package/lib/parse-options/validate-options/schema.json +1 -1
- package/package.json +5 -5
package/ChangeLog
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
2022.05.13, v26.1.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- (@putout/processor-css) rm once
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
feature:
|
|
8
|
+
- (package) @putout/engine-processor v6.0.0
|
|
9
|
+
- (package) @putout/engine-loader v7.0.0
|
|
10
|
+
- (package) @putout/engine-loader v7.0.0
|
|
11
|
+
- (@putout/engine-processor) getProcessorRunners: sync -> async
|
|
12
|
+
- (putout) getProcessors: sync -> async
|
|
13
|
+
- (@putout/engine-loader) loadProcessors -> loadProcessorsAsync
|
|
14
|
+
- (@putout/plugin-remove-useless-variables) exclude mirrored renames (used in tests)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
2022.05.12, v26.0.2
|
|
18
|
+
|
|
19
|
+
fix:
|
|
20
|
+
- (@putout/plugin-reuse-deuplicate-init) description
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
feature:
|
|
24
|
+
- (package) @putout/plugin-reuse-duplicate-init v4.0.0
|
|
25
|
+
- (@putout/plugin-reuse-duplicate-init) drop support of π < 26
|
|
26
|
+
- (@putout/plugin-reuse-duplicate-init) report message: simplify
|
|
27
|
+
- (@putout/plugin-remove-useless-variables) remove: add support of AssignmentExpression
|
|
28
|
+
- (@putout/operate) remove: improve comments support
|
|
29
|
+
- (@putout/plugin-remove-useless-variables) await: improve report message
|
|
30
|
+
- (@putout/plugin-putout) add: replace-test-message
|
|
31
|
+
- (@putout/plugin-apply-array-at) improve report
|
|
32
|
+
- (@putout/plugin-convert-reduce-to-for-of) exclude CallExpression
|
|
33
|
+
- (@putout/plugin-tape) convert-ok-to-match: test: add support of message
|
|
34
|
+
- (@putout/plugin-remove-useless-operand) check operand type when string could be used
|
|
35
|
+
- (@putout/plugin-madrun) convert-lint-lib: parseObject -> getProperty
|
|
36
|
+
- (@putout/plugin-madrun) convert-nyc-to-c8: add support of CommonJS
|
|
37
|
+
- (@putout/operator-add-args) exclude not calls
|
|
38
|
+
- (@putout/eslint-config) add array-bracket-spacing
|
|
39
|
+
- (@putout/plugin-putout) add-args: add support of process
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
2022.05.09, v26.0.1
|
|
43
|
+
|
|
44
|
+
fix:
|
|
45
|
+
- (@putout/plugin-convert-commonjs-to-esm) report
|
|
46
|
+
- (putout) help: localy -> locally
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
feature:
|
|
50
|
+
- (package) @putout/plugin-convert-esm-to-commonjs v5.0.0
|
|
51
|
+
- (@putout/plugin-convert-esm-to-commonjs) drop support of π < 26
|
|
52
|
+
- (@putout/plugin-convert-esm-to-commonjs) change report
|
|
53
|
+
|
|
54
|
+
|
|
1
55
|
2022.05.08, v26.0.0
|
|
2
56
|
|
|
3
57
|
feature:
|
|
@@ -208,7 +262,7 @@ feature:
|
|
|
208
262
|
- (package) @putout/plugin-typescript v2.0.0
|
|
209
263
|
- (@putout/plugin-typescript) drop support of π < 16
|
|
210
264
|
- (@putout/plugin-typescript) remove-duplicates-from-union: avoid duplicates reporting
|
|
211
|
-
- (@putout/plugin-extract-object-properties) not-equal-deep: link to listStore() results -> call linkStore() when
|
|
265
|
+
- (@putout/plugin-extract-object-properties) not-equal-deep: link to listStore() results -> call linkStore() when needed
|
|
212
266
|
- (@putout/engine-runner) store: listStore: use Set() inside to prevent duplicates and return array
|
|
213
267
|
|
|
214
268
|
|
|
@@ -1253,7 +1307,7 @@ feature:
|
|
|
1253
1307
|
2021.11.28, v22.2.1
|
|
1254
1308
|
|
|
1255
1309
|
fix:
|
|
1256
|
-
- (@putout/plugin-remove-constant-conditions) report: "constant
|
|
1310
|
+
- (@putout/plugin-remove-constant-conditions) report: "constant conditions should not be used" -> "Avoid constant conditions"
|
|
1257
1311
|
|
|
1258
1312
|
feature:
|
|
1259
1313
|
- (package) @putout/plugin-madrun v11.0.0
|
|
@@ -1268,7 +1322,7 @@ feature:
|
|
|
1268
1322
|
fix:
|
|
1269
1323
|
- (@putout/plugin-remove-unused-variables) OptionalMemberExpression: computed property
|
|
1270
1324
|
- (eslint-plugin-putout) array-element-newline: minimum elements: 4 -> 5
|
|
1271
|
-
- (eslint-plugin-putout) add-newlinew-before-function-call:
|
|
1325
|
+
- (eslint-plugin-putout) add-newlinew-before-function-call: trimmed whitespaces on empty line
|
|
1272
1326
|
- (eslint-plugin-putout) add-newline-before-function-call: add support of comments
|
|
1273
1327
|
- (eslint-plugin-putout) add-newline-before-function-call: continue -> return
|
|
1274
1328
|
|
|
@@ -1283,7 +1337,7 @@ feature:
|
|
|
1283
1337
|
- (@putout/eslint-config) padding-line-between-statements: add support of while
|
|
1284
1338
|
- (eslint-plugin-putout) add add-newline-before-function-call
|
|
1285
1339
|
- (@putout/eslint-config) add func-call-spacing (https://eslint.org/docs/rules/func-call-spacing)
|
|
1286
|
-
- (eslint-plugin-putout) plugin-tape-remove-newline-before-t-end: add support of
|
|
1340
|
+
- (eslint-plugin-putout) plugin-tape-remove-newline-before-t-end: add support of trimmed newline
|
|
1287
1341
|
- (eslint-plugin-putout) add add-newline-before-t-end
|
|
1288
1342
|
- (@putout/plugin-declare-undefined-variables) add maybeEmptyArray
|
|
1289
1343
|
- (eslint-plugin-putout) array-element-newline: add support of Identifier
|
|
@@ -1714,7 +1768,7 @@ feature:
|
|
|
1714
1768
|
2021.09.25, v20.5.0
|
|
1715
1769
|
|
|
1716
1770
|
fix:
|
|
1717
|
-
- (@putout/test)
|
|
1771
|
+
- (@putout/test) leak of plugins used in `t.transform()`
|
|
1718
1772
|
- (@putout/plugin-tape) apply-with-name: not declared
|
|
1719
1773
|
- (@putout/plugin-declare-undefined-variables) get back record, to have eslint-plugin-putout support
|
|
1720
1774
|
|
|
@@ -1936,11 +1990,11 @@ fix:
|
|
|
1936
1990
|
2021.09.01, v19.3.0
|
|
1937
1991
|
|
|
1938
1992
|
fix:
|
|
1939
|
-
- feature(putout) exit with error when "--fix" used with "--enable(-all)" or "--
|
|
1993
|
+
- feature(putout) exit with error when "--fix" used with "--enable(-all)" or "--disable(-all)" (#77)
|
|
1940
1994
|
- (@putout/plugin-declare-undefined-variables) mockImport: multiple declarations
|
|
1941
1995
|
|
|
1942
1996
|
feature:
|
|
1943
|
-
- (putout) exit with error when "--fix" used with "--enable(-all)" or "--
|
|
1997
|
+
- (putout) exit with error when "--fix" used with "--enable(-all)" or "--disable(-all)" (#77)
|
|
1944
1998
|
- (@putout/plugin-regexp) remove-useless-group: allow only test, search match (#74)
|
|
1945
1999
|
- (@putout/plugin-apply-filter-boolean) add
|
|
1946
2000
|
- (eslint-plugin-putout) rm category (https://eslint.org/blog/2021/08/eslint-v8.0.0-beta.1-released)
|
|
@@ -2003,8 +2057,8 @@ feature:
|
|
|
2003
2057
|
2021.08.23, v19.0.0
|
|
2004
2058
|
|
|
2005
2059
|
fix:
|
|
2006
|
-
- (@putout/cli-validate-args) switch to
|
|
2007
|
-
- (@putout/plugin-regexp) convert-to-string: false
|
|
2060
|
+
- (@putout/cli-validate-args) switch to dynamic import
|
|
2061
|
+
- (@putout/plugin-regexp) convert-to-string: false positive with Char of kind meta: \d
|
|
2008
2062
|
- (@putout/eslint-config) peerDependency
|
|
2009
2063
|
- (eslint-plugin-putout) peerDependencies: eslint
|
|
2010
2064
|
|
|
@@ -2033,7 +2087,7 @@ feature:
|
|
|
2033
2087
|
fix:
|
|
2034
2088
|
- (@putout/compare) link: arrays
|
|
2035
2089
|
- (putout) parse-options: read rules with "putout-plugin" prefix
|
|
2036
|
-
- (eslint-plugin-putout) rm
|
|
2090
|
+
- (eslint-plugin-putout) rm additional esm handling
|
|
2037
2091
|
- (@putout/engine-runner) empty key
|
|
2038
2092
|
|
|
2039
2093
|
feature:
|
|
@@ -2178,7 +2232,7 @@ feature:
|
|
|
2178
2232
|
|
|
2179
2233
|
fix:
|
|
2180
2234
|
- (@putout/compare) exclude: range, parent (#67)
|
|
2181
|
-
- (@putout/plugin-regexp) remove-useless-group:
|
|
2235
|
+
- (@putout/plugin-regexp) remove-useless-group: exclude named capturing groups (#67)
|
|
2182
2236
|
|
|
2183
2237
|
feature:
|
|
2184
2238
|
- (ruler) exclude rules not related to putout
|
|
@@ -2726,7 +2780,7 @@ fix:
|
|
|
2726
2780
|
|
|
2727
2781
|
|
|
2728
2782
|
feature:
|
|
2729
|
-
- feature(@putout/plugin-remove-useless-await) add
|
|
2783
|
+
- feature(@putout/plugin-remove-useless-await) add support of not async functions
|
|
2730
2784
|
- feature(putout) bin: disable remove-empty/import, ESM: disable strict-mode/add
|
|
2731
2785
|
- feature(eslint-plugin-putout) single-property-destructuring: add support of ImportDeclaration
|
|
2732
2786
|
- feature(eslint-plugin-putout) ide: remove-empty/block -> remove-empty
|
|
@@ -2994,7 +3048,7 @@ feature:
|
|
|
2994
3048
|
2021.01.30, v14.0.3
|
|
2995
3049
|
|
|
2996
3050
|
fix:
|
|
2997
|
-
- (putout) prevent unhandled
|
|
3051
|
+
- (putout) prevent unhandled exceptions
|
|
2998
3052
|
- (@putout/processor-ignore) windows line endings
|
|
2999
3053
|
|
|
3000
3054
|
feature:
|
|
@@ -3014,7 +3068,7 @@ feature:
|
|
|
3014
3068
|
2021.01.27, v14.0.1
|
|
3015
3069
|
|
|
3016
3070
|
fix:
|
|
3017
|
-
- (putout) cache-files: rm useless logical operation: "" always
|
|
3071
|
+
- (putout) cache-files: rm useless logical operation: "" always positive after condition
|
|
3018
3072
|
|
|
3019
3073
|
feature:
|
|
3020
3074
|
- (package) eslint-plugin-putout v7.0.0
|
|
@@ -3147,7 +3201,7 @@ feature:
|
|
|
3147
3201
|
- (putout) cli: cache: add ability to detect eslintrc change
|
|
3148
3202
|
- (putout) cache-files: add ability to detect node_modules changes
|
|
3149
3203
|
- (@putout/plugin-tape) add convert-emitter-to-promise
|
|
3150
|
-
- (@putout/formatter-memory) add
|
|
3204
|
+
- (@putout/formatter-memory) add support of PUTOUT_PROGRESS_BAR
|
|
3151
3205
|
- (@putout/plugin-nodejs) add convert-promisify-to-fs-promises
|
|
3152
3206
|
|
|
3153
3207
|
|
|
@@ -3422,7 +3476,7 @@ feature:
|
|
|
3422
3476
|
2020.12.07, v12.0.1
|
|
3423
3477
|
|
|
3424
3478
|
fix:
|
|
3425
|
-
- (putout) parse-match: memory
|
|
3479
|
+
- (putout) parse-match: memory leak: 400mb -> 140mb: rm memo
|
|
3426
3480
|
|
|
3427
3481
|
feature:
|
|
3428
3482
|
- (@putout/plugin-convert-commonjs-to-esm) require: exclude declared require
|
|
@@ -4405,7 +4459,7 @@ fix:
|
|
|
4405
4459
|
- (@putout/engine-loader) load-plugin: rm useless Module.plugins (used for webpack bundle build)
|
|
4406
4460
|
|
|
4407
4461
|
feature:
|
|
4408
|
-
- (putout) add --debug flag to switch formatter into reason of a crash (when
|
|
4462
|
+
- (putout) add --debug flag to switch formatter into reason of a crash (when occurs)
|
|
4409
4463
|
- (@putout/eslint-cofig) .eslintrc.json -> eslintrc.json
|
|
4410
4464
|
|
|
4411
4465
|
|
|
@@ -5097,7 +5151,7 @@ feature:
|
|
|
5097
5151
|
|
|
5098
5152
|
feature:
|
|
5099
5153
|
- (putout) parse-options: readRules: plugins: object -> array
|
|
5100
|
-
- (@putout/codemod-convert-tape-to-supertape)
|
|
5154
|
+
- (@putout/codemod-convert-tape-to-supertape) convert to replace
|
|
5101
5155
|
- (@putout/codemod-cut-legacy) convert to include
|
|
5102
5156
|
- (@putout/engine-runner) filter: replace -> include
|
|
5103
5157
|
- (@putout/engine-runner) rm unused check
|
|
@@ -5166,7 +5220,7 @@ feature:
|
|
|
5166
5220
|
2020.01.17, v7.6.1
|
|
5167
5221
|
|
|
5168
5222
|
fix:
|
|
5169
|
-
- feature(@putout/eslint-config) disable no-empty-pattern: no
|
|
5223
|
+
- feature(@putout/eslint-config) disable no-empty-pattern: no
|
|
5170
5224
|
- (putout) parseOptions: custom optionsmore important then merged options, custom match more important then custom options
|
|
5171
5225
|
|
|
5172
5226
|
feature:
|
|
@@ -6386,13 +6440,13 @@ fix:
|
|
|
6386
6440
|
- (eslintrc) overrides does not supported by eslint
|
|
6387
6441
|
- (@putout/plugin-extract-sequence-epxressions) add support of WhileStatement
|
|
6388
6442
|
- (@putout/eslint-config) rm overrides: does not supported by eslint
|
|
6389
|
-
- (@putout/eslint-config) no-
|
|
6443
|
+
- (@putout/eslint-config) no-unneeded-ternary: default-assignment: defaultAssignment
|
|
6390
6444
|
|
|
6391
6445
|
feature:
|
|
6392
6446
|
- (putout) rm shebang check
|
|
6393
6447
|
- (putout) improve directives support
|
|
6394
6448
|
- (@putout/eslint-config) overrids "bin": disable rules: no-console, no-process-exit
|
|
6395
|
-
- (@putout/eslint-config) no-
|
|
6449
|
+
- (@putout/eslint-config) no-unneeded-ternary: default-assignment: false
|
|
6396
6450
|
|
|
6397
6451
|
|
|
6398
6452
|
2019.07.24, v4.60.0
|
|
@@ -6651,7 +6705,7 @@ fix:
|
|
|
6651
6705
|
- (@putout/plugin-convert-apply-to-spread) rm quotes
|
|
6652
6706
|
|
|
6653
6707
|
feature:
|
|
6654
|
-
- (putout) add ability to handle
|
|
6708
|
+
- (putout) add ability to handle overlapped plugins: missing node
|
|
6655
6709
|
- (@putout/plugin-remove-unused-variables) add support of named FunctionExpression in ReturnStatement
|
|
6656
6710
|
- (package) eslint-plugin-node v9.1.0
|
|
6657
6711
|
- (package) eslint v6.0.1
|
|
@@ -6681,7 +6735,7 @@ fix:
|
|
|
6681
6735
|
feature:
|
|
6682
6736
|
- (putout) enable typescript only for .ts files
|
|
6683
6737
|
- (package) eslint v6.0.1
|
|
6684
|
-
- (@putout/plugin-remove-empty) add support of empty
|
|
6738
|
+
- (@putout/plugin-remove-empty) add support of empty consequent block, and not empty alternate block if IfStatement
|
|
6685
6739
|
- (@putout/plugin-remove-unused-variables) add support of TSInterfaceDeclaration, TSMethodSignature
|
|
6686
6740
|
- (package) eslint-plugin-node v9.1.0
|
|
6687
6741
|
- (package) eslint v6.0.1
|
|
@@ -6999,7 +7053,7 @@ fix:
|
|
|
6999
7053
|
|
|
7000
7054
|
feature:
|
|
7001
7055
|
- (@putout/plugin-putout) add
|
|
7002
|
-
- (@putout/eslint-config) padding-line-
|
|
7056
|
+
- (@putout/eslint-config) padding-line-between-statements: add empty line before if condition
|
|
7003
7057
|
- (@putout/plugin-remove-empty-pattern) add support of function argument
|
|
7004
7058
|
- (@putout/plugin-remove-empty) add support of css
|
|
7005
7059
|
|
|
@@ -7164,7 +7218,7 @@ feature:
|
|
|
7164
7218
|
- (@putout/plugin-remove-unused-variables) add support of ClassDeclaration in ExportDefaultDeclaration
|
|
7165
7219
|
- (@putotu/plugin-remove-unused-variables) condition isObjectExpression -> traverse ObjectExpression
|
|
7166
7220
|
- (putout) isTemplateLiteral checks -> TemplateLiteral key
|
|
7167
|
-
- (putout) add support of TemplateLiteral in
|
|
7221
|
+
- (putout) add support of TemplateLiteral in ConditionalExpression
|
|
7168
7222
|
- (@putout/plugin-remove-unused-variables) add support of Identifier in JSXSpreadAttribute
|
|
7169
7223
|
- (@putout/plugin-remove-unused-variables) add support of marking as used elements before RestElement when destructuring used as a function param
|
|
7170
7224
|
- (@putout/plugin-remove-unused-variables) add support of specifiers in ExportNamedDeclaration
|
|
@@ -7232,7 +7286,7 @@ fix:
|
|
|
7232
7286
|
|
|
7233
7287
|
fix:
|
|
7234
7288
|
- (run-plugins) add early return when no need to apply changes
|
|
7235
|
-
- docs(changelog) rm
|
|
7289
|
+
- docs(changelog) rm
|
|
7236
7290
|
|
|
7237
7291
|
|
|
7238
7292
|
2019.02.22, v4.3.0
|
|
@@ -7259,7 +7313,7 @@ fix:
|
|
|
7259
7313
|
|
|
7260
7314
|
feature:
|
|
7261
7315
|
- (plugin-madrun) call-series -> call-run
|
|
7262
|
-
- (eslint-plugin-putout) add
|
|
7316
|
+
- (eslint-plugin-putout) add support of multiple-properties-destructuring
|
|
7263
7317
|
- (eslint-config) add object-property-newline
|
|
7264
7318
|
|
|
7265
7319
|
|
|
@@ -7339,7 +7393,7 @@ feature:
|
|
|
7339
7393
|
- (putout) set defaults for bin
|
|
7340
7394
|
- (putout) remove support of putout section of package.json
|
|
7341
7395
|
- (putout) rm --config
|
|
7342
|
-
- (eslint-config) prefer-destructuring: AssignmentExpression: disable
|
|
7396
|
+
- (eslint-config) prefer-destructuring: AssignmentExpression: disable object
|
|
7343
7397
|
- (eslint-config) prefer-destructuring
|
|
7344
7398
|
- (putout) madrun v2.0.0
|
|
7345
7399
|
|
|
@@ -7355,7 +7409,7 @@ feature:
|
|
|
7355
7409
|
|
|
7356
7410
|
fix:
|
|
7357
7411
|
- (@putout/plugin-madrun) add .spec.js to ignore
|
|
7358
|
-
- (@putout/test) report/reportCode: disable
|
|
7412
|
+
- (@putout/test) report/reportCode: disable
|
|
7359
7413
|
|
|
7360
7414
|
feature:
|
|
7361
7415
|
- (@putout/plugin-madrun) add
|
|
@@ -7747,12 +7801,12 @@ feature:
|
|
|
7747
7801
|
|
|
7748
7802
|
fix:
|
|
7749
7803
|
- (plugin-remove-only) description
|
|
7750
|
-
- feature(putout) change plugin structure: find,
|
|
7804
|
+
- feature(putout) change plugin structure: find,
|
|
7751
7805
|
|
|
7752
7806
|
feature:
|
|
7753
7807
|
- (parse-match) move out from bin/putout.js
|
|
7754
7808
|
- (putout) add support of match/ignore
|
|
7755
|
-
- (putout) add plugin name in
|
|
7809
|
+
- (putout) add plugin name in errors output
|
|
7756
7810
|
- (plugin-remove-skip) add
|
|
7757
7811
|
- (putout) add ability to set config path
|
|
7758
7812
|
- (putout) cherow -> espree: comments support
|
|
@@ -8067,7 +8121,7 @@ feature:
|
|
|
8067
8121
|
2018.12.21, v2.1.0
|
|
8068
8122
|
|
|
8069
8123
|
fix:
|
|
8070
|
-
- test(putout) fn vars
|
|
8124
|
+
- test(putout) fn vars
|
|
8071
8125
|
- test(putout) arrow-vars-
|
|
8072
8126
|
|
|
8073
8127
|
feature:
|
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ Usage: putout [options] [path]
|
|
|
154
154
|
Options:
|
|
155
155
|
-h, --help display this help and exit
|
|
156
156
|
-v, --version output version information and exit
|
|
157
|
-
-f, --format [formatter] use a specific output format, the default is: 'progress-bar'
|
|
157
|
+
-f, --format [formatter] use a specific output format, the default is: 'progress-bar' locally and 'dump' on CI
|
|
158
158
|
-s, --staged add staged files when in git repository
|
|
159
159
|
--fix apply fixes of errors to code
|
|
160
160
|
--fix-count [count = 10] count of fixes rounds
|
|
@@ -187,7 +187,7 @@ putout lib test --fix
|
|
|
187
187
|
|
|
188
188
|
## Plugins
|
|
189
189
|
|
|
190
|
-
By default π**Putout** uses all enabled by default plugins, anyways it can be run with a couple mentioned plugins (
|
|
190
|
+
By default π**Putout** uses all enabled by default plugins, anyways it can be run with a couple mentioned plugins (split with ","):
|
|
191
191
|
|
|
192
192
|
```sh
|
|
193
193
|
putout lib --plugins remove-debugger,remove-unused-variables
|
package/help.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"-h, --help ": "display this help and exit",
|
|
3
3
|
"-v, --version ": "output version information and exit",
|
|
4
|
-
"-f, --format [formatter] ": "use a specific output format, the default is: 'progress-bar'
|
|
4
|
+
"-f, --format [formatter] ": "use a specific output format, the default is: 'progress-bar' locally and 'dump' on CI",
|
|
5
5
|
"-s, --staged ": "add staged files when in git repository",
|
|
6
6
|
"--fix ": "apply fixes of errors to code",
|
|
7
7
|
"--fix-count [count = 10] ": "count of fixes rounds",
|
package/lib/cli/formatter.js
CHANGED
|
@@ -1,72 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const tryToCatch = require('try-to-catch');
|
|
4
|
+
const {createAsyncLoader} = require('@putout/engine-loader');
|
|
4
5
|
|
|
5
6
|
const {
|
|
6
7
|
NO_FORMATTER,
|
|
7
8
|
CANNOT_LOAD_FORMATTER,
|
|
8
9
|
} = require('./exit-codes');
|
|
9
10
|
|
|
10
|
-
const {simpleImportDefault} = require('./simple-import');
|
|
11
|
-
|
|
12
|
-
const stub = () => () => {};
|
|
13
|
-
|
|
14
11
|
const {isArray} = Array;
|
|
15
|
-
const {assign} = Object;
|
|
16
12
|
const maybeArray = (a) => isArray(a) ? a : [a, {}];
|
|
17
13
|
|
|
18
|
-
module.exports.getFormatter = async (
|
|
19
|
-
const [
|
|
20
|
-
|
|
21
|
-
return [
|
|
22
|
-
await getReporter(name, exit),
|
|
23
|
-
formatterOptions,
|
|
24
|
-
];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
module.exports.getReporter = getReporter;
|
|
28
|
-
async function getReporter(name, exit) {
|
|
29
|
-
if (name === 'none')
|
|
30
|
-
return stub();
|
|
14
|
+
module.exports.getFormatter = async (formatterOptional, exit) => {
|
|
15
|
+
const [formatterName, formatterOptions] = maybeArray(formatterOptional);
|
|
16
|
+
const loadFormatter = createAsyncLoader('formatter');
|
|
31
17
|
|
|
32
|
-
const [error,
|
|
33
|
-
`@putout/formatter-${name}`,
|
|
34
|
-
`putout-formatter-${name}`,
|
|
35
|
-
]);
|
|
18
|
+
const [error, formatter] = await tryToCatch(loadFormatter, formatterName, exit);
|
|
36
19
|
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
20
|
+
if (formatter)
|
|
21
|
+
return [formatter, formatterOptions];
|
|
39
22
|
|
|
40
23
|
if (error.code === 'ERR_MODULE_NOT_FOUND')
|
|
41
24
|
return exit(NO_FORMATTER, error);
|
|
42
25
|
|
|
43
26
|
exit(CANNOT_LOAD_FORMATTER, error);
|
|
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(simpleImportDefault, 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
|
-
}
|
|
27
|
+
};
|
|
72
28
|
|
package/lib/cli/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const tryToCatch = require('try-to-catch');
|
|
4
|
+
|
|
3
5
|
const yargsParser = require('yargs-parser');
|
|
4
6
|
const {isCI} = require('ci-info');
|
|
5
7
|
const memo = require('nano-memoize');
|
|
@@ -213,7 +215,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
213
215
|
} = config;
|
|
214
216
|
|
|
215
217
|
const [currentFormat, formatterOptions] = await getFormatter(format || formatter, exit);
|
|
216
|
-
const [error, processorRunners] =
|
|
218
|
+
const [error, processorRunners] = await tryToCatch(getProcessorRunners, processors);
|
|
217
219
|
|
|
218
220
|
if (error)
|
|
219
221
|
return exit(CANNOT_LOAD_PROCESSOR, error);
|
|
@@ -350,3 +352,4 @@ function addOnce(emitter, name, fn) {
|
|
|
350
352
|
if (!emitter.listenerCount(name))
|
|
351
353
|
emitter.on(name, fn);
|
|
352
354
|
}
|
|
355
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "π Pluggable and configurable code transformer with built-in eslint and babel plugins support of js, jsx typescript, flow files, markdown, yaml and json",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"@putout/cli-ruler": "^2.0.0",
|
|
54
54
|
"@putout/cli-validate-args": "^1.0.0",
|
|
55
55
|
"@putout/compare": "^9.0.0",
|
|
56
|
-
"@putout/engine-loader": "^
|
|
56
|
+
"@putout/engine-loader": "^7.0.0",
|
|
57
57
|
"@putout/engine-parser": "^5.0.0",
|
|
58
|
-
"@putout/engine-processor": "^
|
|
58
|
+
"@putout/engine-processor": "^6.0.0",
|
|
59
59
|
"@putout/engine-runner": "^13.0.0",
|
|
60
60
|
"@putout/formatter-codeframe": "^4.0.0",
|
|
61
61
|
"@putout/formatter-dump": "^4.0.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@putout/plugin-convert-comparison-to-boolean": "^3.0.0",
|
|
89
89
|
"@putout/plugin-convert-concat-to-flat": "^1.0.0",
|
|
90
90
|
"@putout/plugin-convert-equal-to-strict-equal": "^1.0.0",
|
|
91
|
-
"@putout/plugin-convert-esm-to-commonjs": "^
|
|
91
|
+
"@putout/plugin-convert-esm-to-commonjs": "^5.0.0",
|
|
92
92
|
"@putout/plugin-convert-for-each-to-for-of": "^7.0.0",
|
|
93
93
|
"@putout/plugin-convert-for-in-to-for-of": "^2.0.0",
|
|
94
94
|
"@putout/plugin-convert-for-to-for-of": "^4.0.0",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"@putout/plugin-remove-useless-type-conversion": "^2.0.0",
|
|
159
159
|
"@putout/plugin-remove-useless-typeof": "^1.0.0",
|
|
160
160
|
"@putout/plugin-remove-useless-variables": "^7.0.0",
|
|
161
|
-
"@putout/plugin-reuse-duplicate-init": "^
|
|
161
|
+
"@putout/plugin-reuse-duplicate-init": "^4.0.0",
|
|
162
162
|
"@putout/plugin-simplify-assignment": "^1.0.0",
|
|
163
163
|
"@putout/plugin-simplify-logical-expressions": "^2.0.0",
|
|
164
164
|
"@putout/plugin-simplify-ternary": "^2.0.0",
|