@putout/plugin-putout 23.15.1 → 24.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.
Files changed (79) hide show
  1. package/README.md +28 -0
  2. package/lib/add-await-to-progress/index.js +4 -5
  3. package/lib/add-index-to-import/index.js +6 -10
  4. package/lib/add-path-arg-to-fix/index.js +4 -5
  5. package/lib/add-path-arg-to-visitors/index.js +4 -5
  6. package/lib/add-places-to-compare-places/index.js +2 -4
  7. package/lib/add-test-args/index.js +12 -3
  8. package/lib/add-track-file/index.js +12 -3
  9. package/lib/add-traverse-args/index.js +6 -7
  10. package/lib/apply-async-formatter/index.js +3 -4
  11. package/lib/apply-create-nested-directory/index.js +4 -5
  12. package/lib/apply-create-test/index.js +2 -4
  13. package/lib/apply-declare/index.js +2 -4
  14. package/lib/apply-exports-to-add-args/index.js +12 -0
  15. package/lib/apply-fixture-name-to-message/index.js +4 -5
  16. package/lib/apply-for-of-to-track-file/index.js +2 -4
  17. package/lib/apply-insert-after/index.js +2 -4
  18. package/lib/apply-insert-before/index.js +2 -4
  19. package/lib/apply-lowercase-to-node-builders/index.js +4 -5
  20. package/lib/apply-namespace-specifier/index.js +5 -7
  21. package/lib/apply-parens/index.js +2 -4
  22. package/lib/apply-processors-destructuring/index.js +2 -4
  23. package/lib/apply-remove/index.js +2 -4
  24. package/lib/apply-rename/index.js +2 -4
  25. package/lib/apply-report/index.js +3 -4
  26. package/lib/apply-short-processors/index.js +4 -6
  27. package/lib/apply-vars/index.js +4 -5
  28. package/lib/check-declare/index.js +5 -8
  29. package/lib/check-match/index.js +4 -6
  30. package/lib/check-replace-code/generate-code/index.js +5 -8
  31. package/lib/check-replace-code/generate-code/plugin-generate.js +4 -6
  32. package/lib/check-replace-code/index.js +7 -9
  33. package/lib/convert-add-argument-to-add-args/index.js +3 -4
  34. package/lib/convert-babel-types/index.js +4 -6
  35. package/lib/convert-destructuring-to-identifier/index.js +5 -5
  36. package/lib/convert-dirname-to-url/index.js +4 -5
  37. package/lib/convert-find-to-traverse/index.js +4 -6
  38. package/lib/convert-get-rule-to-require/index.js +9 -11
  39. package/lib/convert-include-to-traverse/index.js +4 -5
  40. package/lib/convert-match-to-function/index.js +2 -4
  41. package/lib/convert-method-to-property/index.js +5 -7
  42. package/lib/convert-node-to-path-in-get-template-values/index.js +4 -6
  43. package/lib/convert-number-to-numeric/index.js +4 -5
  44. package/lib/convert-process-to-find/index.js +4 -4
  45. package/lib/convert-progress-to-track-file/index.js +4 -6
  46. package/lib/convert-putout-test-to-create-test/index.js +5 -6
  47. package/lib/convert-replace-to-function/index.js +2 -4
  48. package/lib/convert-replace-with/index.js +6 -8
  49. package/lib/convert-replace-with-multiple/index.js +5 -7
  50. package/lib/convert-report-to-function/index.js +4 -5
  51. package/lib/convert-to-no-transform-code/index.js +4 -5
  52. package/lib/convert-traverse-to-include/index.js +5 -7
  53. package/lib/convert-traverse-to-replace/index.js +4 -5
  54. package/lib/convert-traverse-to-scan/index.js +5 -7
  55. package/lib/convert-url-to-dirname/index.js +4 -5
  56. package/lib/create-test/index.js +5 -6
  57. package/lib/declare/get-rule.js +4 -4
  58. package/lib/declare/index.js +4 -6
  59. package/lib/declare/operator/filesystem.js +2 -3
  60. package/lib/declare/operator/index.js +5 -7
  61. package/lib/declare/operator/json.js +1 -3
  62. package/lib/declare/operator/keyword.js +1 -3
  63. package/lib/declare/operator/parens.js +1 -3
  64. package/lib/declare/types.js +1179 -0
  65. package/lib/declare-path-variable/index.js +4 -5
  66. package/lib/declare-template-variables/index.js +4 -5
  67. package/lib/includer/index.js +2 -4
  68. package/lib/index.js +68 -68
  69. package/lib/move-require-on-top-level/index.js +5 -7
  70. package/lib/remove-empty-array-from-process/index.js +2 -4
  71. package/lib/remove-unused-get-properties-argument/index.js +4 -5
  72. package/lib/remove-useless-printer-option/index.js +4 -5
  73. package/lib/rename-operate-to-operator/index.js +5 -6
  74. package/lib/replace-operate-with-operator/index.js +2 -4
  75. package/lib/replace-test-message/index.js +4 -5
  76. package/lib/shorten-imports/index.js +2 -4
  77. package/lib/simplify-replace-template/index.js +5 -6
  78. package/package.json +7 -7
  79. package/lib/declare/types.json +0 -1179
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {operator, types} from 'putout';
2
2
 
3
- const {operator, types} = require('putout');
4
3
  const {
5
- traverse,
6
4
  remove,
7
5
  rename,
8
6
  getProperty,
@@ -19,9 +17,9 @@ const {
19
17
  isVariableDeclarator,
20
18
  } = types;
21
19
 
22
- module.exports.report = () => `Use Scanner instead of Traverser`;
20
+ export const report = () => `Use Scanner instead of Traverser`;
23
21
 
24
- module.exports.fix = ({path, pathProperty}) => {
22
+ export const fix = ({path, pathProperty}) => {
25
23
  if (path.isObjectMethod()) {
26
24
  replaceWith(path.parentPath, path.get('body'));
27
25
  path.parentPath.parentPath.node.params.unshift(identifier('path'));
@@ -57,7 +55,7 @@ module.exports.fix = ({path, pathProperty}) => {
57
55
 
58
56
  const {path: programPath} = path.scope.getProgramParent();
59
57
 
60
- traverse(programPath, {
58
+ operator.traverse(programPath, {
61
59
  'module.exports.fix = (__object) => __': (path) => {
62
60
  const rightPath = path.get('right');
63
61
  const [argPath] = rightPath.get('params');
@@ -87,7 +85,7 @@ module.exports.fix = ({path, pathProperty}) => {
87
85
  }
88
86
  };
89
87
 
90
- module.exports.traverse = ({push}) => ({
88
+ export const traverse = ({push}) => ({
91
89
  'ObjectMethod|ObjectProperty'(path) {
92
90
  if (!isFilesystemPath(path))
93
91
  return;
@@ -1,14 +1,13 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {isESM} = operator;
5
4
 
6
- module.exports.report = () => `Use 'createTest(__dirname)' instead of 'createTest(import.meta.url)' in CommonJS'`;
5
+ export const report = () => `Use 'createTest(__dirname)' instead of 'createTest(import.meta.url)' in CommonJS'`;
7
6
 
8
- module.exports.match = () => ({
7
+ export const match = () => ({
9
8
  'createTest(import.meta.url, __a)': (vars, path) => !isESM(path),
10
9
  });
11
10
 
12
- module.exports.replace = () => ({
11
+ export const replace = () => ({
13
12
  'createTest(import.meta.url, __a)': 'createTest(__dirname, __a)',
14
13
  });
@@ -1,6 +1,5 @@
1
- 'use strict';
1
+ import {operator, types} from 'putout';
2
2
 
3
- const {operator, types} = require('putout');
4
3
  const {
5
4
  arrayExpression,
6
5
  objectExpression,
@@ -12,14 +11,14 @@ const {
12
11
 
13
12
  const {replaceWith, getProperty} = operator;
14
13
 
15
- module.exports.report = () => `Apply modifications to 'createTest()' options`;
14
+ export const report = () => `Apply modifications to 'createTest()' options`;
16
15
 
17
- module.exports.include = () => [
16
+ export const include = () => [
18
17
  'createTest(__dirname, __object)',
19
18
  'createTest(import.meta.url, __object)',
20
19
  ];
21
20
 
22
- module.exports.fix = (path, {options}) => {
21
+ export const fix = (path, {options}) => {
23
22
  const objectPath = path.get('arguments.1');
24
23
 
25
24
  if (!getProperty(objectPath, 'plugins'))
@@ -34,7 +33,7 @@ module.exports.fix = (path, {options}) => {
34
33
  }
35
34
  };
36
35
 
37
- module.exports.filter = (path, {options}) => {
36
+ export const filter = (path, {options}) => {
38
37
  if (!options.add)
39
38
  return false;
40
39
 
@@ -1,7 +1,7 @@
1
- 'use strict';
1
+ import {createRequire} from 'node:module';
2
2
 
3
- const getRule = (name, options = 'on') => ({
3
+ const require = createRequire(import.meta.url);
4
+
5
+ export const getRule = (name, options = 'on') => ({
4
6
  [name]: [options, require(`./${name}`)],
5
7
  });
6
-
7
- module.exports.getRule = getRule;
@@ -1,10 +1,8 @@
1
- 'use strict';
1
+ import operator from './operator/index.js';
2
+ import {getRule} from './get-rule.js';
3
+ import types from './types.js';
2
4
 
3
- const types = require('./types');
4
- const operator = require('./operator');
5
- const {getRule} = require('./get-rule');
6
-
7
- module.exports.declare = () => ({
5
+ export const declare = () => ({
8
6
  types: `import {types} from 'putout'`,
9
7
  ...types,
10
8
  template: `import {template} from 'putout'`,
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports = {
1
+ export default {
4
2
  findFile: 'const {findFile} = operator',
5
3
  renameFile: 'const {renameFile} = operator',
6
4
  renameFiles: 'const {renameFiles} = operator',
@@ -17,4 +15,5 @@ module.exports = {
17
15
  writeFileContent: 'const {writeFileContent} = operator',
18
16
  copyFile: 'const {copyFile} = operator',
19
17
  readDirectory: 'const {readDirectory} = operator',
18
+ removeEmptyDirectory: 'const {removeEmptyDirectory} = operator',
20
19
  };
@@ -1,11 +1,9 @@
1
- 'use strict';
1
+ import filesystem from './filesystem.js';
2
+ import json from './json.js';
3
+ import keyword from './keyword.js';
4
+ import parens from './parens.js';
2
5
 
3
- const filesystem = require('./filesystem');
4
- const json = require('./json');
5
- const keyword = require('./keyword');
6
- const parens = require('./parens');
7
-
8
- module.exports = {
6
+ export default {
9
7
  ...filesystem,
10
8
  ...json,
11
9
  ...keyword,
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports = {
1
+ export default {
4
2
  toJS: 'const {toJS} = operator',
5
3
  fromJS: 'const {fromJS} = operator',
6
4
  __filesystem: 'const {__filesystem} = operator',
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports = {
1
+ export default {
4
2
  isKeyword: 'const {isKeyword} = operator',
5
3
  isDeclarationKeyword: 'const {isDeclarationKeyword} = operator',
6
4
  isModuleDeclarationKeyword: 'const {isModuleDeclarationKeyword} = operator',
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports = {
1
+ export default {
4
2
  addParens: 'const {addParens} = operator',
5
3
  removeParens: 'const {removeParens} = operator',
6
4
  hasParens: 'const {hasParens} = operator',