diff --git a/lib/rules/no-useless-catch.js b/lib/rules/no-useless-catch.js index 3211ed2c736..e4284cfb4f4 100644 --- a/lib/rules/no-useless-catch.js +++ b/lib/rules/no-useless-catch.js @@ -27,6 +27,7 @@ module.exports = { return { CatchClause(node) { if ( + node.param && node.param.type === "Identifier" && node.body.body.length && node.body.body[0].type === "ThrowStatement" && diff --git a/tests/lib/rules/no-useless-catch.js b/tests/lib/rules/no-useless-catch.js index 8c1a7118e20..93989a40352 100644 --- a/tests/lib/rules/no-useless-catch.js +++ b/tests/lib/rules/no-useless-catch.js @@ -103,6 +103,16 @@ ruleTester.run("no-useless-catch", rule, { } `, parserOptions: { ecmaVersion: 8 } + }, + { + code: ` + try { + throw new Error('foo'); + } catch { + throw new Error('foo'); + } + `, + parserOptions: { ecmaVersion: 2019 } } ],