diff --git a/src/is-parenthesized.js b/src/is-parenthesized.js index 1ec81a4..45563a4 100644 --- a/src/is-parenthesized.js +++ b/src/is-parenthesized.js @@ -92,7 +92,11 @@ export function isParenthesized( sourceCode = nodeOrSourceCode } - if (node == null) { + if ( + node == null || + // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}` + (node.parent.type === "CatchClause" && node.parent.param === node) + ) { return false } diff --git a/test/is-parenthesized.js b/test/is-parenthesized.js index f27722a..72ac66b 100644 --- a/test/is-parenthesized.js +++ b/test/is-parenthesized.js @@ -203,6 +203,12 @@ describe("The 'isParenthesized' function", () => { "body.0.object": true, }, }, + { + code: "try {} catch (a) {}", + expected: { + "body.0.handler.param": false, + }, + }, ]) { describe(`on the code \`${code}\``, () => { for (const key of Object.keys(expected)) {