eslint-plugin-putout 25.1.2 → 26.0.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/README.md +0 -10
- package/lib/index.mjs +3 -15
- package/lib/json.mjs +10 -0
- package/lib/putout/index.js +0 -10
- package/lib/putout/parse-error.js +1 -1
- package/package.json +3 -3
- 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,11 +104,11 @@ 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
|
},
|
|
111
|
-
}
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
112
|
|
|
113
113
|
export const safeAlign = [
|
|
114
114
|
...n,
|
|
@@ -117,26 +117,14 @@ export const safeAlign = [
|
|
|
117
117
|
...safe.rules,
|
|
118
118
|
'putout/align-spaces': 'error',
|
|
119
119
|
},
|
|
120
|
-
}];
|
|
121
|
-
|
|
122
|
-
export const esm = {
|
|
123
|
-
...n,
|
|
124
|
-
...safeAlign,
|
|
125
|
-
rules: {
|
|
126
|
-
...safeAlign.rules,
|
|
127
|
-
'putout/putout': ['error', {
|
|
128
|
-
esm: true,
|
|
129
|
-
rules: safeRules,
|
|
130
|
-
}],
|
|
131
120
|
},
|
|
132
|
-
|
|
121
|
+
];
|
|
133
122
|
|
|
134
123
|
export const configs = {
|
|
135
124
|
recommended,
|
|
136
125
|
jsx,
|
|
137
126
|
safe,
|
|
138
127
|
safeAlign,
|
|
139
|
-
esm,
|
|
140
128
|
};
|
|
141
129
|
|
|
142
130
|
export const {rules} = putout;
|
package/lib/json.mjs
CHANGED
|
@@ -56,4 +56,14 @@ export default [{
|
|
|
56
56
|
'@stylistic/js/indent': 'off',
|
|
57
57
|
'comma-spacing': 'off',
|
|
58
58
|
},
|
|
59
|
+
}, {
|
|
60
|
+
name: 'putout: json: filesystem',
|
|
61
|
+
files: ['**/.filesystem.json'],
|
|
62
|
+
plugins: {
|
|
63
|
+
'@stylistic': stylisticJs,
|
|
64
|
+
putout,
|
|
65
|
+
},
|
|
66
|
+
rules: {
|
|
67
|
+
'putout/objects-braces-inside-array': 'off',
|
|
68
|
+
},
|
|
59
69
|
}];
|
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.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -75,11 +75,11 @@
|
|
|
75
75
|
"supertape": "^10.0.0"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
|
-
"node": ">=
|
|
78
|
+
"node": ">=20"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"eslint": ">=9",
|
|
82
|
-
"putout": ">=
|
|
82
|
+
"putout": ">=39"
|
|
83
83
|
},
|
|
84
84
|
"license": "MIT",
|
|
85
85
|
"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
|
-
});
|