Repository: eslint/eslint
File: tests/lib/rules/no-invalid-regexp.js (JavaScript)

Code before:
            options: [{ allowConstructorFlags: ["a"] }]
        },

        // unknown pattern
        "new RegExp(pattern, 'g')",
        "new RegExp('.' + '', 'g')",
        "new RegExp(pattern, '')",
        "new RegExp(pattern)",

        // ES2020
        "new RegExp('(?<\\\\ud835\\\\udc9c>.)', 'g')",
        "new RegExp('(?<\\\\u{1d49c}>.)', 'g')",
        "new RegExp('(?<𝒜>.)', 'g');",
        "new RegExp('\\\\p{Script=Nandinagari}', 'u');",

        // ES2022
        "new RegExp('a+(?<Z>z)?', 'd')",
        "new RegExp('\\p{Script=Cpmn}', 'u')",
        "new RegExp('\\p{Script=Cypro_Minoan}', 'u')",
        "new RegExp('\\p{Script=Old_Uyghur}', 'u')",
        "new RegExp('\\p{Script=Ougr}', 'u')",
        "new RegExp('\\p{Script=Tangsa}', 'u')",
        "new RegExp('\\p{Script=Tnsa}', 'u')",
        "new RegExp('\\p{Script=Toto}', 'u')",
        "new RegExp('\\p{Script=Vith}', 'u')",
        "new RegExp('\\p{Script=Vithkuqi}', 'u')",

        // allowConstructorFlags
        {
            code: "new RegExp('.', 'g')",
            options: [{ allowConstructorFlags: [] }]
        },
        {
            code: "new RegExp('.', 'g')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp('.', 'a')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp('.', 'ag')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp('.', 'ga')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp(pattern, 'ga')",
            options: [{ allowConstructorFlags: ["a"] }]

Review comment (suggestion):
We need two more backslashes.

```suggestion
        "new RegExp('\\\\p{Script=Cpmn}', 'u')",
        "new RegExp('\\\\p{Script=Cypro_Minoan}', 'u')",
        "new RegExp('\\\\p{Script=Old_Uyghur}', 'u')",
        "new RegExp('\\\\p{Script=Ougr}', 'u')",
        "new RegExp('\\\\p{Script=Tangsa}', 'u')",
        "new RegExp('\\\\p{Script=Tnsa}', 'u')",
        "new RegExp('\\\\p{Script=Toto}', 'u')",
        "new RegExp('\\\\p{Script=Vith}', 'u')",
        "new RegExp('\\\\p{Script=Vithkuqi}', 'u')",
```

Code after:
            options: [{ allowConstructorFlags: ["a"] }]
        },

        // unknown pattern
        "new RegExp(pattern, 'g')",
        "new RegExp('.' + '', 'g')",
        "new RegExp(pattern, '')",
        "new RegExp(pattern)",

        // ES2020
        "new RegExp('(?<\\\\ud835\\\\udc9c>.)', 'g')",
        "new RegExp('(?<\\\\u{1d49c}>.)', 'g')",
        "new RegExp('(?<𝒜>.)', 'g');",
        "new RegExp('\\\\p{Script=Nandinagari}', 'u');",

        // ES2022
        "new RegExp('a+(?<Z>z)?', 'd')",
        "new RegExp('\\\\p{Script=Cpmn}', 'u')",
        "new RegExp('\\\\p{Script=Cypro_Minoan}', 'u')",
        "new RegExp('\\\\p{Script=Old_Uyghur}', 'u')",
        "new RegExp('\\\\p{Script=Ougr}', 'u')",
        "new RegExp('\\\\p{Script=Tangsa}', 'u')",
        "new RegExp('\\\\p{Script=Tnsa}', 'u')",
        "new RegExp('\\\\p{Script=Toto}', 'u')",
        "new RegExp('\\\\p{Script=Vith}', 'u')",
        "new RegExp('\\\\p{Script=Vithkuqi}', 'u')",

        // allowConstructorFlags
        {
            code: "new RegExp('.', 'g')",
            options: [{ allowConstructorFlags: [] }]
        },
        {
            code: "new RegExp('.', 'g')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp('.', 'a')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp('.', 'ag')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp('.', 'ga')",
            options: [{ allowConstructorFlags: ["a"] }]
        },
        {
            code: "new RegExp(pattern, 'ga')",
            options: [{ allowConstructorFlags: ["a"] }]