better-regex
[a-zA-Z0-9_-]+
into \w+
, which is substantially easier to understand at a glance.catch-error-name
options
object, allowing developers to specify the expected error parameter name, plus an array of names (or patterns) to ignore. This flexibility ensures that the rule can be adapted to fit the project’s naming conventions without forcing a one-size-fits-all approach.networkError
) while still enforcing the base naming convention._
and zero references). This careful consideration prevents the rule from applying fixes that could introduce bugs or affect the functionality of the code.consistent-destructuring
consistent-function-scoping
isEven
is moved outside of filterEvenNumbers
, ensuring it is created once, rather than being recreated every time filterEvenNumbers
is called.isEven
could potentially be used by other functions besides filterEvenNumbers
.custom-error-definition
Error
subclassing.Error
constructor, allowing for more informative error messages and easier debugging. This is crucial because if the message is not passed to the base Error
constructor (as shown in the ‘bad’ example), it leads to a loss of the error message, making it harder to understand the context of the error.
Object.setPrototypeOf(this, CustomError.prototype);
, it supports a proper inheritance chain. This is particularly important in environments that may not handle subclassing of built-in objects like Error
correctly, ensuring that instanceof checks and other prototype-based behaviors work as expected.
empty-brace-spaces
error-message
message
value when creating a built-in error.escape-case
expiring-todo-comments
explicit-length-check
length
or size
property of a value.length
or size
which clarifies the intention of checking for a non-empty array or collection, rather than inadvertently relying on truthy or falsy values.
length
property might not be a simple number, for example, when it is overridden or manipulated, ensuring that the condition evaluates as expected by explicitly comparing it to a specific value.
filename-case