@samitouri / QOS-React-2 / commits / eddbb0cfef

Use double quote for transformed `displayName` and `data-*`

JSX currently transforms everything to double quote except these two. This way, it's at least consistent and will satisfy half of the people who do put a strict quotation linting on their project. Test: `jest`, check the double quoted transformed `data-bla="something"`.

Cheng Lou committed Oct 31, 2014 at 15:47 UTC eddbb0cfef92f0fdaedae8da00449404f516eb86
3 files changed +8 -8
vendor/fbtransform/transforms/__tests__/react-displayName-test.js
+6 -6
@@ -24,7 +24,7 @@ describe('react displayName jsx', function() {
24 var code = [
25 '"use strict";',
26 'var Whateva = React.createClass({',
27 - ' displayName: \'Whateva\',',
27 + ' displayName: "Whateva",',
28 ' render: function() {',
29 ' return null;',
30 ' }',
@@ -34,7 +34,7 @@ describe('react displayName jsx', function() {
34 var result = [
35 '"use strict";',
36 'var Whateva = React.createClass({',
37 - ' displayName: \'Whateva\',',
37 + ' displayName: "Whateva",',
38 ' render: function() {',
39 ' return null;',
40 ' }',
@@ -54,7 +54,7 @@ describe('react displayName jsx', function() {
54 ].join('\n');
55
56 var result = [
57 - 'var Component = React.createClass({displayName: \'Component\',',
57 + 'var Component = React.createClass({displayName: "Component",',
58 ' render: function() {',
59 ' return null;',
60 ' }',
@@ -76,7 +76,7 @@ describe('react displayName jsx', function() {
76
77 var result = [
78 'var Component;',
79 - 'Component = React.createClass({displayName: \'Component\',',
79 + 'Component = React.createClass({displayName: "Component",',
80 ' render: function() {',
81 ' return null;',
82 ' }',
@@ -96,7 +96,7 @@ describe('react displayName jsx', function() {
96 ].join('\n');
97
98 var result = [
99 - 'exports.Component = React.createClass({displayName: \'Component\',',
99 + 'exports.Component = React.createClass({displayName: "Component",',
100 ' render: function() {',
101 ' return null;',
102 ' }',
@@ -119,7 +119,7 @@ describe('react displayName jsx', function() {
119
120 var result = [
121 'exports = {',
122 - ' Component: React.createClass({displayName: \'Component\',',
122 + ' Component: React.createClass({displayName: "Component",',
123 ' render: function() {',
124 ' return null;',
125 ' }',
vendor/fbtransform/transforms/reactDisplayName.js
+1 -1
@@ -33,7 +33,7 @@ function addDisplayName(displayName, object, state) {
33
34 if (safe) {
35 utils.catchup(object['arguments'][0].range[0] + 1, state);
36 - utils.append("displayName: '" + displayName + "',", state);
36 + utils.append('displayName: "' + displayName + '",', state);
37 }
38 }
39 }
vendor/fbtransform/transforms/xjs.js
+1 -1
@@ -231,7 +231,7 @@ function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
231 function quoteAttrName(attr) {
232 // Quote invalid JS identifiers.
233 if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
234 - return "'" + attr + "'";
234 + return '"' + attr + '"';
235 }
236 return attr;
237 }