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

Code before:
            code: "new RegExp('.', 'aga');",
            options: [{ allowConstructorFlags: ["a"] }],
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid flags supplied to RegExp constructor 'ga'" },
                type: "NewExpression"
            }]
        },
        {
            code: "new RegExp(')');",
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /)/: Unmatched ')'" },
                type: "NewExpression"
            }]
        },
        {
            code: String.raw`new RegExp('\\a', 'u');`,
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /\\a/u: Invalid escape" },
                type: "NewExpression"
            }]
        },
        {
            code: String.raw`new RegExp('\\a', 'u');`,
            options: [{ allowConstructorFlags: ["u"] }],
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /\\a/u: Invalid escape" },
                type: "NewExpression"
            }]
        },
        {
            code: String.raw`RegExp('\\u{0}*');`,
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /\\u{0}*/: Nothing to repeat" },
                type: "CallExpression"
            }]
        },
        {
            code: String.raw`new RegExp('\\u{0}*');`,
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /\\u{0}*/: Nothing to repeat" },
                type: "NewExpression"
            }]
        },
        {
            code: String.raw`new RegExp('\\u{0}*', '');`,

Review comment (suggestion):
can you add a test like:
```js
            code: "new RegExp('.', 'uu');",
            options: [{ allowConstructorFlags: ["u"] }],
```

Code after:
            code: "new RegExp('.', 'azz');",
            options: [{ allowConstructorFlags: ["a", "z"] }],
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid flags supplied to RegExp constructor 'zz'" },
                type: "NewExpression"
            }]
        },
        {
            code: "new RegExp('.', 'aga');",
            options: [{ allowConstructorFlags: ["a"] }],
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid flags supplied to RegExp constructor 'aa'" },
                type: "NewExpression"
            }]
        },
        {
            code: "new RegExp('.', 'uu');",
            options: [{ allowConstructorFlags: ["u"] }],
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid flags supplied to RegExp constructor 'uu'" },
                type: "NewExpression"
            }]
        },
        {
            code: "new RegExp(')');",
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /)/: Unmatched ')'" },
                type: "NewExpression"
            }]
        },
        {
            code: String.raw`new RegExp('\\a', 'u');`,
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /\\a/u: Invalid escape" },
                type: "NewExpression"
            }]
        },
        {
            code: String.raw`new RegExp('\\a', 'u');`,
            options: [{ allowConstructorFlags: ["u"] }],
            errors: [{
                messageId: "regexMessage",
                data: { message: "Invalid regular expression: /\\a/u: Invalid escape" },
                type: "NewExpression"
            }]
        },