@putout/plugin-putout 24.2.0 → 24.3.1

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
@@ -27,6 +27,7 @@ npm i @putout/plugin-putout -D
27
27
  - ✅ [apply-declare](#apply-declare);
28
28
  - ✅ [apply-exports-to-add-args](#apply-exports-to-add-args);
29
29
  - ✅ [apply-exports-to-match-files](#apply-exports-to-match-files);
30
+ - ✅ [apply-exports-to-rename-files](#apply-exports-to-rename-files);
30
31
  - ✅ [apply-for-of-to-track-file](#apply-for-of-to-track-file);
31
32
  - ✅ [apply-fixture-name-to-message](#apply-fixture-name-to-message);
32
33
  - ✅ [apply-insert-after](#apply-insert-after);
@@ -100,6 +101,7 @@ npm i @putout/plugin-putout -D
100
101
  "putout/apply-declare": "on",
101
102
  "putout/apply-exports-to-add-args": "on",
102
103
  "putout/apply-exports-to-match-files": "on",
104
+ "putout/apply-exports-to-rename-files": "on",
103
105
  "putout/apply-report": "on",
104
106
  "putout/apply-processors-destructuring": "on",
105
107
  "putout/apply-rename": "on",
@@ -516,6 +518,44 @@ export {
516
518
  };
517
519
  ```
518
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
+
519
559
  ## apply-async-formatter
520
560
 
521
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)': `{
@@ -1,4 +1,4 @@
1
- export const report = () => `Apply 'exports' to 'matchFiles`;
1
+ export const report = () => `Apply 'exports' to 'matchFiles()'`;
2
2
 
3
3
  export const replace = () => ({
4
4
  'export default matchFiles(__args)': `{
@@ -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} = renameFiles(__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,4 @@
1
+ import * as applyExportsToRenameFiles from './apply-exports-to-rename-files/index.js';
1
2
  import * as applyExportsToMatchFiles from './apply-exports-to-match-files/index.js';
2
3
  import * as applyProcessorsDestructuring from './apply-processors-destructuring/index.js';
3
4
  import * as applyAsyncFormatter from './apply-async-formatter/index.js';
@@ -134,4 +135,5 @@ export const rules = {
134
135
  'apply-create-nested-directory': applyCreateNestedDirectory,
135
136
  'apply-report': applyReport,
136
137
  'apply-exports-to-match-files': applyExportsToMatchFiles,
138
+ 'apply-exports-to-rename-files': applyExportsToRenameFiles,
137
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "24.2.0",
3
+ "version": "24.3.1",
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
- });