You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

confusing-browser-globals

Package Overview
Dependencies
Maintainers
5
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confusing-browser-globals

A list of browser globals that are often used by mistake instead of local variables


Version published
Weekly downloads
10M
decreased by-1.43%
Maintainers
5
Install size
4.83 kB
Created
Weekly downloads
 

Package description

What is confusing-browser-globals?

The confusing-browser-globals npm package provides a list of global variables that are commonly found in browser environments. This package is useful for developers who want to avoid naming collisions or conflicts when defining new variables or functions in the global scope of a web application.

What are confusing-browser-globals's main functionalities?

Listing browser globals

This feature allows developers to access a list of common global variables in browser environments, helping to prevent naming conflicts. The code sample imports the list from the package and logs it to the console, providing a quick way to view all the globals.

import confusingGlobals from 'confusing-browser-globals';
console.log(confusingGlobals);

Other packages similar to confusing-browser-globals

Readme

Source

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:

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

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

License

MIT

Keywords

FAQs

Package last updated on 14 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc