eslint-plugin-ie11
Version:
ESLint plugin for detecting unsupported ES6 features in IE11
45 lines (33 loc) • 1.08 kB
Markdown
`let` and `const` are not behaving correctly in loop iteration scope.
This rule aims to avoid common errors when using function within loops.
Examples of **incorrect** code for this rule:
```js
const scopes = [];
for (let i = 0; i < 5; i++) {
scopes.push( function() { return i; } );
}
const zero = scopes[0]();
const one = scopes[1]();
```
Examples of **correct** code for this rule:
```js
// Since is basically a refactor of the code,
// there is no point of having a correct code.
// .. anyway :)
const wrapScope = function( value ) {
return function() { return value ; };
};
const scopes = [];
for (let i = 0; i < 5; i++) {
scopes.push( wrapScope(i) );
}
const zero = scopes[0]();
const one = scopes[1]();
```
If you are brave.
`let` in for/for-in support: http://kangax.github.io/compat-table/es6/#test-let_for/for-in_loop_iteration_scope
`const` in for/for-in support: http://kangax.github.io/compat-table/es6/#test-let_for/for-in_loop_iteration_scope