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.

66 lines
1.8 KiB

  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: 'none' }
  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. // shared, may be used in any env
  35. {
  36. files: ['packages/shared/**'],
  37. rules: {
  38. 'no-restricted-globals': 'off'
  39. }
  40. },
  41. // Packages targeting DOM
  42. {
  43. files: ['packages/{vue,runtime-dom}/**'],
  44. rules: {
  45. 'no-restricted-globals': ['error', ...NodeGlobals]
  46. }
  47. },
  48. // Packages targeting Node
  49. {
  50. files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
  51. rules: {
  52. 'no-restricted-globals': ['error', ...DOMGlobals],
  53. 'no-restricted-syntax': 'off'
  54. }
  55. },
  56. // Private package, browser only + no syntax restrictions
  57. {
  58. files: ['packages/template-explorer/**'],
  59. rules: {
  60. 'no-restricted-globals': ['error', ...NodeGlobals],
  61. 'no-restricted-syntax': 'off'
  62. }
  63. }
  64. ]
  65. }