putout 35.22.1 → 35.22.3
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 +15 -0
- package/lib/cli/process-file.js +12 -7
- package/lib/cli/syntax/{syntax.js → syntax.mjs} +11 -7
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
2024.05.09, v35.22.3
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 6cb49e0b4 putout: cli: syntax lint: improve support of fn
|
|
5
|
+
|
|
6
|
+
2024.05.08, v35.22.2
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 1e3ca1f22 putout: run 🐊 after fixing syntax errors
|
|
10
|
+
- 807430337 eslint-plugin-putout: align-spaces: report
|
|
11
|
+
- 08e77aec0 @putout/plugin-putout: convert-replace-with: report
|
|
12
|
+
- 19908112b @putout/plugin-for-of: add-missing-star: delegate
|
|
13
|
+
- 3f41dd7de @putout/plugin-react: apply-create-root: add
|
|
14
|
+
- eb138c934 @putout/plugin-for-of: add-missing-star
|
|
15
|
+
|
|
1
16
|
2024.05.07, v35.22.1
|
|
2
17
|
|
|
3
18
|
feature:
|
package/lib/cli/process-file.js
CHANGED
|
@@ -6,8 +6,8 @@ const eslint = require('@putout/eslint');
|
|
|
6
6
|
const {putoutAsync} = require('../..');
|
|
7
7
|
const merge = require('../merge');
|
|
8
8
|
const parseMatch = require('../parse-options/parse-match');
|
|
9
|
-
const {lintSyntax} = require('./syntax/syntax');
|
|
10
9
|
|
|
10
|
+
const {simpleImport} = require('./simple-import');
|
|
11
11
|
const parseError = require('./parse-error');
|
|
12
12
|
const isParserError = ([a]) => a?.rule.includes('parser');
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ const getMatchedOptions = (name, options) => {
|
|
|
18
18
|
return merge(options, parseMatch(name, options.match));
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({name, source, startLine, options})
|
|
21
|
+
module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async function processFile({name, source, startLine, options, again}) {
|
|
22
22
|
const {configurePrinter} = await import('./printer/printer.mjs');
|
|
23
23
|
const isTS = /\.tsx?$/.test(name) || /{tsx?}$/.test(name);
|
|
24
24
|
const matchedOptions = getMatchedOptions(name, options);
|
|
@@ -32,8 +32,10 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
|
|
|
32
32
|
printer: configurePrinter(name, printer),
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
if (e) {
|
|
35
|
+
if (!again && e) {
|
|
36
36
|
raw && logError(e);
|
|
37
|
+
|
|
38
|
+
const {lintSyntax} = await simpleImport('./syntax/syntax.mjs');
|
|
37
39
|
const {places, code} = await lintSyntax(source, {
|
|
38
40
|
fix,
|
|
39
41
|
isTS,
|
|
@@ -46,10 +48,13 @@ module.exports = ({fix, fixCount, isFlow, logError, raw, printer}) => async ({na
|
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
if (fix && !places.length)
|
|
49
|
-
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
return await processFile({
|
|
52
|
+
again: true,
|
|
53
|
+
name,
|
|
54
|
+
source: code,
|
|
55
|
+
startLine,
|
|
56
|
+
options,
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
const {code = source} = result || {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import tryCatch from 'try-catch';
|
|
2
|
+
import parseError from '../parse-error.js';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
const parseError = require('../parse-error');
|
|
5
|
-
|
|
6
|
-
module.exports.lintSyntax = async (source, {fix, isTS}) => {
|
|
4
|
+
export const lintSyntax = async (source, {fix, isTS}) => {
|
|
7
5
|
if (fix)
|
|
8
6
|
return await syntaxFix(source);
|
|
9
7
|
|
|
@@ -13,8 +11,14 @@ module.exports.lintSyntax = async (source, {fix, isTS}) => {
|
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
async function syntaxFix(source) {
|
|
16
|
-
const {compile} = await import('goldstein');
|
|
17
|
-
const
|
|
14
|
+
const {compile, keywords} = await import('goldstein');
|
|
15
|
+
const {keywordArrow, keywordIf} = keywords;
|
|
16
|
+
const [error, code] = tryCatch(compile, source, {
|
|
17
|
+
keywords: {
|
|
18
|
+
keywordArrow,
|
|
19
|
+
keywordIf,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
18
22
|
|
|
19
23
|
if (error)
|
|
20
24
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "35.22.
|
|
3
|
+
"version": "35.22.3",
|
|
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",
|