diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index 75eff45319..13370974d9 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -62,7 +62,7 @@ module.exports = { }, create(context) { - const HTML_ENTITY_REGEX = /&[A-Za-z\d#]+;/; + const HTML_ENTITY_REGEX = /&[A-Za-z\d#]+;/g; const ruleOptions = context.options[0]; const userConfig = typeof ruleOptions === 'string' ? {props: ruleOptions, children: ruleOptions} : @@ -81,7 +81,7 @@ module.exports = { } function containsOnlyHtmlEntities(rawStringValue) { - return rawStringValue.replace(new RegExp(HTML_ENTITY_REGEX, 'g'), '').trim() === ''; + return rawStringValue.replace(HTML_ENTITY_REGEX, '').trim() === ''; } function containsDisallowedJSXTextChars(rawStringValue) { @@ -126,7 +126,7 @@ module.exports = { word === '' ? '' : `{${JSON.stringify(word)}}` )).join(HTML_ENTITY); - const htmlEntities = text.match(new RegExp(HTML_ENTITY_REGEX, 'g')); + const htmlEntities = text.match(HTML_ENTITY_REGEX); return htmlEntities.reduce((acc, htmlEntitiy) => ( acc.replace(HTML_ENTITY, htmlEntitiy) ), withCurlyBraces);