Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require-throws recursion #1138

Open
PatrikTrefil opened this issue Aug 2, 2023 · 0 comments
Open

require-throws recursion #1138

PatrikTrefil opened this issue Aug 2, 2023 · 0 comments

Comments

@PatrikTrefil
Copy link

Motivation

Currently, we can require @throws tag on functions that have a throw statement directly in their bodies. I think it would be great to take it to the next level and require the @throws tag for all errors that may be thrown by a function. All error handling is an important part of API behavior and should therefore be well documented. This is already done by languages such as Java.

Current behavior

// No error by ESLint :(
/**
 * Description.
 */
function a() {
    b();
}
/**
 * @throws Error - Always throws an error.
 */
function b() {
    throw new Error();
}

Desired behavior

// ESLint error: throws tag required for function a
/**
 * Description.
 */
function a() {
    b();
}
/**
 * @throws Error - Always throws an error.
 */
function b() {
    throw new Error();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant