putout 35.21.0 β†’ 35.22.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,17 @@
1
+ 2024.05.07, v35.22.0
2
+
3
+ feature:
4
+ - 300976b97 putout: @putout/plugin-promises v15.0.0
5
+ - 84f082b24 @putout/plugin-promises: drop support of 🐊 < 35
6
+ - 6cb1598b8 putout: process-file: do not show ESLint parser errors when 🐊Putout can parse
7
+ - 2b8b8be6c @putout/engine-parser: add ability to parse await without async
8
+ - ca781d676 @putout/plugin-promises: add-missing-async: add
9
+
10
+ 2024.05.07, v35.21.1
11
+
12
+ feature:
13
+ - 9f6278963 putout: process-file: syntax
14
+
1
15
  2024.05.06, v35.21.0
2
16
 
3
17
  fix:
@@ -2,14 +2,14 @@
2
2
 
3
3
  const tryToCatch = require('try-to-catch');
4
4
  const eslint = require('@putout/eslint');
5
- const quickLint = require('@putout/quick-lint');
6
5
 
7
6
  const {putoutAsync} = require('../..');
8
7
  const merge = require('../merge');
9
8
  const parseMatch = require('../parse-options/parse-match');
10
- const {syntaxFix} = require('./syntax/syntax');
9
+ const {lintSyntax} = require('./syntax/syntax');
11
10
 
12
11
  const parseError = require('./parse-error');
12
+ const isParserError = ([a]) => a?.rule.includes('parser');
13
13
 
14
14
  const getMatchedOptions = (name, options) => {
15
15
  if (!name.includes('{'))
@@ -32,23 +32,26 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
32
32
  printer: configurePrinter(name, printer),
33
33
  });
34
34
 
35
- if (e && !fix) {
35
+ if (e) {
36
36
  raw && logError(e);
37
- const quickLintPlaces = await quickLint(source, {
37
+ const {places, code} = await lintSyntax(source, {
38
+ fix,
38
39
  isTS,
39
- isJSX: true,
40
40
  });
41
41
 
42
- if (quickLintPlaces.length)
42
+ if (!fix && places.length)
43
43
  return {
44
- places: quickLintPlaces,
45
- code: source,
44
+ places,
45
+ code,
46
+ };
47
+
48
+ if (fix && !places.length)
49
+ return {
50
+ places,
51
+ code,
46
52
  };
47
53
  }
48
54
 
49
- if (e && fix)
50
- return await syntaxFix(source);
51
-
52
55
  const {code = source} = result || {};
53
56
  const allPlaces = result ? result.places : parseError(e);
54
57
 
@@ -58,7 +61,10 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
58
61
  fix,
59
62
  });
60
63
 
61
- allPlaces.push(...newPlaces);
64
+ const wasParserError = isParserError(newPlaces);
65
+
66
+ if (e || !wasParserError)
67
+ allPlaces.push(...newPlaces);
62
68
 
63
69
  const places = formatPlaces(startLine, allPlaces);
64
70
 
@@ -1,12 +1,43 @@
1
1
  'use strict';
2
2
 
3
- module.exports.syntaxFix = async (source) => {
4
- const {parse, print} = await import('goldstein');
3
+ const tryCatch = require('try-catch');
4
+ const parseError = require('../parse-error');
5
+
6
+ module.exports.lintSyntax = async (source, {fix, isTS}) => {
7
+ if (fix)
8
+ return await syntaxFix(source);
5
9
 
6
- const code = print(parse(source));
10
+ return await syntaxLint(source, {
11
+ isTS,
12
+ });
13
+ };
14
+
15
+ async function syntaxFix(source) {
16
+ const {compile} = await import('goldstein');
17
+ const [error, code] = tryCatch(compile, source);
18
+
19
+ if (error)
20
+ return {
21
+ code: source,
22
+ places: parseError(error),
23
+ };
7
24
 
8
25
  return {
9
26
  code,
10
27
  places: [],
11
28
  };
12
- };
29
+ }
30
+
31
+ async function syntaxLint(source, {isTS}) {
32
+ const {default: quickLint} = await import('@putout/quick-lint');
33
+
34
+ const quickLintPlaces = await quickLint(source, {
35
+ isTS,
36
+ isJSX: true,
37
+ });
38
+
39
+ return {
40
+ places: quickLintPlaces,
41
+ code: source,
42
+ };
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "35.21.0",
3
+ "version": "35.22.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, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -133,7 +133,7 @@
133
133
  "@putout/plugin-nodejs": "^11.0.0",
134
134
  "@putout/plugin-npmignore": "^5.0.0",
135
135
  "@putout/plugin-package-json": "^7.0.0",
136
- "@putout/plugin-promises": "^14.0.0",
136
+ "@putout/plugin-promises": "^15.0.0",
137
137
  "@putout/plugin-putout": "^19.0.0",
138
138
  "@putout/plugin-putout-config": "^5.0.0",
139
139
  "@putout/plugin-regexp": "^8.0.0",