Skip to content

Commit 74071a8

Browse files
committed
[eslint config] [base] [patch] add error messages to no-restricted-syntax
Fixes airbnb#1353.
1 parent aa9bbf9 commit 74071a8

File tree

1 file changed

+16
-4
lines changed
  • packages/eslint-config-airbnb-base/rules

1 file changed

+16
-4
lines changed

packages/eslint-config-airbnb-base/rules/style.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,22 @@ module.exports = {
256256
// http://eslint.org/docs/rules/no-restricted-syntax
257257
'no-restricted-syntax': [
258258
'error',
259-
'ForInStatement',
260-
'ForOfStatement',
261-
'LabeledStatement',
262-
'WithStatement',
259+
{
260+
selector: 'ForInStatement',
261+
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
262+
},
263+
{
264+
selector: 'ForOfStatement',
265+
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
266+
},
267+
{
268+
selector: 'LabeledStatement',
269+
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
270+
},
271+
{
272+
selector: 'WithStatement',
273+
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
274+
},
263275
],
264276

265277
// disallow space between function identifier and application

0 commit comments

Comments
 (0)