Skip to content

Commit 086e2e2

Browse files
jakezateckySunil Pai
authored andcommitted
Consistently use printOptions (#145)
1 parent 036b16c commit 086e2e2

6 files changed

+15
-8
lines changed

transforms/React-DOM-to-react-dom-factories.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
module.exports = function(file, api, options) {
1414
const j = api.jscodeshift;
15+
const printOptions = options.printOptions || { quote: 'single' };
1516
const root = j(file.source);
1617

1718
let hasModifications;
@@ -187,6 +188,6 @@ module.exports = function(file, api, options) {
187188
hasModifications = replaceReactDOMReferences(j, root) || hasModifications;
188189

189190
return hasModifications
190-
? root.toSource({ quote: 'single' })
191+
? root.toSource(printOptions)
191192
: null;
192193
};

transforms/React-PropTypes-to-prop-types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
module.exports = function(file, api, options) {
1414
const j = api.jscodeshift;
15+
const printOptions = options.printOptions || { quote: 'single' };
1516
const root = j(file.source);
1617

1718
const MODULE_NAME = options['module-name'] || 'prop-types';
@@ -291,6 +292,6 @@ module.exports = function(file, api, options) {
291292
}
292293

293294
return hasModifications
294-
? root.toSource({ quote: 'single' })
295+
? root.toSource(printOptions)
295296
: null;
296297
};

transforms/ReactNative-View-propTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const isViewPropTypes = path => (
7373
module.exports = function(file, api, options) {
7474
const j = api.jscodeshift;
7575

76+
const printOptions = options.printOptions || { quote: 'single' };
7677
let root = j(file.source);
7778

7879
let numMatchedPaths = 0;
@@ -238,6 +239,6 @@ module.exports = function(file, api, options) {
238239
}
239240

240241
return numMatchedPaths > 0
241-
? root.toSource({ quote: 'single' })
242+
? root.toSource(printOptions)
242243
: null;
243244
};

transforms/create-element-to-jsx.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
module.exports = function(file, api, options) {
1414
const j = api.jscodeshift;
15+
const printOptions = options.printOptions || {};
1516
const root = j(file.source);
1617
const ReactUtils = require('./utils/ReactUtils')(j);
1718
const encodeJSXTextValue = value =>
@@ -251,7 +252,7 @@ module.exports = function(file, api, options) {
251252
.size();
252253

253254
if (mutations) {
254-
return root.toSource();
255+
return root.toSource(printOptions);
255256
}
256257
}
257258

transforms/manual-bind-to-arrow.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
* }
2222
*/
2323

24-
export default function transformer(file, api) {
24+
export default function transformer(file, api, options) {
2525
const j = api.jscodeshift;
2626

27+
const printOptions = options.printOptions || {};
2728
var root = j(file.source);
2829

2930
// Helper functions to transform a method declaration to an arrow function
@@ -174,7 +175,7 @@ export default function transformer(file, api) {
174175
});
175176

176177
if (hasChanged) {
177-
return transform.toSource();
178+
return transform.toSource(printOptions);
178179
}
179180
return null;
180181
}

transforms/react-to-react-dom.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ function isRequire(path, moduleName) {
5454
);
5555
}
5656

57-
module.exports = function(file, api) {
57+
module.exports = function(file, api, options) {
5858
var j = api.jscodeshift;
59+
60+
var printOptions = options.printOptions || {quote: 'single'};
5961
var root = j(file.source);
6062

6163
[
@@ -394,5 +396,5 @@ module.exports = function(file, api) {
394396
}
395397
});
396398

397-
return root.toSource({quote: 'single'});
399+
return root.toSource(printOptions);
398400
};

0 commit comments

Comments
 (0)