Skip to content

Commit

Permalink
Use short version of Regex
Browse files Browse the repository at this point in the history
Fixes error: "TypeError: Cannot supply flags when constructing one RegExp from another"
  • Loading branch information
rafbgarcia committed Dec 13, 2019
1 parent af69522 commit 94e608d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -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} :
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 94e608d

Please sign in to comment.