File tree Expand file tree Collapse file tree 5 files changed +54
-0
lines changed
packages/rtk-codemods2/transforms/createSliceBuilder Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ # createSliceBuilder
2
+
3
+
4
+ ## Usage
5
+
6
+ ```
7
+ npx rtk-codemods2 createSliceBuilder path/of/files/ or/some**/*glob.js
8
+
9
+ # or
10
+
11
+ yarn global add rtk-codemods2
12
+ rtk-codemods2 createSliceBuilder path/of/files/ or/some**/*glob.js
13
+ ```
14
+
15
+ ## Local Usage
16
+ ```
17
+ node ./bin/cli.js createSliceBuilder path/of/files/ or/some**/*glob.js
18
+ ```
19
+
20
+ ## Input / Output
21
+
22
+ <!-- FIXTURES_TOC_START-->
23
+ <!-- FIXTURES_TOC_END-->
24
+
25
+ <!-- FIXTURES_CONTENT_START-->
26
+ <!-- FIXTURES_CONTENT_END-->
Original file line number Diff line number Diff line change
1
+ const { getParser } = require ( 'codemod-cli' ) . jscodeshift ;
2
+ const { getOptions } = require ( 'codemod-cli' ) ;
3
+
4
+ module . exports = function transformer ( file , api ) {
5
+ const j = getParser ( api ) ;
6
+ const options = getOptions ( ) ;
7
+
8
+ return j ( file . source )
9
+ . find ( j . Identifier )
10
+ . forEach ( path => {
11
+ path . node . name = path . node . name
12
+ . split ( '' )
13
+ . reverse ( )
14
+ . join ( '' ) ;
15
+ } )
16
+ . toSource ( ) ;
17
+ } ;
18
+
19
+ module . exports . type = 'js' ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const { runTransformTest } = require ( 'codemod-cli' ) ;
4
+
5
+ runTransformTest ( {
6
+ name : 'createSliceBuilder' ,
7
+ path : require . resolve ( './index.js' ) ,
8
+ fixtureDir : `${ __dirname } /__testfixtures__/` ,
9
+ } ) ;
You can’t perform that action at this time.
0 commit comments