Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 849 Bytes

declaration-order.md

File metadata and controls

40 lines (28 loc) · 849 Bytes

cupcake/declaration-order

Enforces order of variable declarations

  • ⭐️ This rule is included in plugin:cupcake/recommended preset.

Enforces variable declarations to be in a specific order.

Rule Details

This rule is enforces a preferred order of variable declarations. The default is const before let, and ignoring var.

Examples of incorrect code:

let bar;
const foo = 1;

Examples of correct code:

const foo = 1;
let bar;

If a variable is used in a const declaration, then order will not be enforced.

let foo = 1;
const fooInitial = foo;

Options

The order of declarations can be specified: ["let", "const"] will enforce let before const.

Implementation