Skip to content

Commit 7bf5911

Browse files
committed
Use key.value for string literal
1 parent 5680a2b commit 7bf5911

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/rules/sort-prop-types.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ module.exports = {
5757
const propWrapperFunctions = new Set(context.settings.propWrapperFunctions || []);
5858

5959
function getKey(node) {
60-
const key = sourceCode.getText(node.key || node.argument);
61-
const hasLeadingQuote = /['"]/.test(key[0]);
62-
return hasLeadingQuote ? key.substring(1, key.length - 1) : key;
60+
if (node.key && node.key.value) {
61+
return node.key.value;
62+
}
63+
return sourceCode.getText(node.key || node.argument);
6364
}
6465

6566
function getValueName(node) {

0 commit comments

Comments
 (0)