web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

  1. # confusing-browser-globals
  2. A curated list of browser globals that commonly cause confusion and are not recommended to use without an explicit `window.` qualifier.
  3. ## Motivation
  4. 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.
  5. For example:
  6. ```js
  7. handleClick() { // missing `event` argument
  8. this.setState({
  9. text: event.target.value // uses the `event` global: oops!
  10. });
  11. }
  12. ```
  13. 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.
  14. ## Installation
  15. ```sh
  16. npm install --save confusing-browser-globals
  17. ```
  18. ## Usage
  19. 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.
  20. If you maintain your own ESLint configuration, you can do this:
  21. ```js
  22. var restrictedGlobals = require('confusing-browser-globals');
  23. module.exports = {
  24. rules: {
  25. 'no-restricted-globals': ['error'].concat(restrictedGlobals),
  26. },
  27. };
  28. ```
  29. ## License
  30. MIT