Skip to content

Files

Latest commit

 

History

History
44 lines (34 loc) · 799 Bytes

func-style.md

File metadata and controls

44 lines (34 loc) · 799 Bytes

Pattern: Inconsistent function declaration style

Issue: -

Description

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.

Examples

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() {
  // ...
};