/*eslint prefer-const: "error"*//*eslint-env es6*/// using const.consta=0;// it's never initialized.leta;console.log(a);// it's reassigned after initialized.leta;a=0;a=1;console.log(a);// it's initialized in a different block from the declaration.leta;if(true){a=0;}console.log(a);// it's initialized at a place that we cannot write a variable declaration.leta;if(true)a=0;console.log(a);// `i` gets a new binding each iterationfor(constiin[1,2,3]){console.log(i);}// `a` gets a new binding each iterationfor(constaof[1,2,3]){console.log(a);}// `end` is never reassigned, but we cannot separate the declarations without modifying the scope.for(leti=0,end=10;i<end;++i){console.log(a);}// suggest to use `no-var` rule.varb=3;console.log(b);

Examples of correct code for the default {"destructuring": "any"} option:

/*eslint prefer-const: "error"*//*eslint-env es6*/// using const.const{a:a0,b}=obj;consta=a0+1;// all variables are reassigned.let{a,b}=obj;a=a+1;b=b+1;

Examples of incorrect code for the {"destructuring": "all"} option:

/*eslint prefer-const: ["error", {"destructuring": "all"}]*//*eslint-env es6*/// all of `a` and `b` should be const, so those are warned.let{a,b}=obj;/*error 'a' is never reassigned, use 'const' instead.
'b' is never reassigned, use 'const' instead.*/

Examples of correct code for the {"destructuring": "all"} option:

/*eslint prefer-const: ["error", {"destructuring": "all"}]*//*eslint-env es6*/// 'b' is never reassigned, but all of `a` and `b` should not be const, so those are ignored.let{a,b}=obj;a=a+1;

ignoreReadBeforeAssign

This is an option to avoid conflicting with no-use-before-define rule (without "nofunc" option).
If true is specified, this rule will ignore variables that are read between the declaration and the first assignment.
Default is false.

Examples of correct code for the {"ignoreReadBeforeAssign": true} option: