[eslint config] [base] [patch] add error messages to no-restricted-syntax

Fixes #1353.
This commit is contained in:
Jordan Harband
2017-04-03 15:23:00 -07:00
parent aa9bbf9f49
commit 74071a809c

View File

@@ -256,10 +256,22 @@ module.exports = {
// http://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
'error',
'ForInStatement',
'ForOfStatement',
'LabeledStatement',
'WithStatement',
{
selector: 'ForInStatement',
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.',
},
{
selector: 'ForOfStatement',
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.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
// disallow space between function identifier and application