handle-callback-err
UnreleasedConfiguration
Requires callbacks to reference their error parameter.
Rule details
The rule checks the first parameter binding of each function, arrow function, or method. If its name matches the configured error name and it has no references, the rule reports the function.
Examples of incorrect code:
Examples of correct code:
A reference inside a nested function counts. A different variable with the same name does not. The rule checks references, so assigning to the parameter or giving it a default value also counts; it does not prove that the error is handled at runtime. Destructuring uses the first bound name, skipping empty patterns.
Options
The single option is a string. It defaults to "err"; an empty string also uses this default. Other names replace the default.
A string beginning with ^ is a JavaScript regular expression with the Unicode (u) flag. For example, "^.+Error$" matches connectionError. Strings without a leading ^ match a parameter name exactly.
Invalid patterns such as "^[" cause a configuration error before linting starts.
This rule has no automatic fix or suggestions.
Differences from upstream
Use Unicode category abbreviations such as \p{L} instead of long property names such as \p{Letter}. For example, rslint rejects "^\\p{Letter}+$" as an unsupported pattern, while upstream accepts it and reports function f(错误) {}. Changing the option to "^\\p{L}+$" makes both report it.