From 94e608d2063e34916e1e5bfa997722326b1ed861 Mon Sep 17 00:00:00 2001 From: Rafael Garcia Date: Fri, 13 Dec 2019 10:40:59 -0300 Subject: [PATCH] Use short version of Regex Fixes error: "TypeError: Cannot supply flags when constructing one RegExp from another" --- lib/rules/jsx-curly-brace-presence.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);