Skip to content

Commit dc59667

Browse files
committed
[Fix] support JSXText nodes alongside Literal nodes
1 parent 2889e89 commit dc59667

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

lib/rules/forbid-foreign-prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = {
8181
!isLeftSideOfAssignment(node) &&
8282
!isAllowedAssignment(node)
8383
) || (
84-
node.property.type === 'Literal' &&
84+
(node.property.type === 'Literal' || node.property.type === 'JSXText') &&
8585
node.property.value === 'propTypes' &&
8686
!isLeftSideOfAssignment(node) &&
8787
!isAllowedAssignment(node)

lib/rules/jsx-curly-brace-presence.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ module.exports = {
171171
const parentType = JSXExpressionNode.parent.type;
172172

173173
if (
174-
expressionType === 'Literal' &&
174+
(expressionType === 'Literal' || expressionType === 'JSXText') &&
175175
typeof expression.value === 'string' &&
176176
!needToEscapeCharacterForJSX(expression.raw) && (
177177
parentType === 'JSXElement' ||
@@ -246,13 +246,7 @@ module.exports = {
246246
}
247247
},
248248

249-
Literal: node => {
250-
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
251-
reportMissingCurly(node);
252-
}
253-
},
254-
255-
JSXText: node => {
249+
'Literal, JSXText': node => {
256250
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
257251
reportMissingCurly(node);
258252
}

lib/rules/no-unescaped-entities.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ module.exports = {
7171
}
7272

7373
return {
74-
Literal: function(node) {
75-
if (node.parent.type === 'JSXElement') {
76-
reportInvalidEntity(node);
77-
}
78-
},
79-
80-
JSXText: function(node) {
74+
'Literal, JSXText': function(node) {
8175
if (node.parent.type === 'JSXElement') {
8276
reportInvalidEntity(node);
8377
}

0 commit comments

Comments
 (0)