Skip to content

Commit

Permalink
Use double quote for transformed displayName and data-*
Browse files Browse the repository at this point in the history
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"`.
  • Loading branch information
chenglou committed Oct 31, 2014
1 parent 1666661 commit eddbb0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('react displayName jsx', function() {
var code = [
'"use strict";',
'var Whateva = React.createClass({',
' displayName: \'Whateva\',',
' displayName: "Whateva",',
' render: function() {',
' return null;',
' }',
Expand All @@ -34,7 +34,7 @@ describe('react displayName jsx', function() {
var result = [
'"use strict";',
'var Whateva = React.createClass({',
' displayName: \'Whateva\',',
' displayName: "Whateva",',
' render: function() {',
' return null;',
' }',
Expand All @@ -54,7 +54,7 @@ describe('react displayName jsx', function() {
].join('\n');

var result = [
'var Component = React.createClass({displayName: \'Component\',',
'var Component = React.createClass({displayName: "Component",',
' render: function() {',
' return null;',
' }',
Expand All @@ -76,7 +76,7 @@ describe('react displayName jsx', function() {

var result = [
'var Component;',
'Component = React.createClass({displayName: \'Component\',',
'Component = React.createClass({displayName: "Component",',
' render: function() {',
' return null;',
' }',
Expand All @@ -96,7 +96,7 @@ describe('react displayName jsx', function() {
].join('\n');

var result = [
'exports.Component = React.createClass({displayName: \'Component\',',
'exports.Component = React.createClass({displayName: "Component",',
' render: function() {',
' return null;',
' }',
Expand All @@ -119,7 +119,7 @@ describe('react displayName jsx', function() {

var result = [
'exports = {',
' Component: React.createClass({displayName: \'Component\',',
' Component: React.createClass({displayName: "Component",',
' render: function() {',
' return null;',
' }',
Expand Down
2 changes: 1 addition & 1 deletion vendor/fbtransform/transforms/reactDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function addDisplayName(displayName, object, state) {

if (safe) {
utils.catchup(object['arguments'][0].range[0] + 1, state);
utils.append("displayName: '" + displayName + "',", state);
utils.append('displayName: "' + displayName + '",', state);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/fbtransform/transforms/xjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
function quoteAttrName(attr) {
// Quote invalid JS identifiers.
if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
return "'" + attr + "'";
return '"' + attr + '"';
}
return attr;
}
Expand Down

0 comments on commit eddbb0c

Please sign in to comment.