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();
}
Motivation
Currently, we can require
@throwstag on functions that have athrowstatement directly in their bodies. I think it would be great to take it to the next level and require the@throwstag 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
Desired behavior