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
@@ -2,23 +2,21 @@
2
2
  * @fileoverview Wrapper around @babel-eslint/parser to make it work with ESLint v10.
3
3
  * @author Milos Djermanovic
4
4
  */
5
-
6
- 'use strict';
7
-
8
5
  //-----------------------------------------------------------------------------
9
6
  // Requirements
10
7
  //-----------------------------------------------------------------------------
11
- const eslintScope = require('eslint-scope');
12
-
13
- const babelESLintParser = require('@babel/eslint-parser/experimental-worker');
8
+ import * as eslintScope from 'eslint-scope';
9
+ import babelESLintParser from '@babel/eslint-parser/experimental-worker';
14
10
 
15
11
  //------------------------------------------------------------------------------
16
12
  // Type Definitions
17
13
  //------------------------------------------------------------------------------
14
+
18
15
  /** @typedef {import("eslint-scope").ScopeManager} ScopeManager */
19
16
  //-----------------------------------------------------------------------------
20
17
  // Helpers
21
18
  //-----------------------------------------------------------------------------
19
+
22
20
  /**
23
21
  * Add global variables and resolve references to all global variables.
24
22
  * @this {ScopeManager}
@@ -92,7 +90,7 @@ function addGlobals(names) {
92
90
  //-----------------------------------------------------------------------------
93
91
  // Exports
94
92
  //-----------------------------------------------------------------------------
95
- module.exports = {
93
+ export default {
96
94
  ...babelESLintParser,
97
95
  parseForESLint(...args) {
98
96
  const retv = babelESLintParser.parseForESLint(...args);
package/eslint-v10/ts.js CHANGED
@@ -2,22 +2,21 @@
2
2
  * @fileoverview Wrapper around @typescript-eslint/parser to make it work with ESLint v10.
3
3
  * @author Milos Djermanovic
4
4
  */
5
-
6
- 'use strict';
7
-
8
5
  //-----------------------------------------------------------------------------
9
6
  // Requirements
10
7
  //-----------------------------------------------------------------------------
11
- const eslintScope = require('eslint-scope');
12
- const typescriptESLintParser = require('@typescript-eslint/parser');
8
+ import * as eslintScope from 'eslint-scope';
9
+ import typescriptESLintParser from '@typescript-eslint/parser';
13
10
 
14
11
  //------------------------------------------------------------------------------
15
12
  // Type Definitions
16
13
  //------------------------------------------------------------------------------
14
+
17
15
  /** @typedef {import("eslint-scope").ScopeManager} ScopeManager */
18
16
  //-----------------------------------------------------------------------------
19
17
  // Helpers
20
18
  //-----------------------------------------------------------------------------
19
+
21
20
  /**
22
21
  * Add global variables and resolve references to all global variables.
23
22
  * @this {ScopeManager}
@@ -89,7 +88,7 @@ function addGlobals(names) {
89
88
  //-----------------------------------------------------------------------------
90
89
  // Exports
91
90
  //-----------------------------------------------------------------------------
92
- module.exports = {
91
+ export default {
93
92
  ...typescriptESLintParser,
94
93
  parseForESLint(...args) {
95
94
  const retv = typescriptESLintParser.parseForESLint(...args);
@@ -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
  isExpressionStatement,
@@ -11,10 +10,10 @@ const {
11
10
 
12
11
  const regExp = /^;?\n( +)?\n( +)?/;
13
12
 
14
- module.exports.category = 'layout';
15
- module.exports.report = () => 'Add newline after function call';
13
+ export const category = 'layout';
14
+ export const report = () => 'Add newline after function call';
16
15
 
17
- module.exports.filter = ({node, getCommentsAfter, getSpacesAfterNode}) => {
16
+ export const filter = ({node, getCommentsAfter, getSpacesAfterNode}) => {
18
17
  if (!isExpressionStatement(node.parent))
19
18
  return false;
20
19
 
@@ -76,10 +75,10 @@ module.exports.filter = ({node, getCommentsAfter, getSpacesAfterNode}) => {
76
75
  return false;
77
76
  };
78
77
 
79
- module.exports.fix = ({text}) => {
78
+ export const fix = ({text}) => {
80
79
  return `${text};\n`;
81
80
  };
82
81
 
83
- module.exports.include = () => [
82
+ export const include = () => [
84
83
  'CallExpression',
85
84
  ];
@@ -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
  isVariableDeclaration,
@@ -11,9 +10,9 @@ const {
11
10
  //const regExp = /^\n( +)?\n( +)?$/;
12
11
  const regExp = /^\n(\s+)?\n(\s+)?((\n(\s+)+)?)$/;
13
12
 
14
- module.exports.report = () => 'Add newline before expression';
13
+ export const report = () => 'Add newline before expression';
15
14
 
16
- module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) => {
15
+ export const filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) => {
17
16
  if (!isExpressionStatement(node.parent))
18
17
  return false;
19
18
 
@@ -61,11 +60,11 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
61
60
  return false;
62
61
  };
63
62
 
64
- module.exports.fix = ({text}) => {
63
+ export const fix = ({text}) => {
65
64
  return `\n${text}`;
66
65
  };
67
66
 
68
- module.exports.include = () => [
67
+ export const include = () => [
69
68
  'CallExpression',
70
69
  'AssignmentExpression',
71
70
  ];
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
1
  const regExp = /^\n( +)?\n +$/;
4
2
 
5
- module.exports.report = () => `Add newline before 'return'`;
3
+ export const report = () => `Add newline before 'return'`;
6
4
 
7
- module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) => {
5
+ export const filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) => {
8
6
  if (getCommentsBefore(node).length)
9
7
  return false;
10
8
 
@@ -43,10 +41,10 @@ module.exports.filter = ({text, node, getCommentsBefore, getSpacesBeforeNode}) =
43
41
  return !(count < 1);
44
42
  };
45
43
 
46
- module.exports.fix = ({text}) => {
44
+ export const fix = ({text}) => {
47
45
  return `\n${text}`;
48
46
  };
49
47
 
50
- module.exports.include = () => [
48
+ export const include = () => [
51
49
  'ReturnStatement',
52
50
  ];
@@ -1,13 +1,11 @@
1
- 'use strict';
1
+ export const category = 'layout';
2
+ export const report = () => 'Add newlines between specifiers';
2
3
 
3
- module.exports.category = 'layout';
4
- module.exports.report = () => 'Add newlines between specifiers';
5
-
6
- module.exports.include = () => [
4
+ export const include = () => [
7
5
  'ExportNamedDeclaration',
8
6
  ];
9
7
 
10
- module.exports.fix = ({text}) => {
8
+ export const fix = ({text}) => {
11
9
  return text
12
10
  .replace(/,\s+/g, ',\n ')
13
11
  .replace(/{/g, '{\n')
@@ -16,7 +14,7 @@ module.exports.fix = ({text}) => {
16
14
  .replace(/\n+}/g, '\n}');
17
15
  };
18
16
 
19
- module.exports.filter = ({text, node}) => {
17
+ export const filter = ({text, node}) => {
20
18
  const regExp = /, +?[a-zA-Z]/g;
21
19
 
22
20
  if (node.specifiers.length < 4)
@@ -1,14 +1,13 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {isTSTypeAliasDeclaration} = types;
5
4
 
6
- module.exports.category = 'typescript';
7
- module.exports.report = () => 'Add newlines between types in union';
5
+ export const category = 'typescript';
6
+ export const report = () => 'Add newlines between types in union';
8
7
 
9
8
  const regExp = /[^\n]\|\s[A-Za-z]/;
10
9
 
11
- module.exports.filter = ({text, node}) => {
10
+ export const filter = ({text, node}) => {
12
11
  if (!isTSTypeAliasDeclaration(node.parent))
13
12
  return false;
14
13
 
@@ -21,8 +20,8 @@ module.exports.filter = ({text, node}) => {
21
20
  return regExp.test(text);
22
21
  };
23
22
 
24
- module.exports.fix = ({text}) => '\n | ' + text.replace(/\s\|/g, '\n |');
23
+ export const fix = ({text}) => '\n | ' + text.replace(/\s\|/g, '\n |');
25
24
 
26
- module.exports.include = () => [
25
+ export const include = () => [
27
26
  'TSUnionType',
28
27
  ];
@@ -1,17 +1,16 @@
1
- 'use strict';
1
+ import alignSpaces from 'align-spaces';
2
2
 
3
- const alignSpaces = require('align-spaces');
4
3
  const alignedMap = new Map();
5
4
 
6
- module.exports.report = () => 'Keep whitespaces in blank lines';
5
+ export const report = () => 'Keep whitespaces in blank lines';
7
6
 
8
- module.exports.include = () => ['Program'];
7
+ export const include = () => ['Program'];
9
8
 
10
- module.exports.fix = ({text}) => {
9
+ export const fix = ({text}) => {
11
10
  return alignedMap.get(text);
12
11
  };
13
12
 
14
- module.exports.filter = ({text}) => {
13
+ export const filter = ({text}) => {
15
14
  const aligned = alignSpaces(text);
16
15
 
17
16
  if (text === aligned)
@@ -1,6 +1,5 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {
5
4
  isArrayExpression,
6
5
  isMemberExpression,
@@ -11,8 +10,8 @@ const isString = (a) => typeof a === 'string';
11
10
  const isBool = (a) => typeof a === 'boolean';
12
11
  const isNumber = (a) => typeof a === 'number';
13
12
 
14
- module.exports.category = 'array';
15
- module.exports.report = () => 'Add newlines between array elements';
13
+ export const category = 'array';
14
+ export const report = () => 'Add newlines between array elements';
16
15
 
17
16
  const regexp = /['"\da-zA-Z]+, ['"\da-zA-Z]/;
18
17
 
@@ -26,7 +25,7 @@ const isSupportedNode = (a) => {
26
25
  return a.type === 'Identifier';
27
26
  };
28
27
 
29
- module.exports.filter = ({text, node}) => {
28
+ export const filter = ({text, node}) => {
30
29
  if (isMemberExpression(node.parent))
31
30
  return false;
32
31
 
@@ -62,14 +61,14 @@ module.exports.filter = ({text, node}) => {
62
61
  return regexp.test(text);
63
62
  };
64
63
 
65
- module.exports.fix = ({text}) => {
64
+ export const fix = ({text}) => {
66
65
  return text
67
66
  .replace(/\[/g, '[\n')
68
67
  .replace(/\]/g, '\n]')
69
68
  .replace(/,/g, ',\n');
70
69
  };
71
70
 
72
- module.exports.include = () => [
71
+ export const include = () => [
73
72
  'ArrayExpression',
74
73
  ];
75
74
 
package/lib/common.js CHANGED
@@ -1,8 +1,8 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {isImportDefaultSpecifier} = require('putout').types;
3
+ const {isImportDefaultSpecifier} = types;
4
4
 
5
- module.exports.isCorrectLoc = (line, properties) => {
5
+ export const isCorrectLoc = (line, properties) => {
6
6
  for (const [i, prop] of properties.entries()) {
7
7
  if (prop.loc.start.line < i + line + 1)
8
8
  return false;
@@ -11,7 +11,7 @@ module.exports.isCorrectLoc = (line, properties) => {
11
11
  return true;
12
12
  };
13
13
 
14
- module.exports.isCorrectImportLoc = (line, specifiers) => {
14
+ export const isCorrectImportLoc = (line, specifiers) => {
15
15
  if (!isImportDefaultSpecifier(specifiers[0]))
16
16
  ++line;
17
17
 
@@ -1,11 +1,9 @@
1
- 'use strict';
1
+ export const category = 'destructuring';
2
+ export const report = () => 'Keep curly braces on one line when you use destructuring as function argument';
2
3
 
3
- module.exports.category = 'destructuring';
4
- module.exports.report = () => 'Keep curly braces on one line when you use destructuring as function argument';
4
+ export const filter = ({text}) => /\n/.test(text);
5
5
 
6
- module.exports.filter = ({text}) => /\n/.test(text);
7
-
8
- module.exports.fix = ({text}) => {
6
+ export const fix = ({text}) => {
9
7
  return text
10
8
  .replace(/\n/g, '')
11
9
  .replace(/ /g, '')
@@ -14,7 +12,7 @@ module.exports.fix = ({text}) => {
14
12
  };
15
13
 
16
14
  // can't use because of an error// ':has(ArrowFunctionExpression, FunctionExpression, FunctionDeclaration) > .params[type=ObjectPattern]'// Error: Unknown node type JSXElement
17
- module.exports.include = () => [
15
+ export const include = () => [
18
16
  'ArrowFunctionExpression > .params[type=ObjectPattern]',
19
17
  'FunctionExpression > .params[type=ObjectPattern]',
20
18
  'FunctionDeclaration > .params[type=ObjectPattern]',
@@ -1,20 +1,21 @@
1
- 'use strict';
1
+ import {dirname} from 'node:path';
2
+ import {createRequire} from 'node:module';
3
+ import putout from 'putout';
2
4
 
3
- const {dirname} = require('node:path');
4
- const putout = require('putout');
5
+ const require = createRequire(import.meta.url);
5
6
 
6
- module.exports.category = 'evaluate';
7
- module.exports.report = () => 'Evaluate expression';
8
- module.exports.include = () => [
7
+ export const category = 'evaluate';
8
+ export const report = () => 'Evaluate expression';
9
+ export const include = () => [
9
10
  'ImportDeclaration',
10
11
  ];
11
12
 
12
- module.exports.filter = ({node}) => {
13
+ export const filter = ({node}) => {
13
14
  const {value} = node.source;
14
15
  return value.startsWith('__putout_evaluate:');
15
16
  };
16
17
 
17
- module.exports.fix = ({text, node, filename}) => {
18
+ export const fix = ({text, node, filename}) => {
18
19
  const {value} = node.source;
19
20
 
20
21
  const result = evaluate({
@@ -27,6 +28,7 @@ module.exports.fix = ({text, node, filename}) => {
27
28
 
28
29
  function evaluate({value, filename}) {
29
30
  value = value.replace(/__putout_evaluate:\s?/, 'return ');
31
+
30
32
  const {code} = putout(value, {
31
33
  fix: true,
32
34
  rules: {
@@ -1,22 +1,20 @@
1
- 'use strict';
1
+ export const category = 'destructuring';
2
+ export const report = () => 'Keep all properties in one line when using destructuring in for-of';
2
3
 
3
- module.exports.category = 'destructuring';
4
- module.exports.report = () => 'Keep all properties in one line when using destructuring in for-of';
5
-
6
- module.exports.include = ({options}) => {
4
+ export const include = ({options}) => {
7
5
  const {maxProperties = 8} = options[0] || {};
8
6
 
9
7
  return [`VariableDeclarator[id.type="ObjectPattern"][id.properties.length<${maxProperties}]`];
10
8
  };
11
9
 
12
- module.exports.filter = ({node, text}) => {
10
+ export const filter = ({node, text}) => {
13
11
  if (node.parent.parent.type !== 'ForOfStatement')
14
12
  return false;
15
13
 
16
14
  return text.includes('\n');
17
15
  };
18
16
 
19
- module.exports.fix = ({text}) => {
17
+ export const fix = ({text}) => {
20
18
  return text
21
19
  .replace(/\n/g, '')
22
20
  .replace(/,/g, ', ')
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
- module.exports.report = () => {
1
+ export const report = () => {
4
2
  return `Unexpected new lines around arguments`;
5
3
  };
6
4
 
7
- module.exports.fix = ({text, node, getText}) => {
5
+ export const fix = ({text, node, getText}) => {
8
6
  const {body} = node.body;
9
7
 
10
8
  node.body.body = [];
@@ -23,13 +21,13 @@ module.exports.fix = ({text, node, getText}) => {
23
21
  return text.replace(paramsText, newText);
24
22
  };
25
23
 
26
- module.exports.include = () => [
24
+ export const include = () => [
27
25
  'FunctionDeclaration',
28
26
  'FunctionExpression',
29
27
  'ArrowFunctionExpression',
30
28
  ];
31
29
 
32
- module.exports.filter = ({text}) => {
30
+ export const filter = ({text}) => {
33
31
  const beforeCloseIndex = text.indexOf(')');
34
32
  const beforeCloseText = text.slice(0, beforeCloseIndex);
35
33
 
@@ -1,11 +1,11 @@
1
1
  import config from '@putout/eslint-config';
2
2
  import nPlugin from 'eslint-plugin-n';
3
- import markdown from './markdown.mjs';
4
- import json from './json.mjs';
5
- import html from './html.mjs';
6
- import ts from './ts.mjs';
7
- import jsxConfig, {jsx} from './jsx.mjs';
8
- import * as putout from './plugin.mjs';
3
+ import markdown from './markdown.js';
4
+ import json from './json.js';
5
+ import html from './html.js';
6
+ import ts from './ts.js';
7
+ import jsxConfig, {jsx} from './jsx.js';
8
+ import * as putout from './plugin.js';
9
9
 
10
10
  const n = nPlugin.configs['flat/mixed-esm-and-cjs'];
11
11
 
@@ -1,5 +1,5 @@
1
1
  import stylistic from '@stylistic/eslint-plugin';
2
- import * as putout from './plugin.mjs';
2
+ import * as putout from './plugin.js';
3
3
 
4
4
  export default [{
5
5
  name: 'putout: json',
@@ -1,7 +1,6 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
+ import {isCorrectLoc} from '../common.js';
2
3
 
3
- const {types} = require('putout');
4
- const {isCorrectLoc} = require('../common');
5
4
  const {
6
5
  isImportDeclaration,
7
6
  isForOfStatement,
@@ -20,15 +19,15 @@ const parseOptions = (options) => {
20
19
 
21
20
  const notImportDefaultSpecifier = (a) => a.type !== 'ImportDefaultSpecifier';
22
21
 
23
- module.exports.category = 'destructuring';
24
- module.exports.report = () => 'Keep each property on separate lines when destructuring long properties';
22
+ export const category = 'destructuring';
23
+ export const report = () => 'Keep each property on separate lines when destructuring long properties';
25
24
 
26
- module.exports.include = () => [
25
+ export const include = () => [
27
26
  'VariableDeclarator[id.type="ObjectPattern"][id.properties.length>=2]',
28
27
  'ImportDeclaration[specifiers.length>=2]',
29
28
  ];
30
29
 
31
- module.exports.fix = ({text}) => {
30
+ export const fix = ({text}) => {
32
31
  const end = text.indexOf('}') + 1;
33
32
 
34
33
  const startText = text
@@ -42,7 +41,7 @@ module.exports.fix = ({text}) => {
42
41
  return `${startText}${endText}`;
43
42
  };
44
43
 
45
- module.exports.filter = ({node}, options) => {
44
+ export const filter = ({node}, options) => {
46
45
  const {parent} = node.parent;
47
46
  const {maxLength} = parseOptions(options);
48
47
 
@@ -1,8 +1,8 @@
1
1
  import * as parserOpts from '@putout/engine-parser/babel/options';
2
2
  import parserPlugins from '@putout/engine-parser/babel/plugins';
3
3
  import babel from '#babel/eslint-parser/experimental-worker';
4
- import tsConfig from './ts.mjs';
5
- import {jsx} from './jsx.mjs';
4
+ import tsConfig from './ts.js';
5
+ import {jsx} from './jsx.js';
6
6
 
7
7
  const [ts, tsx] = tsConfig;
8
8
 
@@ -1,15 +1,14 @@
1
- 'use strict';
2
-
3
- const {isImportDeclaration} = require('putout').types;
4
- const {parseImportSpecifiers} = require('parse-import-specifiers');
5
-
6
- const {
1
+ import {types} from 'putout';
2
+ import {parseImportSpecifiers} from 'parse-import-specifiers';
3
+ import {
7
4
  isCorrectLoc,
8
5
  isCorrectImportLoc,
9
- } = require('../common');
6
+ } from '../common.js';
7
+
8
+ const {isImportDeclaration} = types;
10
9
 
11
- module.exports.category = 'destructuring';
12
- module.exports.report = () => 'Keep each property on separate lines when using multiple destructuring properties';
10
+ export const category = 'destructuring';
11
+ export const report = () => 'Keep each property on separate lines when using multiple destructuring properties';
13
12
 
14
13
  const parseOptions = (options) => {
15
14
  const {minProperties = 2} = options[0] || {};
@@ -19,7 +18,7 @@ const parseOptions = (options) => {
19
18
  };
20
19
  };
21
20
 
22
- module.exports.include = ({options}) => {
21
+ export const include = ({options}) => {
23
22
  const {minProperties} = parseOptions(options);
24
23
 
25
24
  return [
@@ -28,7 +27,7 @@ module.exports.include = ({options}) => {
28
27
  ];
29
28
  };
30
29
 
31
- module.exports.filter = ({node}, options) => {
30
+ export const filter = ({node}, options) => {
32
31
  const {minProperties} = parseOptions(options);
33
32
  const {line} = node.loc.start;
34
33
 
@@ -55,7 +54,7 @@ module.exports.filter = ({node}, options) => {
55
54
  return !isCorrectLoc(line, properties);
56
55
  };
57
56
 
58
- module.exports.fix = ({text}) => {
57
+ export const fix = ({text}) => {
59
58
  return text
60
59
  .replace(/,/g, ',\n')
61
60
  .replace('{', '{\n')
@@ -1,12 +1,10 @@
1
- 'use strict';
1
+ export const report = () => 'Add new line before and after arguments in a function call';
2
2
 
3
- module.exports.report = () => 'Add new line before and after arguments in a function call';
4
-
5
- module.exports.include = () => [
3
+ export const include = () => [
6
4
  'CallExpression',
7
5
  ];
8
6
 
9
- module.exports.filter = ({node, text}) => {
7
+ export const filter = ({node, text}) => {
10
8
  if (node.callee.type !== 'Identifier')
11
9
  return false;
12
10
 
@@ -34,7 +32,7 @@ module.exports.filter = ({node, text}) => {
34
32
  return !(isOpenBracket && isCloseBracket);
35
33
  };
36
34
 
37
- module.exports.fix = ({text}) => {
35
+ export const fix = ({text}) => {
38
36
  return text
39
37
  .replace('(', '(\n')
40
38
  .replace(/,\s?/g, ',\n')
@@ -1,16 +1,14 @@
1
- 'use strict';
2
-
3
- const process = require('node:process');
4
- const {accessSync} = require('node:fs');
5
-
6
- const {
1
+ import process from 'node:process';
2
+ import {accessSync} from 'node:fs';
3
+ import {
7
4
  extname,
8
5
  dirname,
9
6
  join,
10
- } = require('node:path');
11
-
12
- const {tryCatch} = require('try-catch');
7
+ } from 'node:path';
8
+ import {createRequire} from 'node:module';
9
+ import {tryCatch} from 'try-catch';
13
10
 
11
+ const require = createRequire(import.meta.url);
14
12
  const cwd = process.cwd();
15
13
 
16
14
  const RELATIVE = '\\.\\.?\\/?';
@@ -19,16 +17,16 @@ const isRelativeEnd = (a) => RegExp(`${RELATIVE}$`).test(a);
19
17
  const getDir = (a) => a === '<input>' ? cwd : dirname(a);
20
18
  const getValue = ({source}) => source?.value;
21
19
 
22
- module.exports.category = 'errors';
23
- module.exports.report = () => 'Always add an extension to relative imports';
24
- module.exports.include = () => [
20
+ export const category = 'errors';
21
+ export const report = () => 'Always add an extension to relative imports';
22
+ export const include = () => [
25
23
  'ImportDeclaration',
26
24
  'ImportExpression',
27
25
  'ExportAllDeclaration',
28
26
  'ExportNamedDeclaration',
29
27
  ];
30
28
 
31
- module.exports.fix = ({node, text, filename}) => {
29
+ export const fix = ({node, text, filename}) => {
32
30
  const value = getValue(node);
33
31
  const dir = getDir(filename);
34
32
 
@@ -40,7 +38,7 @@ module.exports.fix = ({node, text, filename}) => {
40
38
  return text.replace(value, resolved);
41
39
  };
42
40
 
43
- module.exports.filter = ({node}) => {
41
+ export const filter = ({node}) => {
44
42
  const value = getValue(node);
45
43
 
46
44
  if (!value || value.endsWith('.js'))