putout 22.3.3 → 22.5.1

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,68 @@
1
+ 2021.12.05, v22.5.1
2
+
3
+ feature:
4
+ - (package) @putout/plugin-declare-undefined-variables v6.0.0
5
+ - (package) @putout/plugin-tape v7.0.0
6
+ - (package) @putout/operator-declare v2.0.0
7
+ - (@putout/operator-declare) drop support of putout < 22.5
8
+ - (@putout/plugin-tape) drop support of putout < 22.5
9
+ - (@putout/plugin-tape) declare: add mockImport
10
+ - (@putout/plugin-declare-undefined-variables) mv mock-import to @putout/plugin-tape
11
+ - (@putout/plugin-declare-undefined-variables) drop support of putout < 22.5
12
+ - (@putout/plugin-declare-undefined-variables) simport: add support of dual packages
13
+ - (@putout/operator-declare) add support of dual packages: esm and commonjs
14
+
15
+
16
+ 2021.12.04, v22.5.0
17
+
18
+ fix:
19
+ - (@putout/plugin-convert-mock-require-to-mock-import) handle no stopAll case
20
+
21
+ feature:
22
+ - (@putout/plugin-declare-undefined-variables) add support of simport
23
+ - (package) @putout/formatter-progress-bar v2.0.0
24
+ - (@putout/test) format: improve ability to test ESM
25
+ - (@putout/plugin-convert-commonjs-to-esm) require: call: exclude dot dot
26
+ - (@putout/plugin-declare-undefined-variables) add fresh-import
27
+ - (@putout/formatter-progress-bar) convert to ESM
28
+ - (package) @putout/plugin-convert-commonjs-to-esm v6.0.0
29
+ - (package) @putout/formatter-progress v3.0.0
30
+ - (@putout/formatter-progress) convert to ESM
31
+ - (@putout/plugin-convert-commonjs-to-esm) drop support of putout < 22
32
+ - (@putout/plugin-convert-commonjs-to-esm) require: improve support of namespaces: PascalCase -> kebabCase
33
+ - (@putout/test) v4.0.0
34
+ - (putout) add support of ESM formatters
35
+ - (@putout/formatter-eslint) convert to ESM
36
+ - (@putout/formatter-eslint) convert to async
37
+ - (@putout/test) format: convert to async
38
+ - (putout) add support of async formatters
39
+ - (@putout/plugin-declare-undefined-variables) add support of zlib
40
+ - (@putout/plugin-declare-undefined-variables) logical: add id
41
+ - (@putout/plugin-declare-undefined-variables) add logical
42
+
43
+
44
+ 2021.12.02, v22.4.0
45
+
46
+ feature:
47
+ - (putout) add env variable PUTOUT_CONFIG_FILE
48
+ - (eslint-plugin-putout) ts: add extension rules
49
+ - (eslint-plugin-putout) ts: enable @typescript-eslint/type-annotation-spacing
50
+ - (eslint-plugin-putout) safe: add remove-useless-arguments
51
+ - (eslint-plugin-putout) tape-remove-newline-before-t-end: add support of case when no assertions found before t.end()
52
+ - (eslint-plugin-putout) ts: disable: ban-types, no-explicit-any, no-empty-function
53
+ - (package) eslint-plugin-putout v12.0.0
54
+ - (eslint-plugin-putout) drop support of putout < 22
55
+ - (eslint-plugin-putout) add first class support of typescript
56
+ - (eslint-plugin-putout) improve support of add-newline-{before,after}-function-call
57
+ - (@putout/plugin-remove-empty-pattern) add support of nested ArrayPattern
58
+
59
+
60
+ 2021.12.01, v22.3.4
61
+
62
+ fix:
63
+ - (putout) validate-options: add support of boolean
64
+
65
+
1
66
  2021.11.30, v22.3.3
2
67
 
3
68
  fix:
package/README.md CHANGED
@@ -153,6 +153,8 @@ putout lib --plugins remove-debugger,remove-unused-variables
153
153
  🐊`Putout` supports next `environment variables`:
154
154
 
155
155
  - `PUTOUT_FILES` - files that should be processed by putout, divided by ",";
156
+ - `PUTOUT_CONFIG_FILE` - path to 🐊`Putout` config file;
157
+ - `ESLINT_CONFIG_FILE` - path to `ESLint` config file;
156
158
 
157
159
  ```sh
158
160
  PUTOUT_FILES=lib,test putout --fix
@@ -1,24 +1,27 @@
1
1
  'use strict';
2
2
 
3
- const tryCatch = require('try-catch');
3
+ const {createSimport} = require('simport');
4
+ const tryToCatch = require('try-to-catch');
5
+
4
6
  const {NO_FORMATTER} = require('./exit-codes');
5
7
 
8
+ const simport = createSimport(__filename);
6
9
  const stub = () => () => {};
7
10
 
8
11
  const {isArray} = Array;
9
12
  const maybeArray = (a) => isArray(a) ? a : [a, {}];
10
13
 
11
- module.exports.getFormatter = (formatter, exit) => {
14
+ module.exports.getFormatter = async (formatter, exit) => {
12
15
  const [name, formatterOptions] = maybeArray(formatter);
13
16
 
14
17
  return [
15
- getReporter(name, exit),
18
+ await getReporter(name, exit),
16
19
  formatterOptions,
17
20
  ];
18
21
  };
19
22
 
20
23
  module.exports.getReporter = getReporter;
21
- function getReporter(name, exit) {
24
+ async function getReporter(name, exit) {
22
25
  let e;
23
26
  let reporter;
24
27
 
@@ -26,16 +29,16 @@ function getReporter(name, exit) {
26
29
  return stub();
27
30
  }
28
31
 
29
- [e, reporter] = tryCatch(require, `@putout/formatter-${name}`);
32
+ [e, reporter] = await tryToCatch(simport, `@putout/formatter-${name}`);
30
33
 
31
34
  if (!e)
32
35
  return reporter;
33
36
 
34
- [e, reporter] = tryCatch(require, `putout-formatter-${name}`);
37
+ [e, reporter] = await tryToCatch(simport, `putout-formatter-${name}`);
35
38
 
36
- if (e)
37
- exit(NO_FORMATTER, e);
39
+ if (!e)
40
+ return reporter;
38
41
 
39
- return reporter;
42
+ exit(NO_FORMATTER, e);
40
43
  }
41
44
 
@@ -1,19 +1,34 @@
1
1
  'use strict';
2
2
 
3
- const {dirname} = require('path');
3
+ const {
4
+ join,
5
+ dirname,
6
+ } = require('path');
4
7
 
5
8
  const buildPlugins = require('./build-plugins');
6
9
  const parseOptions = require('../parse-options');
7
10
 
11
+ const {assign} = Object;
12
+ const {env} = process;
13
+ const {PUTOUT_CONFIG_FILE} = env;
14
+
15
+ const maybeConfig = {
16
+ plugins: [],
17
+ };
18
+
19
+ PUTOUT_CONFIG_FILE && assign(maybeConfig, require(join(process.cwd(), PUTOUT_CONFIG_FILE)));
20
+
8
21
  module.exports = ({noConfig, plugins, name, transform, rulesdir}) => {
9
22
  const transformPlugins = buildPlugins(transform);
10
23
 
11
24
  if (noConfig)
12
25
  return {
26
+ ...maybeConfig,
13
27
  dir: dirname(name),
14
28
  plugins: [
15
29
  ...plugins,
16
30
  ...transformPlugins,
31
+ ...maybeConfig.plugins,
17
32
  ],
18
33
  };
19
34
 
@@ -24,9 +39,11 @@ module.exports = ({noConfig, plugins, name, transform, rulesdir}) => {
24
39
 
25
40
  return {
26
41
  ...result,
42
+ ...maybeConfig,
27
43
  plugins: [
28
44
  ...result.plugins,
29
45
  ...transformPlugins,
46
+ ...maybeConfig.plugins,
30
47
  ],
31
48
  };
32
49
  };
package/lib/cli/index.js CHANGED
@@ -235,7 +235,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
235
235
  processors = defaultProcessors,
236
236
  } = config;
237
237
 
238
- const [currentFormat, formatterOptions] = getFormatter(format || formatter, exit);
238
+ const [currentFormat, formatterOptions] = await getFormatter(format || formatter, exit);
239
239
  const [error, processorRunners] = tryCatch(getProcessorRunners, processors);
240
240
 
241
241
  if (error)
@@ -341,7 +341,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
341
341
  count: length,
342
342
  });
343
343
 
344
- const line = report(currentFormat, formatterProxy);
344
+ const line = await report(currentFormat, formatterProxy);
345
345
 
346
346
  write(line || '');
347
347
  rawPlaces.push(places);
@@ -382,7 +382,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
382
382
  }
383
383
  }
384
384
 
385
- const line = report(currentFormat, {
385
+ const line = await report(currentFormat, {
386
386
  report,
387
387
  formatterOptions,
388
388
  name: chooseName(name, resolvedName),
package/lib/cli/report.js CHANGED
@@ -4,7 +4,7 @@ module.exports = () => {
4
4
  let filesCount = 0;
5
5
  let errorsCount = 0;
6
6
 
7
- return (formatter, options) => {
7
+ return async (formatter, options) => {
8
8
  const {
9
9
  name,
10
10
  source,
@@ -19,7 +19,7 @@ module.exports = () => {
19
19
 
20
20
  errorsCount += places.length;
21
21
 
22
- return formatter({
22
+ return await formatter({
23
23
  name,
24
24
  options: formatterOptions,
25
25
  source,
@@ -5,12 +5,11 @@
5
5
  "definitions": {
6
6
  "rule": {
7
7
  "oneOf": [{
8
- "description": "🐊Putout rule\n\n\"off\" means rule is off\n\"on\" means it is a on\n",
9
- "enum": [ "on", "off"]
8
+ "$ref": "#/definitions/ruleToggle"
10
9
  }, {
11
10
  "type": "array",
12
11
  "items": [{
13
- "enum": [ "on", "off"]
12
+ "$ref": "#/definitions/ruleToggle"
14
13
  }, {
15
14
  "type": "object"
16
15
  }],
@@ -19,7 +18,7 @@
19
18
  }, {
20
19
  "type": "array",
21
20
  "items": [{
22
- "enum": [ "on", "off"]
21
+ "$ref": "#/definitions/ruleToggle"
23
22
  }, {
24
23
  "type": "string"
25
24
  }, {
@@ -30,7 +29,7 @@
30
29
  }, {
31
30
  "type": "array",
32
31
  "items": [{
33
- "enum": [ "on", "off"]
32
+ "$ref": "#/definitions/ruleToggle"
34
33
  }, {
35
34
  "type": "string"
36
35
  }],
@@ -46,6 +45,14 @@
46
45
  "$ref": "#/definitions/rule"
47
46
  }
48
47
  }
48
+ },
49
+ "ruleToggle": {
50
+ "oneOf": [{
51
+ "description": "🐊Putout rule\n\n\"off\" means rule is off\n\"on\" means it is a on\n",
52
+ "enum": [ "on", "off"]
53
+ }, {
54
+ "enum": [true, false]
55
+ }]
49
56
  }
50
57
  },
51
58
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "22.3.3",
3
+ "version": "22.5.1",
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",
@@ -61,12 +61,12 @@
61
61
  "@putout/formatter-json": "^1.0.0",
62
62
  "@putout/formatter-json-lines": "^1.0.0",
63
63
  "@putout/formatter-memory": "^1.0.0",
64
- "@putout/formatter-progress": "^2.0.0",
65
- "@putout/formatter-progress-bar": "^1.1.0",
64
+ "@putout/formatter-progress": "^3.0.0",
65
+ "@putout/formatter-progress-bar": "^2.0.0",
66
66
  "@putout/formatter-stream": "^2.0.0",
67
67
  "@putout/operate": "^6.0.0",
68
68
  "@putout/operator-add-args": "^1.0.0",
69
- "@putout/operator-declare": "^1.0.0",
69
+ "@putout/operator-declare": "^2.0.0",
70
70
  "@putout/operator-regexp": "^1.0.0",
71
71
  "@putout/plugin-apply-array-at": "^1.0.0",
72
72
  "@putout/plugin-apply-as-type-assertions": "^1.0.0",
@@ -83,7 +83,7 @@
83
83
  "@putout/plugin-convert-assignment-to-arrow-function": "^1.0.0",
84
84
  "@putout/plugin-convert-assignment-to-comparison": "^1.0.0",
85
85
  "@putout/plugin-convert-bitwise-to-logical": "^1.0.0",
86
- "@putout/plugin-convert-commonjs-to-esm": "^5.0.0",
86
+ "@putout/plugin-convert-commonjs-to-esm": "^6.0.0",
87
87
  "@putout/plugin-convert-comparison-to-boolean": "^1.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",
@@ -102,7 +102,7 @@
102
102
  "@putout/plugin-convert-to-arrow-function": "^3.0.0",
103
103
  "@putout/plugin-convert-top-level-return": "^4.0.0",
104
104
  "@putout/plugin-convert-typeof-to-is-type": "^1.0.0",
105
- "@putout/plugin-declare-undefined-variables": "^5.0.0",
105
+ "@putout/plugin-declare-undefined-variables": "^6.0.0",
106
106
  "@putout/plugin-eslint": "^2.0.0",
107
107
  "@putout/plugin-extract-object-properties": "^6.0.0",
108
108
  "@putout/plugin-extract-sequence-expressions": "^2.0.0",
@@ -169,7 +169,7 @@
169
169
  "@putout/plugin-split-nested-destructuring": "^1.0.0",
170
170
  "@putout/plugin-split-variable-declarations": "^2.0.0",
171
171
  "@putout/plugin-strict-mode": "^2.0.0",
172
- "@putout/plugin-tape": "^6.0.0",
172
+ "@putout/plugin-tape": "^7.0.0",
173
173
  "@putout/plugin-webpack": "^1.0.0",
174
174
  "@putout/processor-css": "^3.0.0",
175
175
  "@putout/processor-ignore": "^2.0.0",
@@ -220,7 +220,7 @@
220
220
  "currify": "^4.0.0",
221
221
  "eslint": "^8.0.1",
222
222
  "eslint-plugin-node": "^11.0.0",
223
- "eslint-plugin-putout": "^11.0.0",
223
+ "eslint-plugin-putout": "^12.0.0",
224
224
  "just-camel-case": "^4.0.2",
225
225
  "lerna": "^4.0.0",
226
226
  "madrun": "^8.6.0",