regexp/no-missing-g-flag
💼 This rule is enabled in the following configs: 🟢 flat/recommended
, 🔵 recommended
.
🔧 This rule is automatically fixable by the --fix
CLI option.
disallow missing
g
flag in patterns used inString#matchAll
andString#replaceAll
📖 Rule Details
When calling String#matchAll()
and String#replaceAll()
with a RegExp
missing the global (g
) flag, it will be a runtime error. This rule reports RegExp
s missing the global (g
) flag that cause these errors.
🔧 Options
json
{
"regexp/no-missing-g-flag": ["error",
{
"strictTypes": true
}
]
}
strictTypes
... Iftrue
, strictly check the type of object to determine if the regex instance was used inmatchAll()
andreplaceAll()
. Default istrue
.
This option is always on when using TypeScript.
📚 Further reading
🚀 Version
This rule was introduced in eslint-plugin-regexp v1.10.0