variables.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const confusingBrowserGlobals = require('confusing-browser-globals');
  2. module.exports = {
  3. rules: {
  4. // enforce or disallow variable initializations at definition
  5. 'init-declarations': 'off',
  6. // disallow the catch clause parameter name being the same as a variable in the outer scope
  7. 'no-catch-shadow': 'off',
  8. // disallow deletion of variables
  9. 'no-delete-var': 'error',
  10. // disallow labels that share a name with a variable
  11. // https://eslint.org/docs/rules/no-label-var
  12. 'no-label-var': 'error',
  13. // disallow specific globals
  14. 'no-restricted-globals': [
  15. 'error',
  16. {
  17. name: 'isFinite',
  18. message:
  19. 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
  20. },
  21. {
  22. name: 'isNaN',
  23. message:
  24. 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
  25. },
  26. ].concat(confusingBrowserGlobals),
  27. // disallow declaration of variables already declared in the outer scope
  28. 'no-shadow': 'error',
  29. // disallow shadowing of names such as arguments
  30. 'no-shadow-restricted-names': 'error',
  31. // disallow use of undeclared variables unless mentioned in a /*global */ block
  32. 'no-undef': 'error',
  33. // disallow use of undefined when initializing variables
  34. 'no-undef-init': 'error',
  35. // disallow use of undefined variable
  36. // https://eslint.org/docs/rules/no-undefined
  37. // TODO: enable?
  38. 'no-undefined': 'off',
  39. // disallow declaration of variables that are not used in the code
  40. 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
  41. // disallow use of variables before they are defined
  42. 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
  43. }
  44. };