File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,14 +46,24 @@ $ npm install --save-dev babel-plugin-react-remove-properties
4646
4747** .babelrc**
4848
49- ``` json
49+ ``` js
50+ // without options
5051{
5152 " env" : {
5253 " production" : {
5354 " plugins" : [" react-remove-properties" ]
5455 }
5556 }
5657}
58+
59+ // with options
60+ {
61+ " env" : {
62+ " production" : {
63+ " plugins" : [" react-remove-properties" , {" property" : " data-test" }]
64+ }
65+ }
66+ }
5767```
5868
5969#### Via CLI
Original file line number Diff line number Diff line change 33module . exports = function ( ) {
44 return {
55 visitor : {
6- Program : function ( path ) {
6+ Program : function ( path , state ) {
77 // On program start, do an explicit traversal up front for this plugin.
8+ const property = state . opts . property || 'data-test' ;
89 path . traverse ( {
910 JSXIdentifier : function ( path ) {
10- if ( path . node . name === 'data-test' ) {
11+ if ( path . node . name === property ) {
1112 path . parentPath . remove ( ) ;
1213 }
1314 } ,
You can’t perform that action at this time.
0 commit comments