Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Added allow-empty-catch option to no-empty #2886

Merged
merged 3 commits into from
Jun 8, 2017
Merged

Added allow-empty-catch option to no-empty #2886

merged 3 commits into from
Jun 8, 2017

Conversation

JoshuaKGoldberg
Copy link
Contributor

PR checklist

Overview of change:

Allows catch blocks to be empty.
Fixes #1088.

CHANGELOG.md entry:

[enhancement] Added allow-empty-catch option to no-empty

Allows catch blocks to be empty.
Fixes #1088.
Copy link
Contributor

@ajafff ajafff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with suggestions

@@ -59,6 +71,16 @@ function walk(ctx: Lint.WalkContext<void>) {
});
}

function isExcluded(node: ts.Node, options: Options): boolean {
const { parent } = node;
if (parent === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent will never be undefined here

}

return isExcludedConstructor(parent)
|| (options.allowEmptyCatch === true && parent.kind === ts.SyntaxKind.CatchClause);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simply rename isExcludedConstructor and add this condition to its return statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ehh, I actually prefer the explicitness. But sure.

const ALLOW_EMPTY_CATCH = "allow-empty-catch";

interface Options {
allowEmptyCatch?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be optional

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: no-empty should ignore empty catch blocks
3 participants