eslint-plugin-putout 12.7.1 → 12.9.2
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 +4 -1
- package/lib/add-newline-after-function-call/index.js +1 -1
- package/lib/common.js +2 -10
- package/lib/function-declaration-paren-newline/index.js +1 -3
- package/lib/newline-function-call-arguments/README.md +2 -2
- package/lib/newline-function-call-arguments/index.js +3 -0
- package/lib/no-unresolved/README.md +8 -0
- package/lib/no-unresolved/index.js +7 -3
- package/lib/putout/index.js +10 -1
- package/lib/putout/parse-error.js +8 -0
- package/lib/ts.js +3 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -101,9 +101,12 @@ When using 🐊`Putout` in IDE with `--fix` on save, or when you want to disable
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
Disabled `ESLint` rules:
|
|
105
105
|
|
|
106
106
|
- [no-useless-return](https://eslint.org/docs/rules/no-useless-return)
|
|
107
|
+
|
|
108
|
+
Disabled 🐊`Putout` rules:
|
|
109
|
+
|
|
107
110
|
- [remove-empty](https://github.com/coderaiser/putout/tree/v22.0.0/packages/plugin-remove-empty);
|
|
108
111
|
- [remove-unused-variables](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-variables);
|
|
109
112
|
- [remove-unused-types](https://github.com/coderaiser/putout/tree/v22.0.0/packages/remove-unused-types);
|
package/lib/common.js
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
const {isImportDefaultSpecifier} = require('putout').types;
|
|
4
4
|
|
|
5
5
|
module.exports.isCorrectLoc = (line, properties) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < n; i++) {
|
|
9
|
-
const prop = properties[i];
|
|
10
|
-
|
|
6
|
+
for (const [i, prop] of properties.entries()) {
|
|
11
7
|
if (prop.loc.start.line < i + line + 1)
|
|
12
8
|
return false;
|
|
13
9
|
}
|
|
@@ -16,14 +12,10 @@ module.exports.isCorrectLoc = (line, properties) => {
|
|
|
16
12
|
};
|
|
17
13
|
|
|
18
14
|
module.exports.isCorrectImportLoc = (line, specifiers) => {
|
|
19
|
-
const n = specifiers.length;
|
|
20
|
-
|
|
21
15
|
if (!isImportDefaultSpecifier(specifiers[0]))
|
|
22
16
|
++line;
|
|
23
17
|
|
|
24
|
-
for (
|
|
25
|
-
const spec = specifiers[i];
|
|
26
|
-
|
|
18
|
+
for (const [i, spec] of specifiers.entries()) {
|
|
27
19
|
if (spec.loc.start.line < i + line)
|
|
28
20
|
return false;
|
|
29
21
|
}
|
|
@@ -10,9 +10,7 @@ module.exports.report = () => {
|
|
|
10
10
|
return `Unexpected new lines around arguments`;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
module.exports.fix = ({text}) =>
|
|
14
|
-
return fixNewLines(text);
|
|
15
|
-
};
|
|
13
|
+
module.exports.fix = ({text}) => fixNewLines(text);
|
|
16
14
|
|
|
17
15
|
module.exports.include = () => [
|
|
18
16
|
'FunctionDeclaration',
|
|
@@ -9,7 +9,7 @@ This rule aims to fix eslint transform.
|
|
|
9
9
|
Examples of **incorrect** code for this rule:
|
|
10
10
|
|
|
11
11
|
```js
|
|
12
|
-
const onConnectError = squad(superFn(
|
|
12
|
+
const onConnectError = squad(superFn(connect_error),
|
|
13
13
|
logWraped(isLog, importStr),
|
|
14
14
|
addUrl(colorUrl),
|
|
15
15
|
getDescription);
|
|
@@ -19,7 +19,7 @@ Examples of **correct** code for this rule:
|
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
21
|
const onConnectError = squad(
|
|
22
|
-
superFn(
|
|
22
|
+
superFn(connect_error),
|
|
23
23
|
logWraped(isLog, importStr),
|
|
24
24
|
addUrl(colorUrl),
|
|
25
25
|
getDescription,
|
|
@@ -12,6 +12,10 @@ Examples of **incorrect** code for this rule:
|
|
|
12
12
|
```js
|
|
13
13
|
import x from './y';
|
|
14
14
|
import dir from './dir';
|
|
15
|
+
|
|
16
|
+
export * from './y';
|
|
17
|
+
export * as dir from './dir';
|
|
18
|
+
export {m} from './y';
|
|
15
19
|
```
|
|
16
20
|
|
|
17
21
|
[File extension is mandatory](https://nodejs.org/api/esm.html#esm_mandatory_file_extensions) and will produce an error from `node.js`:
|
|
@@ -26,4 +30,8 @@ Examples of **correct** code for this rule:
|
|
|
26
30
|
```js
|
|
27
31
|
import x from './y.js';
|
|
28
32
|
import dir from './dir/index.js';
|
|
33
|
+
|
|
34
|
+
export * from './y.js';
|
|
35
|
+
export * as dir from './dir/index.js';
|
|
36
|
+
export {m} from './y.js';
|
|
29
37
|
```
|
|
@@ -18,13 +18,17 @@ const isRelativeEnd = (a) => RegExp(`${RELATIVE}$`).test(a);
|
|
|
18
18
|
const getDir = (a) => a === '<input>' ? cwd : dirname(a);
|
|
19
19
|
const getValue = (node) => {
|
|
20
20
|
const {source} = node;
|
|
21
|
-
|
|
22
|
-
return value;
|
|
21
|
+
return source?.value;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
module.exports.category = 'errors';
|
|
26
25
|
module.exports.report = () => 'Always add an extension to relative imports';
|
|
27
|
-
module.exports.include = () => [
|
|
26
|
+
module.exports.include = () => [
|
|
27
|
+
'ImportDeclaration',
|
|
28
|
+
'ImportExpression',
|
|
29
|
+
'ExportAllDeclaration',
|
|
30
|
+
'ExportNamedDeclaration',
|
|
31
|
+
];
|
|
28
32
|
|
|
29
33
|
module.exports.fix = ({node, text, filename}) => {
|
|
30
34
|
const value = getValue(node);
|
package/lib/putout/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const tryCatch = require('try-catch');
|
|
4
|
+
|
|
3
5
|
const {
|
|
4
6
|
ignores,
|
|
5
7
|
findPlaces,
|
|
@@ -13,6 +15,7 @@ const traverse = require('@babel/traverse').default;
|
|
|
13
15
|
const v8 = require('v8');
|
|
14
16
|
|
|
15
17
|
const parseOptions = require('putout/parse-options');
|
|
18
|
+
const {parseError} = require('./parse-error');
|
|
16
19
|
|
|
17
20
|
const cwd = process.cwd();
|
|
18
21
|
const getContextOptions = ({options}) => {
|
|
@@ -55,7 +58,13 @@ module.exports = {
|
|
|
55
58
|
parser: createParser(node),
|
|
56
59
|
});
|
|
57
60
|
|
|
58
|
-
const places = findPlaces
|
|
61
|
+
const [error, places = []] = tryCatch(findPlaces, ast, text, resultOptions);
|
|
62
|
+
|
|
63
|
+
if (error)
|
|
64
|
+
context.report({
|
|
65
|
+
message: `${parseError(error)} (putout)`,
|
|
66
|
+
node,
|
|
67
|
+
});
|
|
59
68
|
|
|
60
69
|
for (const {rule, message, position} of places) {
|
|
61
70
|
context.report({
|
package/lib/ts.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.2",
|
|
4
|
+
"type": "commonjs",
|
|
4
5
|
"description": "eslint plugin for putout",
|
|
5
6
|
"release": false,
|
|
6
7
|
"tag": false,
|
|
7
|
-
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout",
|
|
8
|
+
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme",
|
|
8
9
|
"changelog": false,
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|