Skip to content

Commit

Permalink
[Fix] support JSXText nodes alongside Literal nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 25, 2018
1 parent 2889e89 commit dc59667
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/rules/forbid-foreign-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = {
!isLeftSideOfAssignment(node) &&
!isAllowedAssignment(node)
) || (
node.property.type === 'Literal' &&
(node.property.type === 'Literal' || node.property.type === 'JSXText') &&
node.property.value === 'propTypes' &&
!isLeftSideOfAssignment(node) &&
!isAllowedAssignment(node)
Expand Down
10 changes: 2 additions & 8 deletions lib/rules/jsx-curly-brace-presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ module.exports = {
const parentType = JSXExpressionNode.parent.type;

if (
expressionType === 'Literal' &&
(expressionType === 'Literal' || expressionType === 'JSXText') &&
typeof expression.value === 'string' &&
!needToEscapeCharacterForJSX(expression.raw) && (
parentType === 'JSXElement' ||
Expand Down Expand Up @@ -246,13 +246,7 @@ module.exports = {
}
},

Literal: node => {
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
reportMissingCurly(node);
}
},

JSXText: node => {
'Literal, JSXText': node => {
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
reportMissingCurly(node);
}
Expand Down
8 changes: 1 addition & 7 deletions lib/rules/no-unescaped-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ module.exports = {
}

return {
Literal: function(node) {
if (node.parent.type === 'JSXElement') {
reportInvalidEntity(node);
}
},

JSXText: function(node) {
'Literal, JSXText': function(node) {
if (node.parent.type === 'JSXElement') {
reportInvalidEntity(node);
}
Expand Down

0 comments on commit dc59667

Please sign in to comment.