putout 22.3.2 → 22.5.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,59 @@
1
+ 2021.12.04, v22.5.0
2
+
3
+ fix:
4
+ - (@putout/plugin-convert-mock-require-to-mock-import) handle no stopAll case
5
+
6
+ feature:
7
+ - (@putout/plugin-declare-undefined-variables) add support of simport
8
+ - (package) @putout/formatter-progress-bar v2.0.0
9
+ - (@putout/test) format: improve ability to test ESM
10
+ - (@putout/plugin-convert-commonjs-to-esm) require: call: exclude dot dot
11
+ - (@putout/plugin-declare-undefined-variables) add fresh-import
12
+ - (@putout/formatter-progress-bar) convert to ESM
13
+ - (package) @putout/plugin-convert-commonjs-to-esm v6.0.0
14
+ - (package) @putout/formatter-progress v3.0.0
15
+ - (@putout/formatter-progress) convert to ESM
16
+ - (@putout/plugin-convert-commonjs-to-esm) drop support of putout < 22
17
+ - (@putout/plugin-convert-commonjs-to-esm) require: improve support of namespaces: PascalCase -> kebabCase
18
+ - (@putout/test) v4.0.0
19
+ - (putout) add support of ESM formatters
20
+ - (@putout/formatter-eslint) convert to ESM
21
+ - (@putout/formatter-eslint) convert to async
22
+ - (@putout/test) format: convert to async
23
+ - (putout) add support of async formatters
24
+ - (@putout/plugin-declare-undefined-variables) add support of zlib
25
+ - (@putout/plugin-declare-undefined-variables) logical: add id
26
+ - (@putout/plugin-declare-undefined-variables) add logical
27
+
28
+
29
+ 2021.12.02, v22.4.0
30
+
31
+ feature:
32
+ - (putout) add env variable PUTOUT_CONFIG_FILE
33
+ - (eslint-plugin-putout) ts: add extension rules
34
+ - (eslint-plugin-putout) ts: enable @typescript-eslint/type-annotation-spacing
35
+ - (eslint-plugin-putout) safe: add remove-useless-arguments
36
+ - (eslint-plugin-putout) tape-remove-newline-before-t-end: add support of case when no assertions found before t.end()
37
+ - (eslint-plugin-putout) ts: disable: ban-types, no-explicit-any, no-empty-function
38
+ - (package) eslint-plugin-putout v12.0.0
39
+ - (eslint-plugin-putout) drop support of putout < 22
40
+ - (eslint-plugin-putout) add first class support of typescript
41
+ - (eslint-plugin-putout) improve support of add-newline-{before,after}-function-call
42
+ - (@putout/plugin-remove-empty-pattern) add support of nested ArrayPattern
43
+
44
+
45
+ 2021.12.01, v22.3.4
46
+
47
+ fix:
48
+ - (putout) validate-options: add support of boolean
49
+
50
+
51
+ 2021.11.30, v22.3.3
52
+
53
+ fix:
54
+ - (putout) validate-options: add support of optional message
55
+
56
+
1
57
  2021.11.30, v22.3.2
2
58
 
3
59
  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,17 +5,36 @@
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
  }],
17
16
  "minItems": 2,
18
17
  "additionalItems": false
18
+ }, {
19
+ "type": "array",
20
+ "items": [{
21
+ "$ref": "#/definitions/ruleToggle"
22
+ }, {
23
+ "type": "string"
24
+ }, {
25
+ "type": "object"
26
+ }],
27
+ "minItems": 3,
28
+ "additionalItems": false
29
+ }, {
30
+ "type": "array",
31
+ "items": [{
32
+ "$ref": "#/definitions/ruleToggle"
33
+ }, {
34
+ "type": "string"
35
+ }],
36
+ "minItems": 2,
37
+ "additionalItems": false
19
38
  }]
20
39
  },
21
40
  "rules": {
@@ -26,6 +45,14 @@
26
45
  "$ref": "#/definitions/rule"
27
46
  }
28
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
+ }]
29
56
  }
30
57
  },
31
58
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "22.3.2",
3
+ "version": "22.5.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",
@@ -61,8 +61,8 @@
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",
@@ -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",
@@ -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",