eslint-plugin-putout 17.5.1 → 17.6.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/lib/putout/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const parseOptions = require('putout/parse-options');
|
|
|
14
14
|
const {parseError} = require('./parse-error');
|
|
15
15
|
|
|
16
16
|
const cwd = process.cwd();
|
|
17
|
+
|
|
17
18
|
const getContextOptions = ({options}) => {
|
|
18
19
|
const [allContextOptions = {}] = options;
|
|
19
20
|
return allContextOptions;
|
|
@@ -34,8 +35,9 @@ module.exports = {
|
|
|
34
35
|
},
|
|
35
36
|
|
|
36
37
|
create(context) {
|
|
37
|
-
const name = context.
|
|
38
|
+
const name = context.filename;
|
|
38
39
|
const options = getContextOptions(context);
|
|
40
|
+
|
|
39
41
|
const resultOptions = parseOptions({
|
|
40
42
|
name,
|
|
41
43
|
options,
|
|
@@ -44,7 +46,7 @@ module.exports = {
|
|
|
44
46
|
if (ignores(cwd, name, resultOptions))
|
|
45
47
|
return EMPTY_VISITORS;
|
|
46
48
|
|
|
47
|
-
const source = context.
|
|
49
|
+
const source = context.sourceCode;
|
|
48
50
|
const {text} = source;
|
|
49
51
|
const node = source.ast;
|
|
50
52
|
|
|
@@ -95,6 +97,7 @@ module.exports = {
|
|
|
95
97
|
|
|
96
98
|
const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
|
|
97
99
|
const includeComments = true;
|
|
100
|
+
|
|
98
101
|
const lastToken = source.getLastToken(node, {
|
|
99
102
|
includeComments,
|
|
100
103
|
});
|
|
@@ -107,4 +110,3 @@ const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
|
|
|
107
110
|
|
|
108
111
|
return fixer.replaceTextRange([0, last], code);
|
|
109
112
|
};
|
|
110
|
-
|
|
@@ -28,9 +28,11 @@ module.exports = {
|
|
|
28
28
|
create(context) {
|
|
29
29
|
return {
|
|
30
30
|
ImportDeclaration(node) {
|
|
31
|
-
const source = context.
|
|
31
|
+
const source = context.sourceCode;
|
|
32
32
|
const text = source.getText(node);
|
|
33
|
-
const newline = source
|
|
33
|
+
const newline = source
|
|
34
|
+
.getText(node, 0, 2)
|
|
35
|
+
.replace(text, '');
|
|
34
36
|
|
|
35
37
|
if (node.specifiers.length > 1)
|
|
36
38
|
return;
|
|
@@ -57,7 +59,10 @@ module.exports = {
|
|
|
57
59
|
|
|
58
60
|
fix(fixer) {
|
|
59
61
|
return [
|
|
60
|
-
fixer.removeRange([
|
|
62
|
+
fixer.removeRange([
|
|
63
|
+
node.range[1],
|
|
64
|
+
node.range[1] + 1,
|
|
65
|
+
]),
|
|
61
66
|
];
|
|
62
67
|
},
|
|
63
68
|
});
|
|
@@ -16,9 +16,11 @@ module.exports = {
|
|
|
16
16
|
create(context) {
|
|
17
17
|
return {
|
|
18
18
|
VariableDeclaration(node) {
|
|
19
|
-
const source = context.
|
|
19
|
+
const source = context.sourceCode;
|
|
20
20
|
const text = source.getText(node);
|
|
21
|
-
const newline = source
|
|
21
|
+
const newline = source
|
|
22
|
+
.getText(node, 0, 2)
|
|
23
|
+
.replace(text, '');
|
|
22
24
|
|
|
23
25
|
if (newline !== '\n\n')
|
|
24
26
|
return;
|
|
@@ -50,7 +52,10 @@ module.exports = {
|
|
|
50
52
|
|
|
51
53
|
fix(fixer) {
|
|
52
54
|
return [
|
|
53
|
-
fixer.removeRange([
|
|
55
|
+
fixer.removeRange([
|
|
56
|
+
node.range[1],
|
|
57
|
+
node.range[1] + 1,
|
|
58
|
+
]),
|
|
54
59
|
];
|
|
55
60
|
},
|
|
56
61
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/plugin-syntax-typescript": "^7.12.1",
|
|
59
|
+
"@putout/plugin-eslint-plugin": "*",
|
|
59
60
|
"@putout/test": "^6.0.0",
|
|
60
61
|
"c8": "^7.5.0",
|
|
61
62
|
"eslint": "^8.0.1",
|