.eslintrc.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const DOMGlobals = ['window', 'document']
  2. const NodeGlobals = ['module', 'require']
  3. module.exports = {
  4. parser: '@typescript-eslint/parser',
  5. parserOptions: {
  6. sourceType: 'module'
  7. },
  8. rules: {
  9. 'no-unused-vars': [
  10. 'error',
  11. // we are only using this rule to check for unused arguments since TS
  12. // catches unused variables but not args.
  13. { varsIgnorePattern: '.*', args: 'after-used', argsIgnorePattern: '^_' }
  14. ],
  15. // most of the codebase are expected to be env agnostic
  16. 'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
  17. // since we target ES2015 for baseline support, we need to forbid object
  18. // rest spread usage (both assign and destructure)
  19. 'no-restricted-syntax': [
  20. 'error',
  21. 'ObjectExpression > SpreadElement',
  22. 'ObjectPattern > RestElement'
  23. ]
  24. },
  25. overrides: [
  26. // tests, no restrictions (runs in Node / jest with jsdom)
  27. {
  28. files: ['**/__tests__/**', 'test-dts/**'],
  29. rules: {
  30. 'no-restricted-globals': 'off',
  31. 'no-restricted-syntax': 'off'
  32. }
  33. },
  34. // Packages targeting DOM
  35. {
  36. files: ['packages/{vue,runtime-dom}/**'],
  37. rules: {
  38. 'no-restricted-globals': ['error', ...NodeGlobals]
  39. }
  40. },
  41. // Packages targeting Node
  42. {
  43. files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
  44. rules: {
  45. 'no-restricted-globals': ['error', ...DOMGlobals],
  46. 'no-restricted-syntax': 'off'
  47. }
  48. },
  49. // Private package, browser only + no syntax restrictions
  50. {
  51. files: ['packages/template-explorer/**'],
  52. rules: {
  53. 'no-restricted-globals': ['error', ...NodeGlobals],
  54. 'no-restricted-syntax': 'off'
  55. }
  56. }
  57. ]
  58. }