Skip to content
Branch: master
Find file History
iansu Publish
 - babel-plugin-named-asset-import@0.3.2
 - babel-preset-react-app@8.0.0
 - confusing-browser-globals@1.0.7
 - create-react-app@3.0.0
 - eslint-config-react-app@4.0.0
 - react-app-polyfill@1.0.0
 - react-dev-utils@9.0.0
 - react-error-overlay@5.1.5
 - react-scripts@3.0.0
Latest commit 265c159 Apr 22, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
LICENSE Add license file to all packages (#5192) Oct 1, 2018
README.md Improved language used in markdown code blocks. (#6419) Feb 22, 2019
index.js Add restricted globals package (#2286) Jan 15, 2018
package.json Publish Apr 22, 2019
test.js Add restricted globals package (#2286) Jan 15, 2018

README.md

confusing-browser-globals

A curated list of browser globals that commonly cause confusion and are not recommended to use without an explicit window. qualifier.

Motivation

Some global variables in browser are likely to be used by people without the intent of using them as globals, such as status, name, event, etc.

For example:

handleClick() { // missing `event` argument
  this.setState({
  	text: event.target.value // uses the `event` global: oops!
  });
}

This package exports a list of globals that are often used by mistake. You can feed this list to a static analysis tool like ESLint to prevent their usage without an explicit window. qualifier.

Installation

npm install --save confusing-browser-globals

Usage

If you use Create React App, you don't need to configure anything, as this rule is already included in the default eslint-config-react-app preset.

If you maintain your own ESLint configuration, you can do this:

var restrictedGlobals = require('confusing-browser-globals');

module.exports = {
  rules: {
    'no-restricted-globals': ['error'].concat(restrictedGlobals),
  },
};

License

MIT

You can’t perform that action at this time.