@putout/eslint 1.3.0 → 1.4.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 +2 -1
- package/lib/eslint.js +1 -0
- package/lib/get-eslint.mjs +59 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
Wrapper that simplifies [**ESLint**](https://eslint.org/) API and makes it compatible with 🐊[**Putout**](https://github.com/coderaiser/putout).
|
|
7
7
|
|
|
8
|
+
☝️ *[FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/) supported from the box.*
|
|
9
|
+
|
|
8
10
|
## Install
|
|
9
11
|
|
|
10
12
|
```
|
|
@@ -165,7 +167,6 @@ When you want to skip plugins, and just provide `options` and `filename` you can
|
|
|
165
167
|
|
|
166
168
|
```js
|
|
167
169
|
const lint = require('@putout/eslint/lint');
|
|
168
|
-
const removeDebugger = require('./remove-debugger');
|
|
169
170
|
|
|
170
171
|
const [code, places] = lint('debugger', {
|
|
171
172
|
filename: 'index.js',
|
package/lib/eslint.js
CHANGED
package/lib/get-eslint.mjs
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
import {ESLint} from 'eslint';
|
|
2
|
+
import FlatESLintExports from 'eslint/use-at-your-own-risk';
|
|
3
|
+
import {findUpSync} from 'find-up';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
const {FlatESLint} = FlatESLintExports;
|
|
6
|
+
|
|
7
|
+
export const getESLint = ({name, fix, config, overrideConfigFile, ESLintOverride, find = findUpSync}) => {
|
|
8
|
+
const eslint = chooseESLint({
|
|
9
|
+
fix,
|
|
10
|
+
name,
|
|
11
|
+
config,
|
|
12
|
+
overrideConfigFile,
|
|
13
|
+
ESLintOverride,
|
|
14
|
+
find,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
calculateConfigForFile: eslint.calculateConfigForFile.bind(eslint),
|
|
19
|
+
lintText: eslint.lintText.bind(eslint),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function chooseESLint({name, config, fix, overrideConfigFile, ESLintOverride, find}) {
|
|
24
|
+
if (find('eslint.config.js'))
|
|
25
|
+
return getFlatESLint({
|
|
26
|
+
ESLintOverride,
|
|
27
|
+
name,
|
|
28
|
+
config,
|
|
29
|
+
overrideConfigFile,
|
|
30
|
+
fix,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return getOldESLint({
|
|
34
|
+
name,
|
|
35
|
+
config,
|
|
36
|
+
ESLintOverride,
|
|
37
|
+
overrideConfigFile,
|
|
38
|
+
fix,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getOldESLint({fix, config, overrideConfigFile, ESLintOverride = ESLint}) {
|
|
4
43
|
const eslint = new ESLintOverride({
|
|
5
44
|
fix,
|
|
6
45
|
overrideConfig: {
|
|
@@ -15,9 +54,23 @@ export const getESLint = ({fix, config, overrideConfigFile, ESLintOverride = ESL
|
|
|
15
54
|
},
|
|
16
55
|
});
|
|
17
56
|
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
57
|
+
return eslint;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getFlatESLint({fix, config, overrideConfigFile, ESLintOverride = FlatESLint}) {
|
|
61
|
+
const eslint = new ESLintOverride({
|
|
62
|
+
fix,
|
|
63
|
+
overrideConfig: {
|
|
64
|
+
ignores: [
|
|
65
|
+
'!.*',
|
|
66
|
+
],
|
|
67
|
+
...config,
|
|
68
|
+
},
|
|
69
|
+
...overrideConfigFile && {
|
|
70
|
+
overrideConfigFile,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return eslint;
|
|
75
|
+
}
|
|
23
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/eslint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"report": "madrun report"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"find-up": "^6.3.0",
|
|
33
34
|
"try-to-catch": "^3.0.1"
|
|
34
35
|
},
|
|
35
36
|
"keywords": [
|