putout 35.21.0 → 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 +5 -0
- package/lib/cli/process-file.js +13 -11
- package/lib/cli/syntax/syntax.js +35 -4
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/lib/cli/process-file.js
CHANGED
|
@@ -2,12 +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');
|
|
10
|
-
const {
|
|
9
|
+
const {lintSyntax} = require('./syntax/syntax');
|
|
11
10
|
|
|
12
11
|
const parseError = require('./parse-error');
|
|
13
12
|
|
|
@@ -32,23 +31,26 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
|
|
|
32
31
|
printer: configurePrinter(name, printer),
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
if (e
|
|
34
|
+
if (e) {
|
|
36
35
|
raw && logError(e);
|
|
37
|
-
const
|
|
36
|
+
const {places, code} = await lintSyntax(source, {
|
|
37
|
+
fix,
|
|
38
38
|
isTS,
|
|
39
|
-
isJSX: true,
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
if (
|
|
41
|
+
if (!fix && places.length)
|
|
43
42
|
return {
|
|
44
|
-
places
|
|
45
|
-
code
|
|
43
|
+
places,
|
|
44
|
+
code,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (fix && !places.length)
|
|
48
|
+
return {
|
|
49
|
+
places,
|
|
50
|
+
code,
|
|
46
51
|
};
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
if (e && fix)
|
|
50
|
-
return await syntaxFix(source);
|
|
51
|
-
|
|
52
54
|
const {code = source} = result || {};
|
|
53
55
|
const allPlaces = result ? result.places : parseError(e);
|
|
54
56
|
|
package/lib/cli/syntax/syntax.js
CHANGED
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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.
|
|
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",
|