Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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