Skip to content

Commit a8643e9

Browse files
add no-restricted-globals to eslint config (facebook#18076)
Our current lint config assumes a browser environment, which means it won't warn you if you use a variable like `name` without declaring it earlier. This imports the same list as the one used by create-react-app, and enables it against our codebase.
1 parent 4912ba3 commit a8643e9

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const {
55
esNextPaths,
66
} = require('./scripts/shared/pathsByLanguageVersion');
77

8+
const restrictedGlobals = require('confusing-browser-globals');
9+
810
const OFF = 0;
911
const ERROR = 2;
1012

@@ -45,6 +47,7 @@ module.exports = {
4547
'no-bitwise': OFF,
4648
'no-inner-declarations': [ERROR, 'functions'],
4749
'no-multi-spaces': ERROR,
50+
'no-restricted-globals': [ERROR].concat(restrictedGlobals),
4851
'no-restricted-syntax': [ERROR, 'WithStatement'],
4952
'no-shadow': ERROR,
5053
'no-unused-expressions': ERROR,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"chalk": "^3.0.0",
4141
"cli-table": "^0.3.1",
4242
"coffee-script": "^1.12.7",
43+
"confusing-browser-globals": "^1.0.9",
4344
"core-js": "^3.6.4",
4445
"coveralls": "^3.0.9",
4546
"create-react-class": "^15.6.3",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3871,6 +3871,11 @@ configstore@^4.0.0:
38713871
write-file-atomic "^2.0.0"
38723872
xdg-basedir "^3.0.0"
38733873

3874+
confusing-browser-globals@^1.0.9:
3875+
version "1.0.9"
3876+
resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz#72bc13b483c0276801681871d4898516f8f54fdd"
3877+
integrity sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==
3878+
38743879
connect-history-api-fallback@^1.6.0:
38753880
version "1.6.0"
38763881
resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc"

0 commit comments

Comments
 (0)