Enforces order of variable declarations
- ⭐️ This rule is included in
plugin:cupcake/recommended
preset.
Enforces variable declarations to be in a specific order.
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;
The order of declarations can be specified: ["let", "const"]
will enforce
let
before const
.