From ff4336010cba350e724f5b32c95bf805d96de682 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 13 Sep 2016 10:08:32 +1200 Subject: [PATCH] Enforce JS var declaration with value This caught us out recently where code did a strict type check for `myVar === undefined`. The var was defined as `let myVar;`, without a value - so the check returned false (it's `null`). To avoid this situation, we've decided to enforce declarations with values. Note that preference should be given to single, immutable assignments via const where possible. See http://eslint.org/docs/rules/init-declarations --- .eslintrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index b0c0c8bd..f1e3878f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,3 +1,6 @@ { - "extends": "airbnb" + "extends": "airbnb", + "rules": { + "init-declarations": 1 + } }