Nighttime Pachinko Marathon
    Wondering what’s next for npm?Check out our public roadmap! »

    confusing-browser-globals
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/confusing-browser-globals package

    1.0.10 • Public • Published

    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

    Install

    npm i confusing-browser-globals

    DownloadsWeekly Downloads

    6,176,936

    Version

    1.0.10

    License

    MIT

    Unpacked Size

    3.87 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar