Commit 06e73fa6 authored by Siddharth Doshi's avatar Siddharth Doshi Committed by Dan Abramov
Browse files

Blacklist confusing global variables (#2130)

* Blacklist confusing global variables

* Blacklist globals

* Fix kitchensink test to lint

* Edit the list

* Use no-restricted globals for this
parent dbd12f14
Showing with 68 additions and 2 deletions
+68 -2
...@@ -18,6 +18,72 @@ ...@@ -18,6 +18,72 @@
// In the future, we might create a separate list of rules for production. // In the future, we might create a separate list of rules for production.
// It would probably be more strict. // It would probably be more strict.
// The ESLint browser environment defines all browser globals as valid,
// even though most people don't know some of them exist (e.g. `name` or `status`).
// This is dangerous as it hides accidentally undefined variables.
// We blacklist the globals that we deem potentially confusing.
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
var restrictedGlobals = [
'addEventListener',
'blur',
'close',
'closed',
'confirm',
'defaultStatus',
'defaultstatus',
'event',
'external',
'find',
'focus',
'frameElement',
'frames',
'history',
'innerHeight',
'innerWidth',
'length',
'location',
'locationbar',
'menubar',
'moveBy',
'moveTo',
'name',
'onblur',
'onerror',
'onfocus',
'onload',
'onresize',
'onunload',
'open',
'opener',
'opera',
'outerHeight',
'outerWidth',
'pageXOffset',
'pageYOffset',
'parent',
'print',
'removeEventListener',
'resizeBy',
'resizeTo',
'screen',
'screenLeft',
'screenTop',
'screenX',
'screenY',
'scroll',
'scrollbars',
'scrollBy',
'scrollTo',
'scrollX',
'scrollY',
'self',
'status',
'statusbar',
'stop',
'toolbar',
'top',
];
module.exports = { module.exports = {
root: true, root: true,
...@@ -121,7 +187,7 @@ module.exports = { ...@@ -121,7 +187,7 @@ module.exports = {
'no-this-before-super': 'warn', 'no-this-before-super': 'warn',
'no-throw-literal': 'warn', 'no-throw-literal': 'warn',
'no-undef': 'error', 'no-undef': 'error',
'no-restricted-globals': ['error', 'event'], 'no-restricted-globals': ['error'].concat(restrictedGlobals),
'no-unexpected-multiline': 'warn', 'no-unexpected-multiline': 'warn',
'no-unreachable': 'warn', 'no-unreachable': 'warn',
'no-unused-expressions': [ 'no-unused-expressions': [
......
...@@ -54,7 +54,7 @@ class App extends Component { ...@@ -54,7 +54,7 @@ class App extends Component {
} }
componentDidMount() { componentDidMount() {
const feature = location.hash.slice(1); const feature = window.location.hash.slice(1);
switch (feature) { switch (feature) {
case 'array-destructuring': case 'array-destructuring':
import( import(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment