Skip to content

Commit 44f03b7

Browse files
committed
Explicitely check for + and - prefixes
1 parent 7f1c9b3 commit 44f03b7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/rules/no-unused-prop-types.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,11 @@ module.exports = {
273273
*/
274274
function getKeyValue(node) {
275275
if (node.type === 'ObjectTypeProperty') {
276-
const tokens = context.getFirstTokens(node, {count: 1, filter: tokenNode => ['Identifier', 'String'].indexOf(tokenNode.type) >= 0});
277-
return stripQuotes(tokens[0].value);
276+
const tokens = context.getFirstTokens(node, 2);
277+
return (tokens[0].value === '+' || tokens[0].value === '-'
278+
? tokens[1].value
279+
: stripQuotes(tokens[0].value)
280+
);
278281
}
279282
const key = node.key || node.argument;
280283
return key.type === 'Identifier' ? key.name : key.value;

lib/rules/prop-types.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,11 @@ module.exports = {
343343
*/
344344
function getKeyValue(node) {
345345
if (node.type === 'ObjectTypeProperty') {
346-
const tokens = context.getFirstTokens(node, {count: 1, filter: tokenNode => ['Identifier', 'String'].indexOf(tokenNode.type) >= 0});
347-
return stripQuotes(tokens[0].value);
346+
const tokens = context.getFirstTokens(node, 2);
347+
return (tokens[0].value === '+' || tokens[0].value === '-'
348+
? tokens[1].value
349+
: stripQuotes(tokens[0].value)
350+
);
348351
}
349352
const key = node.key || node.argument;
350353
return key.type === 'Identifier' ? key.name : key.value;

0 commit comments

Comments
 (0)