Pattern: Inconsistent function declaration style
Issue: -
Mixing function declarations and function expressions in a codebase reduces consistency and can lead to confusion about hoisting behavior. The rule can be configured to enforce either declarations or expressions as the preferred style.
Example of incorrect code:
// When configured for expressions
function foo() {
// ...
}
// When configured for declarations
const foo = function() {
// ...
};
const bar = () => {
// ...
};
Example of correct code:
// When configured for expressions
const foo = function() {
// ...
};
// When configured for declarations
function foo() {
// ...
}
// Methods are not checked
SomeObject.foo = function() {
// ...
};