diff --git a/src/is-parenthesized.js b/src/is-parenthesized.js index 69ec3a3..8ee53c7 100644 --- a/src/is-parenthesized.js +++ b/src/is-parenthesized.js @@ -94,6 +94,8 @@ export function isParenthesized( if ( node == null || + // `Program` can't be parenthesized + node.parent == null || // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}` (node.parent.type === "CatchClause" && node.parent.param === node) ) { diff --git a/test/is-parenthesized.js b/test/is-parenthesized.js index bb48203..973d7b9 100644 --- a/test/is-parenthesized.js +++ b/test/is-parenthesized.js @@ -209,6 +209,12 @@ describe("The 'isParenthesized' function", () => { "body.0.handler.param": false, }, }, + { + code: "foo;", + expected: { + "body.0.parent": false, + }, + }, ]) { describe(`on the code \`${code}\``, () => { for (const key of Object.keys(expected)) {