putout 35.20.1 → 35.21.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,21 @@
1
+ 2024.05.07, v35.21.1
2
+
3
+ feature:
4
+ - 9f6278963 putout: process-file: syntax
5
+
6
+ 2024.05.06, v35.21.0
7
+
8
+ fix:
9
+ - 8b22f546d @putout/processor-yaml: lineWidth: 80 -> Infinity
10
+
11
+ feature:
12
+ - 68404b101 putout: add ability to autofix syntax
13
+ - 7367fd174 @putout/plugin-react: remove-useless-forward-ref: add
14
+ - 522b92c5a @putout/plugin-apply-overrides: improve support of one-two arguments
15
+ - d86f10109 @putout/plugin-react: remove-implicit-ref-return: add
16
+ - 6064290d3 eslint-plugin-putout: long-properties-destructuring: exclude ImportDefaultSpecifier
17
+ - 2d6890984 @putout/plugin-react: add
18
+
1
19
  2024.05.06, v35.20.1
2
20
 
3
21
  fix:
@@ -2,11 +2,11 @@
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');
9
+ const {lintSyntax} = require('./syntax/syntax');
10
10
 
11
11
  const parseError = require('./parse-error');
12
12
 
@@ -33,15 +33,21 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
33
33
 
34
34
  if (e) {
35
35
  raw && logError(e);
36
- const quickLintPlaces = await quickLint(source, {
36
+ const {places, code} = await lintSyntax(source, {
37
+ fix,
37
38
  isTS,
38
- isJSX: true,
39
39
  });
40
40
 
41
- if (quickLintPlaces.length)
41
+ if (!fix && places.length)
42
42
  return {
43
- places: quickLintPlaces,
44
- code: source,
43
+ places,
44
+ code,
45
+ };
46
+
47
+ if (fix && !places.length)
48
+ return {
49
+ places,
50
+ code,
45
51
  };
46
52
  }
47
53
 
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
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);
9
+
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
+ };
24
+
25
+ return {
26
+ code,
27
+ places: [],
28
+ };
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.20.1",
3
+ "version": "35.21.1",
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",
@@ -197,6 +197,7 @@
197
197
  "fast-glob": "^3.2.2",
198
198
  "find-up": "^7.0.0",
199
199
  "fullstore": "^3.0.0",
200
+ "goldstein": "^5.3.0",
200
201
  "ignore": "^5.0.4",
201
202
  "is-relative": "^1.0.0",
202
203
  "nano-memoize": "^3.0.11",