Skip to content

Commit 41f7e06

Browse files
authored
Merge pull request Expensify#145 from Expensify/Rory-AllowForOfLoops
Allow for...of loops in JS
2 parents f99b1d3 + 2157d84 commit 41f7e06

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

rules/es6.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,22 @@ module.exports = {
2626

2727
// Use of `this` outside class methods can lead to crashes on minified code
2828
'no-invalid-this': 'error',
29+
30+
// Override no-restricted-syntax to allow for...of loops
31+
'no-restricted-syntax': ['error',
32+
{
33+
selector: 'ForInStatement',
34+
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. '
35+
+ 'Use Object.{keys,values,entries}, and iterate over the resulting array.',
36+
},
37+
{
38+
selector: 'LabeledStatement',
39+
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
40+
},
41+
{
42+
selector: 'WithStatement',
43+
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize. It is also deprecated.',
44+
},
45+
],
2946
},
3047
};

0 commit comments

Comments
 (0)