eslint-plugin-putout 29.3.0 → 29.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.
Files changed (46) hide show
  1. package/eslint-v10/babel.js +5 -7
  2. package/eslint-v10/ts.js +5 -6
  3. package/lib/add-newline-after-function-call/index.js +6 -7
  4. package/lib/add-newline-before-function-call/index.js +5 -6
  5. package/lib/add-newline-before-return/index.js +4 -6
  6. package/lib/add-newlines-between-specifiers/index.js +5 -7
  7. package/lib/add-newlines-between-types-in-union/index.js +6 -7
  8. package/lib/align-spaces/index.js +5 -6
  9. package/lib/array-element-newline/index.js +6 -7
  10. package/lib/common.js +4 -4
  11. package/lib/destructuring-as-function-argument/index.js +5 -7
  12. package/lib/evaluate/index.js +10 -8
  13. package/lib/for-of-multiple-properties-destructuring/index.js +5 -7
  14. package/lib/function-declaration-paren-newline/index.js +4 -6
  15. package/lib/{index.mjs → index.js} +6 -6
  16. package/lib/{json.mjs → json.js} +1 -1
  17. package/lib/long-properties-destructuring/index.js +7 -8
  18. package/lib/{markdown.mjs → markdown.js} +2 -2
  19. package/lib/multiple-properties-destructuring/index.js +11 -12
  20. package/lib/newline-function-call-arguments/index.js +4 -6
  21. package/lib/no-unresolved/index.js +12 -14
  22. package/lib/nonblock-statement-body-newline/index.js +5 -6
  23. package/lib/object-property-newline/index.js +7 -9
  24. package/lib/objects-braces-inside-array/index.js +7 -7
  25. package/lib/plugin.js +70 -0
  26. package/lib/putout/index.js +4 -4
  27. package/lib/putout/parse-error.js +1 -3
  28. package/lib/remove-duplicate-extensions/index.js +5 -7
  29. package/lib/remove-empty-newline-after-import/index.js +2 -3
  30. package/lib/remove-empty-newline-after-last-element/index.js +5 -7
  31. package/lib/remove-empty-newline-after-last-specifier/index.js +5 -7
  32. package/lib/remove-empty-newline-before-first-specifier/index.js +5 -7
  33. package/lib/remove-empty-newline-between-declarations/index.js +3 -3
  34. package/lib/remove-empty-specifiers/index.js +5 -7
  35. package/lib/remove-newline-after-default-import/index.js +5 -7
  36. package/lib/remove-newline-from-empty-object/index.js +6 -7
  37. package/lib/single-property-destructuring/index.js +6 -8
  38. package/lib/tape-add-newline-before-assertion/index.js +5 -7
  39. package/lib/tape-add-newline-between-tests/index.js +5 -7
  40. package/lib/tape-remove-newline-before-t-end/index.js +6 -8
  41. package/lib/{ts.mjs → ts.js} +2 -2
  42. package/package.json +3 -3
  43. package/lib/plugin.mjs +0 -47
  44. /package/lib/{html.mjs → html.js} +0 -0
  45. /package/lib/{jsx.mjs → jsx.js} +0 -0
  46. /package/lib/putout/{sync.mjs → sync.js} +0 -0
@@ -1,6 +1,5 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {
5
4
  isBlockStatement,
6
5
  isIfStatement,
@@ -9,20 +8,20 @@ const {
9
8
 
10
9
  const reg = /\)\n(\s+)?\n/;
11
10
 
12
- module.exports.report = () => `Remove useless newline`;
11
+ export const report = () => `Remove useless newline`;
13
12
 
14
- module.exports.fix = ({text}) => {
13
+ export const fix = ({text}) => {
15
14
  return text.replace(reg, ')\n');
16
15
  };
17
16
 
18
- module.exports.include = () => [
17
+ export const include = () => [
19
18
  'IfStatement',
20
19
  'ForOfStatement',
21
20
  'ForStatement',
22
21
  'WhileStatement',
23
22
  ];
24
23
 
25
- module.exports.filter = ({text, node}) => {
24
+ export const filter = ({text, node}) => {
26
25
  if (isIf(text, node))
27
26
  return true;
28
27
 
@@ -1,7 +1,5 @@
1
- 'use strict';
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
- module.exports.category = 'destructuring';
13
- module.exports.report = () => 'Keep each property on separate line';
10
+ export const category = 'destructuring';
11
+ export const report = () => 'Keep each property on separate line';
14
12
 
15
- module.exports.include = () => [
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
- module.exports.filter = ({node}) => {
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
- module.exports.fix = ({text}) => {
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
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {isObjectExpression} = require('putout').types;
3
+ const {isObjectExpression} = types;
4
4
 
5
- module.exports.category = 'destructuring';
6
- module.exports.report = () => 'Keep braces on the same line with brackets';
5
+ export const category = 'destructuring';
6
+ export const report = () => 'Keep braces on the same line with brackets';
7
7
 
8
- module.exports.include = () => [
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
- module.exports.filter = ({node, text}) => {
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
- module.exports.fix = ({text}) => {
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,70 @@
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 noUnresolved from './no-unresolved/index.js';
25
+ import * as removeDuplicateExtensions from './remove-duplicate-extensions/index.js';
26
+ import * as evaluate from './evaluate/index.js';
27
+ import * as tapeAddNewlineBeforeAssertion from './tape-add-newline-before-assertion/index.js';
28
+ import * as tapeAddNewlineBetweenTests from './tape-add-newline-between-tests/index.js';
29
+ import * as tapeRemoveNewlineBeforeTEnd from './tape-remove-newline-before-t-end/index.js';
30
+ import * as nonblockStatementBodyNewline from './nonblock-statement-body-newline/index.js';
31
+ import putout from './putout/index.js';
32
+ import removeEmptyNewlineAfterImport from './remove-empty-newline-after-import/index.js';
33
+ import removeEmptyNewlineBetweenDeclarations from './remove-empty-newline-between-declarations/index.js';
34
+
35
+ export const rules = {
36
+ 'putout': putout,
37
+ 'remove-empty-newline-after-import': removeEmptyNewlineAfterImport,
38
+ 'remove-empty-newline-between-declarations': removeEmptyNewlineBetweenDeclarations,
39
+
40
+ 'function-declaration-paren-newline': createPlugin(functionDeclarationParenNewline),
41
+ 'array-element-newline': createPlugin(arrayElementNewline),
42
+ 'single-property-destructuring': createPlugin(singlePropertyDestructuring),
43
+ 'multiple-properties-destructuring': createPlugin(multiplePropertiesDestructuring),
44
+ 'for-of-multiple-properties-destructuring': createPlugin(forOfMultiplePropertiesDestructuring),
45
+ 'long-properties-destructuring': createPlugin(longPropertiesDestructuring),
46
+ 'destructuring-as-function-argument': createPlugin(destructuringAsFunctionArgument),
47
+ 'align-spaces': createPlugin(alignSpaces),
48
+ 'newline-function-call-arguments': createPlugin(newlineFunctionCallArguments),
49
+ 'newlinene-function-call-arguments': createPlugin(functionDeclarationParenNewline),
50
+ 'add-newlines-between-types-in-union': createPlugin(addNewlinesBetweenTypesInUnion),
51
+ 'add-newlines-between-specifiers': createPlugin(addNewlinesBetweenSpecifiers),
52
+ 'add-newline-before-return': createPlugin(addNewlineBeforeReturn),
53
+ 'add-newline-before-function-call': createPlugin(addNewlineBeforeFunctionCall),
54
+ 'add-newline-after-function-call': createPlugin(addNewlineAfterFunctionCall),
55
+ 'remove-newline-after-default-import': createPlugin(removeNewlineAfterDefaultImport),
56
+ 'remove-newline-from-empty-object': createPlugin(removeNewlineFromEmptyObject),
57
+ 'remove-empty-newline-before-first-specifier': createPlugin(removeEmptyNewlineBeforeFirstSpecifier),
58
+ 'remove-empty-newline-after-last-specifier': createPlugin(removeEmptyNewlineAfterLastSpecifier),
59
+ 'remove-empty-newline-after-last-element': createPlugin(removeEmptyNewlineAfterLastElement),
60
+ 'remove-empty-specifiers': createPlugin(removeEmptySpecifiers),
61
+ 'objects-braces-inside-array': createPlugin(objectsBracesInsideArray),
62
+ 'object-property-newline': createPlugin(objectPropertyNewline),
63
+ 'no-unresolved': createPlugin(noUnresolved),
64
+ 'remove-duplicate-extensions': createPlugin(removeDuplicateExtensions),
65
+ 'evaluate': createPlugin(evaluate),
66
+ 'tape-add-newline-before-assertion': createPlugin(tapeAddNewlineBeforeAssertion),
67
+ 'tape-add-newline-between-tests': createPlugin(tapeAddNewlineBetweenTests),
68
+ 'tape-remove-newline-before-t-end': createPlugin(tapeRemoveNewlineBeforeTEnd),
69
+ 'nonblock-statement-body-newline': createPlugin(nonblockStatementBodyNewline),
70
+ };
@@ -1,14 +1,13 @@
1
- 'use strict';
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
- module.exports = {
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,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.parseError = ({code, message, name}) => {
1
+ export const parseError = ({code, message, name}) => {
4
2
  if (message.includes('buildError'))
5
3
  return 'Parser error';
6
4
 
@@ -1,21 +1,19 @@
1
- 'use strict';
2
-
3
1
  const getValue = ({source}) => source?.value;
4
2
 
5
- module.exports.category = 'errors';
6
- module.exports.report = () => 'Avoid duplicate extensions in relative imports';
7
- module.exports.include = () => [
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
- module.exports.fix = ({text}) => {
12
+ export const fix = ({text}) => {
15
13
  return text.replace('.js.js', '.js');
16
14
  };
17
15
 
18
- module.exports.filter = ({node}) => {
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
- 'use strict';
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
- module.exports = {
13
+ export default {
15
14
  meta: {
16
15
  type: 'suggestion',
17
16
  docs: {
@@ -1,18 +1,16 @@
1
- 'use strict';
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
- module.exports.filter = ({text}) => {
6
+ export const filter = ({text}) => {
9
7
  return regExp.test(text);
10
8
  };
11
9
 
12
- module.exports.fix = ({text}) => {
10
+ export const fix = ({text}) => {
13
11
  return text.replace(regExp, '\n]');
14
12
  };
15
13
 
16
- module.exports.include = () => [
14
+ export const include = () => [
17
15
  'ArrayExpression',
18
16
  ];
@@ -1,19 +1,17 @@
1
- 'use strict';
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
- module.exports.filter = ({text}) => {
6
+ export const filter = ({text}) => {
9
7
  return regExp.test(text);
10
8
  };
11
9
 
12
- module.exports.fix = ({text}) => {
10
+ export const fix = ({text}) => {
13
11
  return text.replace(regExp, '\n}');
14
12
  };
15
13
 
16
- module.exports.include = () => [
14
+ export const include = () => [
17
15
  'ImportDeclaration',
18
16
  'ObjectExpression',
19
17
  ];
@@ -1,19 +1,17 @@
1
- 'use strict';
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
- module.exports.filter = ({text}) => {
6
+ export const filter = ({text}) => {
9
7
  return regExp.test(text);
10
8
  };
11
9
 
12
- module.exports.fix = ({text}) => {
10
+ export const fix = ({text}) => {
13
11
  return text.replace(regExp, '{\n');
14
12
  };
15
13
 
16
- module.exports.include = () => [
14
+ export const include = () => [
17
15
  'ImportDeclaration',
18
16
  'ObjectExpression',
19
17
  ];
@@ -1,8 +1,8 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {isObjectPattern} = require('putout').types;
3
+ const {isObjectPattern} = types;
4
4
 
5
- module.exports = {
5
+ export default {
6
6
  meta: {
7
7
  type: 'suggestion',
8
8
  docs: {
@@ -1,9 +1,7 @@
1
- 'use strict';
1
+ export const category = 'object';
2
+ export const report = () => 'Remove empty import specifiers';
2
3
 
3
- module.exports.category = 'object';
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
- module.exports.fix = ({text}) => {
13
+ export const fix = ({text}) => {
16
14
  return text
17
15
  .replace('import {} from', 'import')
18
16
  .replace(/,? {}/, '');
19
17
  };
20
18
 
21
- module.exports.include = () => [
19
+ export const include = () => [
22
20
  'ImportDeclaration',
23
21
  ];
@@ -1,18 +1,16 @@
1
- 'use strict';
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
- module.exports.filter = ({text}) => {
6
+ export const filter = ({text}) => {
9
7
  return regExp.test(text);
10
8
  };
11
9
 
12
- module.exports.fix = ({text}) => {
10
+ export const fix = ({text}) => {
13
11
  return text.replace(regExp, ', {');
14
12
  };
15
13
 
16
- module.exports.include = () => [
14
+ export const include = () => [
17
15
  'ImportDeclaration',
18
16
  ];
@@ -1,14 +1,13 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {isArrayExpression} = types;
5
4
 
6
- module.exports.category = 'object';
7
- module.exports.report = () => 'Remove newline from empty object';
5
+ export const category = 'object';
6
+ export const report = () => 'Remove newline from empty object';
8
7
 
9
8
  const regExp = /\n/;
10
9
 
11
- module.exports.filter = ({text, node, getCommentsInside}) => {
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
- module.exports.fix = () => '{}';
25
+ export const fix = () => '{}';
27
26
 
28
- module.exports.include = () => [
27
+ export const include = () => [
29
28
  'ObjectExpression',
30
29
  ];
@@ -1,6 +1,4 @@
1
- 'use strict';
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
- module.exports.category = 'destructuring';
18
- module.exports.report = () => 'Keep curly braces on one line when you have one destructuring property';
15
+ export const category = 'destructuring';
16
+ export const report = () => 'Keep curly braces on one line when you have one destructuring property';
19
17
 
20
- module.exports.include = () => [
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
- module.exports.filter = ({node, text, getText, getCommentsInside}) => {
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
- module.exports.fix = ({text, node, getText}) => {
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
- 'use strict';
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
- module.exports.filter = ({text}) => {
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
- module.exports.fix = ({text}) => {
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
- module.exports.include = () => [
26
+ export const include = () => [
29
27
  'CallExpression',
30
28
  ];
@@ -1,9 +1,7 @@
1
- 'use strict';
1
+ export const category = 'tape';
2
+ export const report = () => 'Add newline between tests';
2
3
 
3
- module.exports.category = 'tape';
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
- module.exports.fix = ({text}) => {
18
+ export const fix = ({text}) => {
21
19
  return `\n${text}`;
22
20
  };
23
21
 
24
- module.exports.include = () => [
22
+ export const include = () => [
25
23
  'CallExpression ',
26
24
  ];
@@ -1,6 +1,4 @@
1
- 'use strict';
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
- module.exports.category = 'tape';
13
- module.exports.report = () => 'Remove newline before t.end()';
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
- module.exports.filter = ({text, node}) => {
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
- module.exports.fix = ({text}) => {
45
+ export const fix = ({text}) => {
48
46
  return text.replace(newlineReg, '\n t.end()');
49
47
  };
50
48
 
51
- module.exports.include = () => [
49
+ export const include = () => [
52
50
  'CallExpression',
53
51
  ];
@@ -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.mjs';
7
- import * as plugin from './plugin.mjs';
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": "29.3.0",
4
- "type": "commonjs",
3
+ "version": "29.4.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.mjs",
15
+ ".": "./lib/index.js",
16
16
  "./babel": "./eslint-v10/babel.js"
17
17
  },
18
18
  "keywords": [
package/lib/plugin.mjs DELETED
@@ -1,47 +0,0 @@
1
- import {createRequire} from 'node:module';
2
- import {createPlugin} from '@putout/eslint/create-plugin';
3
-
4
- const require = createRequire(import.meta.url);
5
-
6
- const getRule = (a) => ({
7
- [a]: require(`./${a}`),
8
- });
9
-
10
- const getWrapRule = (a) => ({
11
- [a]: createPlugin(require(`./${a}`)),
12
- });
13
-
14
- export const rules = {
15
- ...getWrapRule('array-element-newline'),
16
- ...getWrapRule('single-property-destructuring'),
17
- ...getWrapRule('multiple-properties-destructuring'),
18
- ...getWrapRule('for-of-multiple-properties-destructuring'),
19
- ...getWrapRule('long-properties-destructuring'),
20
- ...getWrapRule('destructuring-as-function-argument'),
21
- ...getWrapRule('align-spaces'),
22
- ...getWrapRule('newline-function-call-arguments'),
23
- ...getWrapRule('function-declaration-paren-newline'),
24
- ...getWrapRule('add-newlines-between-types-in-union'),
25
- ...getWrapRule('add-newlines-between-specifiers'),
26
- ...getWrapRule('add-newline-before-return'),
27
- ...getWrapRule('add-newline-before-function-call'),
28
- ...getWrapRule('add-newline-after-function-call'),
29
- ...getWrapRule('remove-newline-after-default-import'),
30
- ...getWrapRule('remove-newline-from-empty-object'),
31
- ...getWrapRule('remove-empty-newline-before-first-specifier'),
32
- ...getWrapRule('remove-empty-newline-after-last-specifier'),
33
- ...getWrapRule('remove-empty-newline-after-last-element'),
34
- ...getWrapRule('remove-empty-specifiers'),
35
- ...getWrapRule('objects-braces-inside-array'),
36
- ...getWrapRule('object-property-newline'),
37
- ...getWrapRule('no-unresolved'),
38
- ...getWrapRule('remove-duplicate-extensions'),
39
- ...getWrapRule('evaluate'),
40
- ...getWrapRule('tape-add-newline-before-assertion'),
41
- ...getWrapRule('tape-add-newline-between-tests'),
42
- ...getWrapRule('tape-remove-newline-before-t-end'),
43
- ...getWrapRule('nonblock-statement-body-newline'),
44
- ...getRule('putout'),
45
- ...getRule('remove-empty-newline-after-import'),
46
- ...getRule('remove-empty-newline-between-declarations'),
47
- };
File without changes
File without changes
File without changes