eslint-plugin-putout 29.3.0 → 30.0.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 +0 -1
- package/eslint-v10/babel.js +5 -7
- package/eslint-v10/ts.js +5 -6
- package/lib/add-newline-after-function-call/index.js +6 -7
- package/lib/add-newline-before-function-call/index.js +5 -6
- package/lib/add-newline-before-return/index.js +4 -6
- package/lib/add-newlines-between-specifiers/index.js +5 -7
- package/lib/add-newlines-between-types-in-union/index.js +6 -7
- package/lib/align-spaces/index.js +5 -6
- package/lib/array-element-newline/index.js +6 -7
- package/lib/common.js +4 -4
- package/lib/destructuring-as-function-argument/index.js +5 -7
- package/lib/evaluate/index.js +10 -8
- package/lib/for-of-multiple-properties-destructuring/index.js +5 -7
- package/lib/function-declaration-paren-newline/index.js +4 -6
- package/lib/{index.mjs → index.js} +6 -7
- package/lib/{json.mjs → json.js} +1 -1
- package/lib/long-properties-destructuring/index.js +7 -8
- package/lib/{markdown.mjs → markdown.js} +2 -2
- package/lib/multiple-properties-destructuring/index.js +11 -12
- package/lib/newline-function-call-arguments/index.js +4 -6
- package/lib/nonblock-statement-body-newline/index.js +5 -6
- package/lib/object-property-newline/index.js +7 -9
- package/lib/objects-braces-inside-array/index.js +7 -7
- package/lib/plugin.js +68 -0
- package/lib/putout/index.js +4 -4
- package/lib/putout/parse-error.js +1 -3
- package/lib/remove-duplicate-extensions/index.js +5 -7
- package/lib/remove-empty-newline-after-import/index.js +2 -3
- package/lib/remove-empty-newline-after-last-element/index.js +5 -7
- package/lib/remove-empty-newline-after-last-specifier/index.js +5 -7
- package/lib/remove-empty-newline-before-first-specifier/index.js +5 -7
- package/lib/remove-empty-newline-between-declarations/index.js +3 -3
- package/lib/remove-empty-specifiers/index.js +5 -7
- package/lib/remove-newline-after-default-import/index.js +5 -7
- package/lib/remove-newline-from-empty-object/index.js +6 -7
- package/lib/single-property-destructuring/index.js +6 -8
- package/lib/tape-add-newline-before-assertion/index.js +5 -7
- package/lib/tape-add-newline-between-tests/index.js +5 -7
- package/lib/tape-remove-newline-before-t-end/index.js +6 -8
- package/lib/{ts.mjs → ts.js} +2 -2
- package/package.json +6 -10
- package/lib/no-unresolved/index.js +0 -81
- package/lib/plugin.mjs +0 -47
- /package/lib/{html.mjs → html.js} +0 -0
- /package/lib/{jsx.mjs → jsx.js} +0 -0
- /package/lib/putout/{sync.mjs → sync.js} +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {types} = require('putout');
|
|
4
|
-
const {isCorrectLoc} = require('../common');
|
|
1
|
+
import {types} from 'putout';
|
|
2
|
+
import {isCorrectLoc} from '../common.js';
|
|
5
3
|
|
|
6
4
|
const {
|
|
7
5
|
isVariableDeclarator,
|
|
@@ -9,17 +7,17 @@ const {
|
|
|
9
7
|
isTSTypeAliasDeclaration,
|
|
10
8
|
} = types;
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export const category = 'destructuring';
|
|
11
|
+
export const report = () => 'Keep each property on separate line';
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
export const include = () => [
|
|
16
14
|
`VariableDeclarator[init.type="ObjectExpression"]`,
|
|
17
15
|
`AssignmentExpression[right.type="ObjectExpression"]`,
|
|
18
16
|
`TSTypeAliasDeclaration[typeAnnotation.type="TSTypeLiteral"]`,
|
|
19
17
|
`TSInterfaceDeclaration`,
|
|
20
18
|
];
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
export const filter = ({node}) => {
|
|
23
21
|
const {loc, right} = node;
|
|
24
22
|
|
|
25
23
|
if (isVariableDeclarator(node)) {
|
|
@@ -50,7 +48,7 @@ module.exports.filter = ({node}) => {
|
|
|
50
48
|
return !isCorrectLoc(line, body);
|
|
51
49
|
};
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
export const fix = ({text}) => {
|
|
54
52
|
return text
|
|
55
53
|
.replace(/,(\s+)?/g, ',\n ')
|
|
56
54
|
.replace(/{/g, '{\n ')
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {isObjectExpression} =
|
|
3
|
+
const {isObjectExpression} = types;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export const category = 'destructuring';
|
|
6
|
+
export const report = () => 'Keep braces on the same line with brackets';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export const include = () => [
|
|
9
9
|
'ArrayExpression',
|
|
10
10
|
];
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ const badStart = /^\[\n(\s+)?{/;
|
|
|
13
13
|
const badEndReg = /},?\n(\s+)?]/;
|
|
14
14
|
const badMiddle = /\},\n(\s+)?\{/;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
export const filter = ({node, text}) => {
|
|
17
17
|
const {elements} = node;
|
|
18
18
|
|
|
19
19
|
for (const element of elements) {
|
|
@@ -28,7 +28,7 @@ module.exports.filter = ({node, text}) => {
|
|
|
28
28
|
return isStart || isEnd || isBadMiddle;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
export const fix = ({text}) => {
|
|
32
32
|
return text
|
|
33
33
|
.replace('[\n', '[')
|
|
34
34
|
.replace(/\[\s+{/, '[{')
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {createPlugin} from '@putout/eslint/create-plugin';
|
|
2
|
+
import * as arrayElementNewline from './array-element-newline/index.js';
|
|
3
|
+
import * as singlePropertyDestructuring from './single-property-destructuring/index.js';
|
|
4
|
+
import * as multiplePropertiesDestructuring from './multiple-properties-destructuring/index.js';
|
|
5
|
+
import * as forOfMultiplePropertiesDestructuring from './for-of-multiple-properties-destructuring/index.js';
|
|
6
|
+
import * as longPropertiesDestructuring from './long-properties-destructuring/index.js';
|
|
7
|
+
import * as destructuringAsFunctionArgument from './destructuring-as-function-argument/index.js';
|
|
8
|
+
import * as alignSpaces from './align-spaces/index.js';
|
|
9
|
+
import * as newlineFunctionCallArguments from './newline-function-call-arguments/index.js';
|
|
10
|
+
import * as functionDeclarationParenNewline from './function-declaration-paren-newline/index.js';
|
|
11
|
+
import * as addNewlinesBetweenTypesInUnion from './add-newlines-between-types-in-union/index.js';
|
|
12
|
+
import * as addNewlinesBetweenSpecifiers from './add-newlines-between-specifiers/index.js';
|
|
13
|
+
import * as addNewlineBeforeReturn from './add-newline-before-return/index.js';
|
|
14
|
+
import * as addNewlineBeforeFunctionCall from './add-newline-before-function-call/index.js';
|
|
15
|
+
import * as addNewlineAfterFunctionCall from './add-newline-after-function-call/index.js';
|
|
16
|
+
import * as removeNewlineAfterDefaultImport from './remove-newline-after-default-import/index.js';
|
|
17
|
+
import * as removeNewlineFromEmptyObject from './remove-newline-from-empty-object/index.js';
|
|
18
|
+
import * as removeEmptyNewlineBeforeFirstSpecifier from './remove-empty-newline-before-first-specifier/index.js';
|
|
19
|
+
import * as removeEmptyNewlineAfterLastSpecifier from './remove-empty-newline-after-last-specifier/index.js';
|
|
20
|
+
import * as removeEmptyNewlineAfterLastElement from './remove-empty-newline-after-last-element/index.js';
|
|
21
|
+
import * as removeEmptySpecifiers from './remove-empty-specifiers/index.js';
|
|
22
|
+
import * as objectsBracesInsideArray from './objects-braces-inside-array/index.js';
|
|
23
|
+
import * as objectPropertyNewline from './object-property-newline/index.js';
|
|
24
|
+
import * as removeDuplicateExtensions from './remove-duplicate-extensions/index.js';
|
|
25
|
+
import * as evaluate from './evaluate/index.js';
|
|
26
|
+
import * as tapeAddNewlineBeforeAssertion from './tape-add-newline-before-assertion/index.js';
|
|
27
|
+
import * as tapeAddNewlineBetweenTests from './tape-add-newline-between-tests/index.js';
|
|
28
|
+
import * as tapeRemoveNewlineBeforeTEnd from './tape-remove-newline-before-t-end/index.js';
|
|
29
|
+
import * as nonblockStatementBodyNewline from './nonblock-statement-body-newline/index.js';
|
|
30
|
+
import putout from './putout/index.js';
|
|
31
|
+
import removeEmptyNewlineAfterImport from './remove-empty-newline-after-import/index.js';
|
|
32
|
+
import removeEmptyNewlineBetweenDeclarations from './remove-empty-newline-between-declarations/index.js';
|
|
33
|
+
|
|
34
|
+
export const rules = {
|
|
35
|
+
'putout': putout,
|
|
36
|
+
'remove-empty-newline-after-import': removeEmptyNewlineAfterImport,
|
|
37
|
+
'remove-empty-newline-between-declarations': removeEmptyNewlineBetweenDeclarations,
|
|
38
|
+
|
|
39
|
+
'function-declaration-paren-newline': createPlugin(functionDeclarationParenNewline),
|
|
40
|
+
'array-element-newline': createPlugin(arrayElementNewline),
|
|
41
|
+
'single-property-destructuring': createPlugin(singlePropertyDestructuring),
|
|
42
|
+
'multiple-properties-destructuring': createPlugin(multiplePropertiesDestructuring),
|
|
43
|
+
'for-of-multiple-properties-destructuring': createPlugin(forOfMultiplePropertiesDestructuring),
|
|
44
|
+
'long-properties-destructuring': createPlugin(longPropertiesDestructuring),
|
|
45
|
+
'destructuring-as-function-argument': createPlugin(destructuringAsFunctionArgument),
|
|
46
|
+
'align-spaces': createPlugin(alignSpaces),
|
|
47
|
+
'newline-function-call-arguments': createPlugin(newlineFunctionCallArguments),
|
|
48
|
+
'newlinene-function-call-arguments': createPlugin(functionDeclarationParenNewline),
|
|
49
|
+
'add-newlines-between-types-in-union': createPlugin(addNewlinesBetweenTypesInUnion),
|
|
50
|
+
'add-newlines-between-specifiers': createPlugin(addNewlinesBetweenSpecifiers),
|
|
51
|
+
'add-newline-before-return': createPlugin(addNewlineBeforeReturn),
|
|
52
|
+
'add-newline-before-function-call': createPlugin(addNewlineBeforeFunctionCall),
|
|
53
|
+
'add-newline-after-function-call': createPlugin(addNewlineAfterFunctionCall),
|
|
54
|
+
'remove-newline-after-default-import': createPlugin(removeNewlineAfterDefaultImport),
|
|
55
|
+
'remove-newline-from-empty-object': createPlugin(removeNewlineFromEmptyObject),
|
|
56
|
+
'remove-empty-newline-before-first-specifier': createPlugin(removeEmptyNewlineBeforeFirstSpecifier),
|
|
57
|
+
'remove-empty-newline-after-last-specifier': createPlugin(removeEmptyNewlineAfterLastSpecifier),
|
|
58
|
+
'remove-empty-newline-after-last-element': createPlugin(removeEmptyNewlineAfterLastElement),
|
|
59
|
+
'remove-empty-specifiers': createPlugin(removeEmptySpecifiers),
|
|
60
|
+
'objects-braces-inside-array': createPlugin(objectsBracesInsideArray),
|
|
61
|
+
'object-property-newline': createPlugin(objectPropertyNewline),
|
|
62
|
+
'remove-duplicate-extensions': createPlugin(removeDuplicateExtensions),
|
|
63
|
+
'evaluate': createPlugin(evaluate),
|
|
64
|
+
'tape-add-newline-before-assertion': createPlugin(tapeAddNewlineBeforeAssertion),
|
|
65
|
+
'tape-add-newline-between-tests': createPlugin(tapeAddNewlineBetweenTests),
|
|
66
|
+
'tape-remove-newline-before-t-end': createPlugin(tapeRemoveNewlineBeforeTEnd),
|
|
67
|
+
'nonblock-statement-body-newline': createPlugin(nonblockStatementBodyNewline),
|
|
68
|
+
};
|
package/lib/putout/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {putoutSync} = require('./sync.mjs');
|
|
1
|
+
import {putoutSync} from './sync.js';
|
|
4
2
|
|
|
5
3
|
const getContextOptions = ({options}) => {
|
|
6
4
|
const [allContextOptions = {}] = options;
|
|
7
5
|
return allContextOptions;
|
|
8
6
|
};
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
export default {
|
|
11
9
|
meta: {
|
|
10
|
+
messages: [],
|
|
12
11
|
type: 'suggestion',
|
|
13
12
|
docs: {
|
|
14
13
|
description: 'Putout',
|
|
@@ -16,6 +15,7 @@ module.exports = {
|
|
|
16
15
|
recommended: true,
|
|
17
16
|
},
|
|
18
17
|
schema: false,
|
|
18
|
+
defaultOptions: [],
|
|
19
19
|
fixable: 'code',
|
|
20
20
|
},
|
|
21
21
|
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const getValue = ({source}) => source?.value;
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export const category = 'errors';
|
|
4
|
+
export const report = () => 'Avoid duplicate extensions in relative imports';
|
|
5
|
+
export const include = () => [
|
|
8
6
|
'ImportDeclaration',
|
|
9
7
|
'ImportExpression',
|
|
10
8
|
'ExportAllDeclaration',
|
|
11
9
|
'ExportNamedDeclaration',
|
|
12
10
|
];
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
export const fix = ({text}) => {
|
|
15
13
|
return text.replace('.js.js', '.js');
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
export const filter = ({node}) => {
|
|
19
17
|
const value = getValue(node);
|
|
20
18
|
return /\.js\.js/.test(value);
|
|
21
19
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {isBuiltin} from 'node:module';
|
|
2
2
|
|
|
3
|
-
const {isBuiltin} = require('node:module');
|
|
4
3
|
const isLocal = (a) => a.source.value.startsWith('.');
|
|
5
4
|
const isNode = (a) => isBuiltin(a.source.value);
|
|
6
5
|
|
|
@@ -11,7 +10,7 @@ const isSameGroup = (a, b) => {
|
|
|
11
10
|
return isNode(a) && isNode(b);
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export default {
|
|
15
14
|
meta: {
|
|
16
15
|
type: 'suggestion',
|
|
17
16
|
docs: {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.category = 'array';
|
|
4
|
-
module.exports.report = () => 'Remove newline after last element';
|
|
1
|
+
export const category = 'array';
|
|
2
|
+
export const report = () => 'Remove newline after last element';
|
|
5
3
|
|
|
6
4
|
const regExp = /\n\n(\s+)?]/;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const filter = ({text}) => {
|
|
9
7
|
return regExp.test(text);
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export const fix = ({text}) => {
|
|
13
11
|
return text.replace(regExp, '\n]');
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const include = () => [
|
|
17
15
|
'ArrayExpression',
|
|
18
16
|
];
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.category = 'import';
|
|
4
|
-
module.exports.report = () => 'Remove newline after last specifier';
|
|
1
|
+
export const category = 'import';
|
|
2
|
+
export const report = () => 'Remove newline after last specifier';
|
|
5
3
|
|
|
6
4
|
const regExp = /\n\n(\s+)?}/;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const filter = ({text}) => {
|
|
9
7
|
return regExp.test(text);
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export const fix = ({text}) => {
|
|
13
11
|
return text.replace(regExp, '\n}');
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const include = () => [
|
|
17
15
|
'ImportDeclaration',
|
|
18
16
|
'ObjectExpression',
|
|
19
17
|
];
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.category = 'import';
|
|
4
|
-
module.exports.report = () => 'Remove newline before first specifier';
|
|
1
|
+
export const category = 'import';
|
|
2
|
+
export const report = () => 'Remove newline before first specifier';
|
|
5
3
|
|
|
6
4
|
const regExp = /{\n(\s+)?\n/;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const filter = ({text}) => {
|
|
9
7
|
return regExp.test(text);
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export const fix = ({text}) => {
|
|
13
11
|
return text.replace(regExp, '{\n');
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const include = () => [
|
|
17
15
|
'ImportDeclaration',
|
|
18
16
|
'ObjectExpression',
|
|
19
17
|
];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export const category = 'object';
|
|
2
|
+
export const report = () => 'Remove empty import specifiers';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
module.exports.report = () => 'Remove empty import specifiers';
|
|
5
|
-
|
|
6
|
-
module.exports.filter = ({text, node, getCommentsInside}) => {
|
|
4
|
+
export const filter = ({text, node, getCommentsInside}) => {
|
|
7
5
|
const comments = getCommentsInside(node);
|
|
8
6
|
|
|
9
7
|
if (comments.length)
|
|
@@ -12,12 +10,12 @@ module.exports.filter = ({text, node, getCommentsInside}) => {
|
|
|
12
10
|
return text.includes('{}');
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
export const fix = ({text}) => {
|
|
16
14
|
return text
|
|
17
15
|
.replace('import {} from', 'import')
|
|
18
16
|
.replace(/,? {}/, '');
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
export const include = () => [
|
|
22
20
|
'ImportDeclaration',
|
|
23
21
|
];
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.category = 'import';
|
|
4
|
-
module.exports.report = () => 'Keep opening curly brace on one line with default import';
|
|
1
|
+
export const category = 'import';
|
|
2
|
+
export const report = () => 'Keep opening curly brace on one line with default import';
|
|
5
3
|
|
|
6
4
|
const regExp = /,\n\s*{/;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const filter = ({text}) => {
|
|
9
7
|
return regExp.test(text);
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export const fix = ({text}) => {
|
|
13
11
|
return text.replace(regExp, ', {');
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export const include = () => [
|
|
17
15
|
'ImportDeclaration',
|
|
18
16
|
];
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {types} = require('putout');
|
|
4
3
|
const {isArrayExpression} = types;
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export const category = 'object';
|
|
6
|
+
export const report = () => 'Remove newline from empty object';
|
|
8
7
|
|
|
9
8
|
const regExp = /\n/;
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
export const filter = ({text, node, getCommentsInside}) => {
|
|
12
11
|
const comments = getCommentsInside(node);
|
|
13
12
|
|
|
14
13
|
if (comments.length)
|
|
@@ -23,8 +22,8 @@ module.exports.filter = ({text, node, getCommentsInside}) => {
|
|
|
23
22
|
return regExp.test(text);
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
export const fix = () => '{}';
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
export const include = () => [
|
|
29
28
|
'ObjectExpression',
|
|
30
29
|
];
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {operator, types} = require('putout');
|
|
1
|
+
import {operator, types} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {
|
|
6
4
|
isRestElement,
|
|
@@ -14,15 +12,15 @@ const AssignRegExp = /{\n?.*=.*\n?.*}/;
|
|
|
14
12
|
|
|
15
13
|
const {compare} = operator;
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export const category = 'destructuring';
|
|
16
|
+
export const report = () => 'Keep curly braces on one line when you have one destructuring property';
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export const include = () => [
|
|
21
19
|
'VariableDeclarator[id.type="ObjectPattern"][id.properties.length=1]',
|
|
22
20
|
'ImportDeclaration[specifiers.length=1]',
|
|
23
21
|
];
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
export const filter = ({node, text, getText, getCommentsInside}) => {
|
|
26
24
|
if (getCommentsInside(node).length)
|
|
27
25
|
return false;
|
|
28
26
|
|
|
@@ -47,7 +45,7 @@ module.exports.filter = ({node, text, getText, getCommentsInside}) => {
|
|
|
47
45
|
return false;
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
export const fix = ({text, node, getText}) => {
|
|
51
49
|
if (isImportDeclaration(node))
|
|
52
50
|
return text.replace(NewLinesReg, '');
|
|
53
51
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.category = 'tape';
|
|
4
|
-
module.exports.report = () => 'Add newline before assertion';
|
|
1
|
+
export const category = 'tape';
|
|
2
|
+
export const report = () => 'Add newline before assertion';
|
|
5
3
|
|
|
6
4
|
const regexp = /;\n +?t\..*;\n +?t.end\(\);/;
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
export const filter = ({text}) => {
|
|
9
7
|
if (!/^test(\.only|\.skip)?\(/.test(text))
|
|
10
8
|
return false;
|
|
11
9
|
|
|
@@ -20,11 +18,11 @@ module.exports.filter = ({text}) => {
|
|
|
20
18
|
return regexp.test(text);
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
export const fix = ({text}) => {
|
|
24
22
|
const [assertion] = text.match(/\st\..*/);
|
|
25
23
|
return text.replace(assertion, `\n${assertion}`);
|
|
26
24
|
};
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
export const include = () => [
|
|
29
27
|
'CallExpression',
|
|
30
28
|
];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export const category = 'tape';
|
|
2
|
+
export const report = () => 'Add newline between tests';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
module.exports.report = () => 'Add newline between tests';
|
|
5
|
-
|
|
6
|
-
module.exports.filter = ({text, node, getText, getCommentsBefore}) => {
|
|
4
|
+
export const filter = ({text, node, getText, getCommentsBefore}) => {
|
|
7
5
|
if (!/^test(\.only|\.skip)?\(/.test(text))
|
|
8
6
|
return false;
|
|
9
7
|
|
|
@@ -17,10 +15,10 @@ module.exports.filter = ({text, node, getText, getCommentsBefore}) => {
|
|
|
17
15
|
return a === ';';
|
|
18
16
|
};
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export const fix = ({text}) => {
|
|
21
19
|
return `\n${text}`;
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
export const include = () => [
|
|
25
23
|
'CallExpression ',
|
|
26
24
|
];
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {operator, types} = require('putout');
|
|
1
|
+
import {operator, types} from 'putout';
|
|
4
2
|
|
|
5
3
|
const {
|
|
6
4
|
isCallExpression,
|
|
@@ -9,12 +7,12 @@ const {
|
|
|
9
7
|
|
|
10
8
|
const {compare} = operator;
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export const category = 'tape';
|
|
11
|
+
export const report = () => 'Remove newline before t.end()';
|
|
14
12
|
|
|
15
13
|
const newlineReg = /\n( +)?\n +t.end\(\)/;
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
export const filter = ({text, node}) => {
|
|
18
16
|
if (!/^test(\.only|\.skip)?\(/.test(text))
|
|
19
17
|
return false;
|
|
20
18
|
|
|
@@ -44,10 +42,10 @@ module.exports.filter = ({text, node}) => {
|
|
|
44
42
|
return false;
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
export const fix = ({text}) => {
|
|
48
46
|
return text.replace(newlineReg, '\n t.end()');
|
|
49
47
|
};
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
export const include = () => [
|
|
52
50
|
'CallExpression',
|
|
53
51
|
];
|
package/lib/{ts.mjs → ts.js}
RENAMED
|
@@ -3,8 +3,8 @@ import tseslint from 'typescript-eslint';
|
|
|
3
3
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
4
4
|
import stylistic from '@stylistic/eslint-plugin';
|
|
5
5
|
import parser from '#typescript-eslint/parser';
|
|
6
|
-
import {jsx} from './jsx.
|
|
7
|
-
import * as plugin from './plugin.
|
|
6
|
+
import {jsx} from './jsx.js';
|
|
7
|
+
import * as plugin from './plugin.js';
|
|
8
8
|
|
|
9
9
|
const {assign} = Object;
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "30.0.0",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
7
7
|
"tag": false,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"url": "git+https://github.com/coderaiser/putout.git"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
|
-
".": "./lib/index.
|
|
15
|
+
".": "./lib/index.js",
|
|
16
16
|
"./babel": "./eslint-v10/babel.js"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@putout/engine-parser": "^15.0.1",
|
|
45
45
|
"@putout/eslint": "^5.0.0",
|
|
46
46
|
"@putout/eslint-config": "^13.0.0",
|
|
47
|
-
"@putout/eslint-flat": "^
|
|
47
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
48
48
|
"@stylistic/eslint-plugin": "~5.2.0 || > 5.3.1",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
50
50
|
"@typescript-eslint/parser": "^8.3.0",
|
|
@@ -73,12 +73,8 @@
|
|
|
73
73
|
"supertape": "^12.0.0"
|
|
74
74
|
},
|
|
75
75
|
"imports": {
|
|
76
|
-
"#typescript-eslint/parser":
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
"#babel/eslint-parser/experimental-worker": {
|
|
80
|
-
"default": "./eslint-v10/babel.js"
|
|
81
|
-
}
|
|
76
|
+
"#typescript-eslint/parser": "./eslint-v10/ts.js",
|
|
77
|
+
"#babel/eslint-parser/experimental-worker": "./eslint-v10/babel.js"
|
|
82
78
|
},
|
|
83
79
|
"engines": {
|
|
84
80
|
"node": ">=22"
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const process = require('node:process');
|
|
4
|
-
const {accessSync} = require('node:fs');
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
extname,
|
|
8
|
-
dirname,
|
|
9
|
-
join,
|
|
10
|
-
} = require('node:path');
|
|
11
|
-
|
|
12
|
-
const {tryCatch} = require('try-catch');
|
|
13
|
-
|
|
14
|
-
const cwd = process.cwd();
|
|
15
|
-
|
|
16
|
-
const RELATIVE = '\\.\\.?\\/?';
|
|
17
|
-
const isRelativeStart = (a) => RegExp(`^${RELATIVE}`).test(a);
|
|
18
|
-
const isRelativeEnd = (a) => RegExp(`${RELATIVE}$`).test(a);
|
|
19
|
-
const getDir = (a) => a === '<input>' ? cwd : dirname(a);
|
|
20
|
-
const getValue = ({source}) => source?.value;
|
|
21
|
-
|
|
22
|
-
module.exports.category = 'errors';
|
|
23
|
-
module.exports.report = () => 'Always add an extension to relative imports';
|
|
24
|
-
module.exports.include = () => [
|
|
25
|
-
'ImportDeclaration',
|
|
26
|
-
'ImportExpression',
|
|
27
|
-
'ExportAllDeclaration',
|
|
28
|
-
'ExportNamedDeclaration',
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
module.exports.fix = ({node, text, filename}) => {
|
|
32
|
-
const value = getValue(node);
|
|
33
|
-
const dir = getDir(filename);
|
|
34
|
-
|
|
35
|
-
const resolved = resolveSource({
|
|
36
|
-
dir,
|
|
37
|
-
value,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return text.replace(value, resolved);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports.filter = ({node}) => {
|
|
44
|
-
const value = getValue(node);
|
|
45
|
-
|
|
46
|
-
if (!value || value.endsWith('.js'))
|
|
47
|
-
return false;
|
|
48
|
-
|
|
49
|
-
if (!isRelativeStart(value))
|
|
50
|
-
return false;
|
|
51
|
-
|
|
52
|
-
return !extname(value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
function resolveSource({dir, value}) {
|
|
56
|
-
if (isRelativeEnd(value)) {
|
|
57
|
-
const name = join(dir, value, 'package.json');
|
|
58
|
-
const [error, info] = tryCatch(require, name);
|
|
59
|
-
|
|
60
|
-
if (!error)
|
|
61
|
-
return join(value, info.main);
|
|
62
|
-
|
|
63
|
-
return `${value}/index.js`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
for (const ext of ['js', 'mjs', 'cjs']) {
|
|
67
|
-
const name = join(dir, `${value}.${ext}`);
|
|
68
|
-
const [error] = tryCatch(accessSync, name);
|
|
69
|
-
|
|
70
|
-
if (!error)
|
|
71
|
-
return `${value}.${ext}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const name = join(dir, value, `index.js`);
|
|
75
|
-
const [error] = tryCatch(accessSync, name);
|
|
76
|
-
|
|
77
|
-
if (!error)
|
|
78
|
-
return `${value}/index.js`;
|
|
79
|
-
|
|
80
|
-
return `${value}.js`;
|
|
81
|
-
}
|