Repository: eslint/eslint
File: tests/lib/rules/no-unused-vars.js (JavaScript)

Code before:
        {
            code: "export default (a) => {};",
            languageOptions: { ecmaVersion: 6, sourceType: "module" },
            errors: [definedError("a")]
        },
        {
            code: "export default (a, b) => { console.log(a); };",
            languageOptions: { ecmaVersion: 6, sourceType: "module" },
            errors: [definedError("b")]
        },

        // caughtErrors
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all" }],
            errors: [definedError("err")]
        },
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore" }],
            errors: [definedError("err", ". Allowed unused args must match /^ignore/u")]
        },
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all", varsIgnorePattern: "^err" }],
            errors: [definedError("err", ". Allowed unused vars must match /^err/u")]
        },

        // multiple try catch with one success
        {
            code: "try{}catch(ignoreErr){}try{}catch(err){};",
            options: [{ caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore" }],
            errors: [definedError("err", ". Allowed unused args must match /^ignore/u")]
        },

        // multiple try catch both fail
        {
            code: "try{}catch(error){}try{}catch(err){};",
            options: [{ caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore" }],
            errors: [
                definedError("error", ". Allowed unused args must match /^ignore/u"),
                definedError("err", ". Allowed unused args must match /^ignore/u")
            ]
        },

        // caughtErrors with other configs
        {
            code: "try{}catch(err){};",
            options: [{ vars: "all", args: "all", caughtErrors: "all" }],
            errors: [definedError("err")]
        },

Review comment (suggestion):
Since `varsIgnorePattern` should not apply to the catch block, the error message should not contain `Allowed unused vars must match /^err/u"`

Code after:
        {
            code: "export default (a) => {};",
            languageOptions: { ecmaVersion: 6, sourceType: "module" },
            errors: [definedError("a")]
        },
        {
            code: "export default (a, b) => { console.log(a); };",
            languageOptions: { ecmaVersion: 6, sourceType: "module" },
            errors: [definedError("b")]
        },

        // caughtErrors
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all" }],
            errors: [definedError("err")]
        },
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore" }],
            errors: [definedError("err", ". Allowed unused args must match /^ignore/u")]
        },
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all", varsIgnorePattern: "^err" }],
            errors: [definedError("err")]
        },
        {
            code: "try{}catch(err){};",
            options: [{ caughtErrors: "all", varsIgnorePattern: "^." }],
            errors: [definedError("err")]
        },

        // multiple try catch with one success
        {
            code: "try{}catch(ignoreErr){}try{}catch(err){};",
            options: [{ caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore" }],
            errors: [definedError("err", ". Allowed unused args must match /^ignore/u")]
        },

        // multiple try catch both fail
        {
            code: "try{}catch(error){}try{}catch(err){};",
            options: [{ caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore" }],
            errors: [
                definedError("error", ". Allowed unused args must match /^ignore/u"),
                definedError("err", ". Allowed unused args must match /^ignore/u")
            ]
        },

        // caughtErrors with other configs