@putout/eslint 2.2.0 → 2.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 -6
- package/lib/create-plugin/index.js +11 -12
- package/lib/eslint.js +2 -4
- package/lib/get-eslint.mjs +5 -10
- package/lib/lint/index.js +1 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -55,9 +55,7 @@ const [source, places] = await eslint({
|
|
|
55
55
|
code: `const t = 'hi'\n`,
|
|
56
56
|
fix: false,
|
|
57
57
|
config: {
|
|
58
|
-
extends: [
|
|
59
|
-
'plugin:putout/recommended',
|
|
60
|
-
],
|
|
58
|
+
extends: ['plugin:putout/recommended'],
|
|
61
59
|
},
|
|
62
60
|
});
|
|
63
61
|
```
|
|
@@ -71,9 +69,7 @@ const [source, places] = await eslint({
|
|
|
71
69
|
fix: true,
|
|
72
70
|
putout: true,
|
|
73
71
|
config: {
|
|
74
|
-
extends: [
|
|
75
|
-
'plugin:putout/recommended',
|
|
76
|
-
],
|
|
72
|
+
extends: ['plugin:putout/recommended'],
|
|
77
73
|
},
|
|
78
74
|
});
|
|
79
75
|
```
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const prepare = (plugin, context, options) => (node) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} = plugin;
|
|
4
|
+
const {filter, report} = plugin;
|
|
5
|
+
|
|
6
|
+
const {sourceCode, filename} = context;
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const getCommentsAfter = source.getCommentsAfter.bind(source);
|
|
14
|
-
const getCommentsInside = source.getCommentsInside.bind(source);
|
|
8
|
+
const getText = sourceCode.getText.bind(sourceCode);
|
|
9
|
+
const getCommentsBefore = sourceCode.getCommentsBefore.bind(sourceCode);
|
|
10
|
+
const getCommentsAfter = sourceCode.getCommentsAfter.bind(sourceCode);
|
|
11
|
+
const getCommentsInside = sourceCode.getCommentsInside.bind(sourceCode);
|
|
15
12
|
|
|
16
13
|
const getSpacesBeforeNode = createGetSpacesBeforeNode({
|
|
17
14
|
getText,
|
|
@@ -23,7 +20,7 @@ const prepare = (plugin, context, options) => (node) => {
|
|
|
23
20
|
|
|
24
21
|
const text = getText(node);
|
|
25
22
|
|
|
26
|
-
const
|
|
23
|
+
const path = {
|
|
27
24
|
text,
|
|
28
25
|
node,
|
|
29
26
|
options,
|
|
@@ -34,7 +31,9 @@ const prepare = (plugin, context, options) => (node) => {
|
|
|
34
31
|
getSpacesBeforeNode,
|
|
35
32
|
getSpacesAfterNode,
|
|
36
33
|
filename,
|
|
37
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const result = filter(path, options);
|
|
38
37
|
|
|
39
38
|
if (!result)
|
|
40
39
|
return;
|
package/lib/eslint.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const process = require('process');
|
|
3
4
|
const {simpleImport} = require('./simple-import.js');
|
|
4
5
|
const tryToCatch = require('try-to-catch');
|
|
5
6
|
|
|
@@ -18,10 +19,7 @@ const noConfigFound = (config, configError) => {
|
|
|
18
19
|
if (configError)
|
|
19
20
|
return false;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
return true;
|
|
23
|
-
|
|
24
|
-
return false;
|
|
22
|
+
return !keys(config.rules).length;
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
const cutNewLine = ({message}) => ({
|
package/lib/get-eslint.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import FlatESLintExports from 'eslint/use-at-your-own-risk';
|
|
1
|
+
import eslint from 'eslint/use-at-your-own-risk';
|
|
3
2
|
import {findUpSync} from 'find-up';
|
|
4
3
|
|
|
5
|
-
const {FlatESLint} =
|
|
4
|
+
const {FlatESLint, LegacyESLint} = eslint;
|
|
6
5
|
|
|
7
6
|
export const getESLint = ({name, fix, config, overrideConfigFile, ESLintOverride, find = findUpSync}) => {
|
|
8
7
|
const eslint = chooseESLint({
|
|
@@ -41,13 +40,11 @@ function chooseESLint({name, config, fix, overrideConfigFile, ESLintOverride, fi
|
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
function getOldESLint({fix, config, overrideConfigFile, ESLintOverride =
|
|
43
|
+
function getOldESLint({fix, config, overrideConfigFile, ESLintOverride = LegacyESLint}) {
|
|
45
44
|
const eslint = new ESLintOverride({
|
|
46
45
|
fix,
|
|
47
46
|
overrideConfig: {
|
|
48
|
-
ignorePatterns: [
|
|
49
|
-
'!.*',
|
|
50
|
-
],
|
|
47
|
+
ignorePatterns: ['!.*'],
|
|
51
48
|
...config,
|
|
52
49
|
},
|
|
53
50
|
...overrideConfigFile && {
|
|
@@ -63,9 +60,7 @@ function getFlatESLint({fix, config, overrideConfigFile, ESLintOverride = FlatES
|
|
|
63
60
|
const eslint = new ESLintOverride({
|
|
64
61
|
fix,
|
|
65
62
|
overrideConfig: {
|
|
66
|
-
ignores: [
|
|
67
|
-
'!.*',
|
|
68
|
-
],
|
|
63
|
+
ignores: ['!.*'],
|
|
69
64
|
...config,
|
|
70
65
|
},
|
|
71
66
|
...overrideConfigFile && {
|
package/lib/lint/index.js
CHANGED
|
@@ -42,10 +42,7 @@ module.exports.lint = (source, {fix = true, plugins, filename, options = []}) =>
|
|
|
42
42
|
return [source, places];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const {
|
|
46
|
-
output,
|
|
47
|
-
messages,
|
|
48
|
-
} = linter.verifyAndFix(source, allOptions, mainOptions);
|
|
45
|
+
const {output, messages} = linter.verifyAndFix(source, allOptions, mainOptions);
|
|
49
46
|
|
|
50
47
|
return [output, messages.map(convertToPlace)];
|
|
51
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/eslint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.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",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@putout/plugin-eslint-plugin": "*",
|
|
41
|
-
"c8": "^
|
|
42
|
-
"eslint": "^8.0
|
|
41
|
+
"c8": "^8.0.0",
|
|
42
|
+
"eslint": "^8.45.0",
|
|
43
43
|
"eslint-plugin-n": "^16.0.0",
|
|
44
|
-
"eslint-plugin-putout": "^
|
|
44
|
+
"eslint-plugin-putout": "^20.0.0",
|
|
45
45
|
"just-camel-case": "^4.0.2",
|
|
46
46
|
"lerna": "^6.0.1",
|
|
47
47
|
"madrun": "^9.0.0",
|
|
48
48
|
"mock-require": "^3.0.3",
|
|
49
49
|
"montag": "^1.0.0",
|
|
50
|
-
"nodemon": "^
|
|
50
|
+
"nodemon": "^3.0.1",
|
|
51
51
|
"putout": "*",
|
|
52
52
|
"supertape": "^8.0.0",
|
|
53
53
|
"try-catch": "^3.0.0"
|