mirror of
https://github.com/facebook/react.git
synced 2026-02-26 16:55:07 +00:00
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"`.
This commit is contained in:
@@ -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;',
|
||||
' }',
|
||||
@@ -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;',
|
||||
' }',
|
||||
@@ -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;',
|
||||
' }',
|
||||
@@ -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;',
|
||||
' }',
|
||||
@@ -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;',
|
||||
' }',
|
||||
@@ -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;',
|
||||
' }',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/fbtransform/transforms/xjs.js
vendored
2
vendor/fbtransform/transforms/xjs.js
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user