.eslintrc.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. plugins: ["jest"],
  9. rules: {
  10. 'no-debugger': 'error',
  11. 'no-unused-vars': [
  12. 'error',
  13. // we are only using this rule to check for unused arguments since TS
  14. // catches unused variables but not args.
  15. { varsIgnorePattern: '.*', args: 'none' }
  16. ],
  17. // most of the codebase are expected to be env agnostic
  18. 'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
  19. // since we target ES2015 for baseline support, we need to forbid object
  20. // rest spread usage in destructure as it compiles into a verbose helper.
  21. // TS now compiles assignment spread into Object.assign() calls so that
  22. // is allowed.
  23. 'no-restricted-syntax': [
  24. 'error',
  25. 'ObjectPattern > RestElement',
  26. 'AwaitExpression'
  27. ]
  28. },
  29. overrides: [
  30. // tests, no restrictions (runs in Node / jest with jsdom)
  31. {
  32. files: ['**/__tests__/**', 'test-dts/**'],
  33. rules: {
  34. 'no-restricted-globals': 'off',
  35. 'no-restricted-syntax': 'off',
  36. 'jest/no-disabled-tests': 'error',
  37. 'jest/no-focused-tests': 'error'
  38. }
  39. },
  40. // shared, may be used in any env
  41. {
  42. files: ['packages/shared/**'],
  43. rules: {
  44. 'no-restricted-globals': 'off'
  45. }
  46. },
  47. // Packages targeting DOM
  48. {
  49. files: ['packages/{vue,vue-compat,runtime-dom}/**'],
  50. rules: {
  51. 'no-restricted-globals': ['error', ...NodeGlobals]
  52. }
  53. },
  54. // Packages targeting Node
  55. {
  56. files: [
  57. 'packages/{compiler-sfc,compiler-ssr,server-renderer,reactivity-transform}/**'
  58. ],
  59. rules: {
  60. 'no-restricted-globals': ['error', ...DOMGlobals],
  61. 'no-restricted-syntax': 'off'
  62. }
  63. },
  64. // Private package, browser only + no syntax restrictions
  65. {
  66. files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
  67. rules: {
  68. 'no-restricted-globals': ['error', ...NodeGlobals],
  69. 'no-restricted-syntax': 'off'
  70. }
  71. }
  72. ]
  73. }