@putout/plugin-putout 24.1.0 → 24.3.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 CHANGED
@@ -26,6 +26,8 @@ npm i @putout/plugin-putout -D
26
26
  - ✅ [apply-create-nested-directory](#apply-create-nested-directory);
27
27
  - ✅ [apply-declare](#apply-declare);
28
28
  - ✅ [apply-exports-to-add-args](#apply-exports-to-add-args);
29
+ - ✅ [apply-exports-to-match-files](#apply-exports-to-match-files);
30
+ - ✅ [apply-exports-to-rename-files](#apply-exports-to-rename-files);
29
31
  - ✅ [apply-for-of-to-track-file](#apply-for-of-to-track-file);
30
32
  - ✅ [apply-fixture-name-to-message](#apply-fixture-name-to-message);
31
33
  - ✅ [apply-insert-after](#apply-insert-after);
@@ -98,6 +100,8 @@ npm i @putout/plugin-putout -D
98
100
  "putout/apply-async-formatter": "on",
99
101
  "putout/apply-declare": "on",
100
102
  "putout/apply-exports-to-add-args": "on",
103
+ "putout/apply-exports-to-match-files": "on",
104
+ "putout/apply-exports-to-rename-files": "on",
101
105
  "putout/apply-report": "on",
102
106
  "putout/apply-processors-destructuring": "on",
103
107
  "putout/apply-rename": "on",
@@ -484,6 +488,74 @@ export {
484
488
  };
485
489
  ```
486
490
 
491
+ ## apply-exports-to-match-files
492
+
493
+ Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/d40ac85b974249c51f9874919468fd30/4194c9b21d065bd1359ffc7298aaeb1835fbbb48).
494
+
495
+ ### ❌ Example of incorrect code
496
+
497
+ ```js
498
+ export default matchFiles({
499
+ '*.cjs': plugin,
500
+ });
501
+ ```
502
+
503
+ ### ✅ Example of correct code
504
+
505
+ ```js
506
+ const {
507
+ report,
508
+ fix,
509
+ scan,
510
+ } = matchFiles({
511
+ '*.cjs': plugin,
512
+ });
513
+
514
+ export {
515
+ report,
516
+ fix,
517
+ scan,
518
+ };
519
+ ```
520
+
521
+ ## apply-exports-to-rename-files
522
+
523
+ Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/999f7a582825fa88691ba87324365f3f/c679723b7ff2159d738ab7681f8c7c6460dd4326).
524
+
525
+ ### ❌ Example of incorrect code
526
+
527
+ ```js
528
+ export default renameFiles({
529
+ type: 'module',
530
+ mask: '*.mjs',
531
+ rename(name) {
532
+ return name.replace(/mjs$/, 'js');
533
+ },
534
+ });
535
+ ```
536
+
537
+ ### ✅ Example of correct code
538
+
539
+ ```js
540
+ const {
541
+ report,
542
+ fix,
543
+ scan,
544
+ } = renameFiles({
545
+ type: 'module',
546
+ mask: '*.mjs',
547
+ rename(name) {
548
+ return name.replace(/mjs$/, 'js');
549
+ },
550
+ });
551
+
552
+ export {
553
+ report,
554
+ fix,
555
+ scan,
556
+ };
557
+ ```
558
+
487
559
  ## apply-async-formatter
488
560
 
489
561
  ### ❌ Example of incorrect code
@@ -1,4 +1,4 @@
1
- export const report = () => `Apply exports to 'addArgs'`;
1
+ export const report = () => `Apply exports to 'addArgs()'`;
2
2
 
3
3
  export const replace = () => ({
4
4
  'export default addArgs(__args)': `{
@@ -0,0 +1,12 @@
1
+ export const report = () => `Apply 'exports' to 'matchFiles()'`;
2
+
3
+ export const replace = () => ({
4
+ 'export default matchFiles(__args)': `{
5
+ const {report, fix, scan} = matchFiles(__args);
6
+ export {
7
+ report,
8
+ fix,
9
+ scan,
10
+ };
11
+ }`,
12
+ });
@@ -0,0 +1,12 @@
1
+ export const report = () => `Apply 'exports' to 'renameFiles()`;
2
+
3
+ export const replace = () => ({
4
+ 'export default renameFiles(__args)': `{
5
+ const {report, fix, scan} = matchFiles(__args);
6
+ export {
7
+ report,
8
+ fix,
9
+ scan,
10
+ };
11
+ }`,
12
+ });
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports.getRule = (name, options = 'on') => ({
4
+ [name]: [options, require(`./${name}`)],
5
+ });
@@ -1,5 +1,5 @@
1
1
  import operator from './operator/index.js';
2
- import {getRule} from './get-rule.js';
2
+ import {getRule} from './get-rule.cjs';
3
3
  import types from './types.js';
4
4
 
5
5
  export const declare = () => ({
package/lib/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import * as applyExportsToRenameFiles from './apply-exports-to-rename-files/index.js';
2
+ import * as applyExportsToMatchFiles from './apply-exports-to-match-files/index.js';
1
3
  import * as applyProcessorsDestructuring from './apply-processors-destructuring/index.js';
2
4
  import * as applyAsyncFormatter from './apply-async-formatter/index.js';
3
5
  import * as applyCreateTest from './apply-create-test/index.js';
@@ -132,4 +134,6 @@ export const rules = {
132
134
  'apply-lowercase-to-node-builders': applyLowercaseToNodeBuilders,
133
135
  'apply-create-nested-directory': applyCreateNestedDirectory,
134
136
  'apply-report': applyReport,
137
+ 'apply-exports-to-match-files': applyExportsToMatchFiles,
138
+ 'apply-exports-to-rename-files': applyExportsToRenameFiles,
135
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "24.1.0",
3
+ "version": "24.3.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",
@@ -1,7 +0,0 @@
1
- import {createRequire} from 'node:module';
2
-
3
- const require = createRequire(import.meta.url);
4
-
5
- export const getRule = (name, options = 'on') => ({
6
- [name]: [options, require(`./${name}`)],
7
- });