@putout/eslint 1.6.0 → 1.8.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 +10 -1
- package/lib/create-plugin/index.js +3 -0
- package/lib/eslint.js +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,15 @@ Wrapper that simplifies [**ESLint**](https://eslint.org/) API and makes it compa
|
|
|
13
13
|
npm i @putout/eslint
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Environment Variables
|
|
17
|
+
|
|
18
|
+
- ☝️ To set custom config file for **ESLint** use `ESLINT_CONFIG_FILE` env variable:
|
|
19
|
+
- ☝️ To disable **ESLint** support use `NO_ESLINT=1` env variable:
|
|
20
|
+
- ☝️ If you want to ignore **ESLint** warnings (which is unfixable errors in 🐊**Putout** language) use `NO_ESLINT_WARNINGS=1`:
|
|
21
|
+
|
|
22
|
+
````sh
|
|
23
|
+
NO_ESLINT_WARNINGS=1 putout --fix lib
|
|
24
|
+
|
|
16
25
|
## API
|
|
17
26
|
|
|
18
27
|
### `eslint(options)`
|
|
@@ -21,7 +30,7 @@ npm i @putout/eslint
|
|
|
21
30
|
|
|
22
31
|
```js
|
|
23
32
|
import eslint from '@putout/eslint';
|
|
24
|
-
|
|
33
|
+
````
|
|
25
34
|
|
|
26
35
|
To use it simply write:
|
|
27
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, '');
|
package/lib/eslint.js
CHANGED
|
@@ -7,6 +7,9 @@ const {keys} = Object;
|
|
|
7
7
|
const eslintId = ' (eslint)';
|
|
8
8
|
const overrideConfigFile = process.env.ESLINT_CONFIG_FILE;
|
|
9
9
|
const noESLint = process.env.NO_ESLINT;
|
|
10
|
+
const noESLintWarnings = process.env.NO_ESLINT_WARNINGS;
|
|
11
|
+
|
|
12
|
+
const WARNING = 1;
|
|
10
13
|
|
|
11
14
|
const noConfigFound = (config, configError) => {
|
|
12
15
|
if (configError && configError.messageTemplate === 'no-config-found')
|
|
@@ -78,7 +81,9 @@ module.exports = async ({name, code, fix, config, putout = false}) => {
|
|
|
78
81
|
|
|
79
82
|
const [report] = results;
|
|
80
83
|
const {output} = report;
|
|
81
|
-
const places = report.messages
|
|
84
|
+
const places = report.messages
|
|
85
|
+
.map(convertToPlace)
|
|
86
|
+
.filter(Boolean);
|
|
82
87
|
|
|
83
88
|
return [
|
|
84
89
|
output || code,
|
|
@@ -91,9 +96,12 @@ module.exports._noConfigFound = noConfigFound;
|
|
|
91
96
|
const parseRule = (rule) => rule || 'parser';
|
|
92
97
|
|
|
93
98
|
module.exports.convertToPlace = convertToPlace;
|
|
94
|
-
function convertToPlace({ruleId = 'parser', message, line = 0, column = 0}) {
|
|
99
|
+
function convertToPlace({ruleId = 'parser', message, line = 0, column = 0, severity}) {
|
|
95
100
|
const rule = `${parseRule(ruleId)}${eslintId}`;
|
|
96
101
|
|
|
102
|
+
if (severity === WARNING && noESLintWarnings)
|
|
103
|
+
return null;
|
|
104
|
+
|
|
97
105
|
return {
|
|
98
106
|
rule,
|
|
99
107
|
message: replaceControlChars(message),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/eslint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.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",
|