eslint-plugin-putout 25.2.0 → 26.0.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/README.md +0 -10
- package/lib/index.mjs +0 -14
- package/lib/putout/index.js +0 -10
- package/lib/putout/parse-error.js +1 -1
- package/package.json +4 -5
- package/lib/putout/async/find-places.mjs +0 -13
- package/lib/putout/async/index.js +0 -117
- package/lib/putout/async/transform.mjs +0 -14
package/README.md
CHANGED
|
@@ -208,16 +208,6 @@ import {jsx} from 'eslint-plugin-putout;
|
|
|
208
208
|
export default jsx;
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
### esm
|
|
212
|
-
|
|
213
|
-
If you want to use **ESM** plugins of 🐊**Putout** you need to use `esm` preset:
|
|
214
|
-
|
|
215
|
-
```json
|
|
216
|
-
import {esm} from 'eslint-plugin-putout;
|
|
217
|
-
|
|
218
|
-
export default esm;
|
|
219
|
-
```
|
|
220
|
-
|
|
221
211
|
## License
|
|
222
212
|
|
|
223
213
|
MIT
|
package/lib/index.mjs
CHANGED
|
@@ -104,7 +104,6 @@ export const safe = [
|
|
|
104
104
|
'putout/align-spaces': 'off',
|
|
105
105
|
'putout/remove-newline-from-empty-object': 'off',
|
|
106
106
|
'putout/putout': ['error', {
|
|
107
|
-
esm: false,
|
|
108
107
|
rules: safeRules,
|
|
109
108
|
}],
|
|
110
109
|
},
|
|
@@ -121,24 +120,11 @@ export const safeAlign = [
|
|
|
121
120
|
},
|
|
122
121
|
];
|
|
123
122
|
|
|
124
|
-
export const esm = {
|
|
125
|
-
...n,
|
|
126
|
-
...safeAlign,
|
|
127
|
-
rules: {
|
|
128
|
-
...safeAlign.rules,
|
|
129
|
-
'putout/putout': ['error', {
|
|
130
|
-
esm: true,
|
|
131
|
-
rules: safeRules,
|
|
132
|
-
}],
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
123
|
export const configs = {
|
|
137
124
|
recommended,
|
|
138
125
|
jsx,
|
|
139
126
|
safe,
|
|
140
127
|
safeAlign,
|
|
141
|
-
esm,
|
|
142
128
|
};
|
|
143
129
|
|
|
144
130
|
export const {rules} = putout;
|
package/lib/putout/index.js
CHANGED
|
@@ -19,16 +19,6 @@ module.exports = {
|
|
|
19
19
|
|
|
20
20
|
create(context) {
|
|
21
21
|
const {esm, ...options} = getContextOptions(context);
|
|
22
|
-
|
|
23
|
-
if (esm) {
|
|
24
|
-
const putoutAsync = require('./async');
|
|
25
|
-
|
|
26
|
-
return putoutAsync({
|
|
27
|
-
context,
|
|
28
|
-
options,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
22
|
const putoutSync = require('./sync');
|
|
33
23
|
|
|
34
24
|
return putoutSync({
|
|
@@ -5,7 +5,7 @@ module.exports.parseError = ({code, message, name}) => {
|
|
|
5
5
|
return 'Parser error';
|
|
6
6
|
|
|
7
7
|
if (code === 'ERR_REQUIRE_ESM')
|
|
8
|
-
return `☝️ Looks like '${name}' is ESM,
|
|
8
|
+
return `☝️ Looks like '${name}' is ESM, consider updating node to >= v20.19`;
|
|
9
9
|
|
|
10
10
|
return message;
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -51,11 +51,10 @@
|
|
|
51
51
|
"@typescript-eslint/parser": "^8.3.0",
|
|
52
52
|
"align-spaces": "^2.0.0",
|
|
53
53
|
"eslint-plugin-n": "^17.0.0",
|
|
54
|
-
"eslint-plugin-putout": "^
|
|
54
|
+
"eslint-plugin-putout": "^26.0.0",
|
|
55
55
|
"eslint-plugin-react": "^7.32.2",
|
|
56
56
|
"globals": "^16.0.0",
|
|
57
57
|
"parse-import-specifiers": "^1.0.1",
|
|
58
|
-
"synckit": "^0.9.0",
|
|
59
58
|
"try-catch": "^3.0.0",
|
|
60
59
|
"try-to-catch": "^3.0.1",
|
|
61
60
|
"typescript": "~5.7.0",
|
|
@@ -75,11 +74,11 @@
|
|
|
75
74
|
"supertape": "^10.0.0"
|
|
76
75
|
},
|
|
77
76
|
"engines": {
|
|
78
|
-
"node": ">=
|
|
77
|
+
"node": ">=20"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
80
|
"eslint": ">=9",
|
|
82
|
-
"putout": ">=
|
|
81
|
+
"putout": ">=39"
|
|
83
82
|
},
|
|
84
83
|
"license": "MIT",
|
|
85
84
|
"publishConfig": {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {findPlacesAsync} from 'putout';
|
|
2
|
-
import tryToCatch from 'try-to-catch';
|
|
3
|
-
import {runAsWorker} from 'synckit';
|
|
4
|
-
import parseOptions from 'putout/parse-options';
|
|
5
|
-
|
|
6
|
-
runAsWorker(async ({name, options, ast, text}) => {
|
|
7
|
-
const resultOptions = parseOptions({
|
|
8
|
-
name,
|
|
9
|
-
options,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return await tryToCatch(findPlacesAsync, ast, text, resultOptions);
|
|
13
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const process = require('node:process');
|
|
4
|
-
const tryCatch = require('try-catch');
|
|
5
|
-
const {createSyncFn} = require('synckit');
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
ignores,
|
|
9
|
-
print,
|
|
10
|
-
parse,
|
|
11
|
-
} = require('putout');
|
|
12
|
-
|
|
13
|
-
const parseOptions = require('putout/parse-options');
|
|
14
|
-
const {parseError} = require('../parse-error');
|
|
15
|
-
|
|
16
|
-
const cwd = process.cwd();
|
|
17
|
-
|
|
18
|
-
const findPlacesSync = createSyncFn(require.resolve('./find-places.mjs'));
|
|
19
|
-
const transformSync = createSyncFn(require.resolve('./transform.mjs'));
|
|
20
|
-
|
|
21
|
-
const EMPTY_VISITORS = {};
|
|
22
|
-
|
|
23
|
-
module.exports = ({context, options}) => {
|
|
24
|
-
const name = context.filename;
|
|
25
|
-
const resultOptions = parseOptions({
|
|
26
|
-
name,
|
|
27
|
-
options,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
if (ignores(cwd, name, resultOptions))
|
|
31
|
-
return EMPTY_VISITORS;
|
|
32
|
-
|
|
33
|
-
const source = context.sourceCode;
|
|
34
|
-
const {text} = source;
|
|
35
|
-
const node = source.ast;
|
|
36
|
-
|
|
37
|
-
const [errorParser, ast] = tryCatch(parse, text, {
|
|
38
|
-
isTS: true,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (errorParser) {
|
|
42
|
-
context.report({
|
|
43
|
-
message: `${parseError(errorParser)} (putout)`,
|
|
44
|
-
node,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return EMPTY_VISITORS;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const [error, places = []] = findPlacesSync({
|
|
51
|
-
name,
|
|
52
|
-
options,
|
|
53
|
-
ast,
|
|
54
|
-
text,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (error) {
|
|
58
|
-
context.report({
|
|
59
|
-
message: `${parseError(error)} (putout)`,
|
|
60
|
-
node,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return EMPTY_VISITORS;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const rules = getRules(places);
|
|
67
|
-
|
|
68
|
-
for (const {rule, message, position} of places) {
|
|
69
|
-
context.report({
|
|
70
|
-
message: `${message} (${rule})`,
|
|
71
|
-
fix: fix({
|
|
72
|
-
ast,
|
|
73
|
-
text,
|
|
74
|
-
name,
|
|
75
|
-
node,
|
|
76
|
-
source,
|
|
77
|
-
options,
|
|
78
|
-
rules,
|
|
79
|
-
}),
|
|
80
|
-
loc: {
|
|
81
|
-
start: position,
|
|
82
|
-
end: position,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return EMPTY_VISITORS;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const fix = ({name, ast, text, node, options, source, rules}) => (fixer) => {
|
|
91
|
-
const lastToken = source.getLastToken(node, {
|
|
92
|
-
includeComments: true,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
ast = transformSync({
|
|
96
|
-
name,
|
|
97
|
-
options,
|
|
98
|
-
ast,
|
|
99
|
-
text,
|
|
100
|
-
rules,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const [, last] = lastToken.range;
|
|
104
|
-
const code = print(ast);
|
|
105
|
-
|
|
106
|
-
return fixer.replaceTextRange([0, last], code);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
function getRules(places) {
|
|
110
|
-
const rules = [];
|
|
111
|
-
|
|
112
|
-
for (const {rule} of places) {
|
|
113
|
-
rules.push(rule);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return [...new Set(rules)];
|
|
117
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {transformAsync} from 'putout';
|
|
2
|
-
import {runAsWorker} from 'synckit';
|
|
3
|
-
import parseOptions from 'putout/parse-options';
|
|
4
|
-
|
|
5
|
-
runAsWorker(async ({name, options, ast, text}) => {
|
|
6
|
-
const resultOptions = parseOptions({
|
|
7
|
-
name,
|
|
8
|
-
options,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
await transformAsync(ast, text, resultOptions);
|
|
12
|
-
|
|
13
|
-
return ast;
|
|
14
|
-
});
|