@putout/eslint 1.7.0 → 1.9.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 +3 -4
- package/lib/create-plugin/index.js +24 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -13,14 +13,13 @@ Wrapper that simplifies [**ESLint**](https://eslint.org/) API and makes it compa
|
|
|
13
13
|
npm i @putout/eslint
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Environment Variables
|
|
17
17
|
|
|
18
18
|
- ☝️ To set custom config file for **ESLint** use `ESLINT_CONFIG_FILE` env variable:
|
|
19
19
|
- ☝️ To disable **ESLint** support use `NO_ESLINT=1` env variable:
|
|
20
20
|
- ☝️ If you want to ignore **ESLint** warnings (which is unfixable errors in 🐊**Putout** language) use `NO_ESLINT_WARNINGS=1`:
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
```sh
|
|
22
|
+
````sh
|
|
24
23
|
NO_ESLINT_WARNINGS=1 putout --fix lib
|
|
25
24
|
|
|
26
25
|
## API
|
|
@@ -31,7 +30,7 @@ NO_ESLINT_WARNINGS=1 putout --fix lib
|
|
|
31
30
|
|
|
32
31
|
```js
|
|
33
32
|
import eslint from '@putout/eslint';
|
|
34
|
-
|
|
33
|
+
````
|
|
35
34
|
|
|
36
35
|
To use it simply write:
|
|
37
36
|
|
|
@@ -108,6 +108,9 @@ const createGetSpacesBeforeNode = ({getText}) => (node, text = getText(node)) =>
|
|
|
108
108
|
let spaces = '';
|
|
109
109
|
let i = 0;
|
|
110
110
|
|
|
111
|
+
if (node === node.parent?.body?.[0].expression)
|
|
112
|
+
return '';
|
|
113
|
+
|
|
111
114
|
while (!spaces || /^[ \n]+$/.test(spaces))
|
|
112
115
|
spaces = getText(node, ++i)
|
|
113
116
|
.replace(text, '');
|
|
@@ -117,13 +120,33 @@ const createGetSpacesBeforeNode = ({getText}) => (node, text = getText(node)) =>
|
|
|
117
120
|
module.exports.createGetSpaceBeforeNode = createGetSpacesBeforeNode;
|
|
118
121
|
|
|
119
122
|
const createGetSpacesAfterNode = ({getText}) => (node, {text = getText(node)}) => {
|
|
123
|
+
const reg = /^[ \n;]+$/;
|
|
124
|
+
|
|
125
|
+
if (isLastNodeInBody(node))
|
|
126
|
+
return '';
|
|
127
|
+
|
|
120
128
|
let spaces = '';
|
|
121
129
|
let i = 0;
|
|
122
130
|
|
|
123
|
-
while (!spaces ||
|
|
131
|
+
while (!spaces || reg.test(spaces))
|
|
124
132
|
spaces = getText(node, 0, ++i)
|
|
125
133
|
.replace(text, '');
|
|
126
134
|
|
|
127
135
|
return spaces.slice(0, -1);
|
|
128
136
|
};
|
|
137
|
+
|
|
129
138
|
module.exports.createGetSpacesAfterNode = createGetSpacesAfterNode;
|
|
139
|
+
|
|
140
|
+
function isLastNodeInBody(node) {
|
|
141
|
+
if (node.parent.body) {
|
|
142
|
+
const {length} = node.parent.body;
|
|
143
|
+
const n = length - 1;
|
|
144
|
+
|
|
145
|
+
if (node === node.parent?.body?.[n]) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/eslint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Wrapper that simplifies ESLint API and makes it compatible with 🐊Putout",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint#readme",
|
|
8
8
|
"main": "./lib/eslint.js",
|
|
9
|
-
"commitType": "colon",
|
|
10
9
|
"release": false,
|
|
11
10
|
"tag": false,
|
|
12
11
|
"changelog": false,
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
"c8": "^7.5.0",
|
|
42
41
|
"eslint": "^8.0.1",
|
|
43
42
|
"eslint-plugin-n": "^15.2.4",
|
|
44
|
-
"eslint-plugin-putout": "^
|
|
43
|
+
"eslint-plugin-putout": "^17.0.0",
|
|
45
44
|
"just-camel-case": "^4.0.2",
|
|
46
45
|
"lerna": "^6.0.1",
|
|
47
46
|
"madrun": "^9.0.0",
|