diff --git a/src/get-string-if-constant.js b/src/get-string-if-constant.js
index 61c5370..8deeaf6 100644
--- a/src/get-string-if-constant.js
+++ b/src/get-string-if-constant.js
@@ -7,6 +7,16 @@ import { getStaticValue } from "./get-static-value"
* @returns {string|null} The value of the node, or `null`.
*/
export function getStringIfConstant(node, initialScope = null) {
+ // Handle the literals that the platform doesn't support natively.
+ if (node.type === "Literal" && node.value === null) {
+ if (node.regex) {
+ return `/${node.regex.pattern}/${node.regex.flags}`
+ }
+ if (node.bigint) {
+ return node.bigint
+ }
+ }
+
const evaluated = getStaticValue(node, initialScope)
return evaluated && String(evaluated.value)
}
diff --git a/test/get-string-if-constant.js b/test/get-string-if-constant.js
index 2761d25..b100410 100644
--- a/test/get-string-if-constant.js
+++ b/test/get-string-if-constant.js
@@ -19,6 +19,7 @@ describe("The 'getStringIfConstant' function", () => {
{ code: "`aaa${id}bbb`", expected: null }, //eslint-disable-line no-template-curly-in-string
{ code: "1 + 2", expected: "3" },
{ code: "'a' + 'b'", expected: "ab" },
+ { code: "/(?\\w+)\\k/gu", expected: "/(?\\w+)\\k/gu" },
]) {
it(`should return ${JSON.stringify(expected)} from ${code}`, () => {
const linter = new eslint.Linter()