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.

89 lines
2.5 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. 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. 'no-restricted-syntax': [
  20. 'error',
  21. // since we target ES2015 for baseline support, we need to forbid object
  22. // rest spread usage in destructure as it compiles into a verbose helper.
  23. 'ObjectPattern > RestElement',
  24. // tsc compiles assignment spread into Object.assign() calls, but esbuild
  25. // still generates verbose helpers, so spread assignment is also prohiboted
  26. 'ObjectExpression > SpreadElement',
  27. 'AwaitExpression'
  28. ]
  29. },
  30. overrides: [
  31. // tests, no restrictions (runs in Node / jest with jsdom)
  32. {
  33. files: ['**/__tests__/**', 'packages/dts-test/**'],
  34. rules: {
  35. 'no-restricted-globals': 'off',
  36. 'no-restricted-syntax': 'off',
  37. 'jest/no-disabled-tests': 'error',
  38. 'jest/no-focused-tests': 'error'
  39. }
  40. },
  41. // shared, may be used in any env
  42. {
  43. files: ['packages/shared/**'],
  44. rules: {
  45. 'no-restricted-globals': 'off'
  46. }
  47. },
  48. // Packages targeting DOM
  49. {
  50. files: ['packages/{vue,vue-compat,runtime-dom}/**'],
  51. rules: {
  52. 'no-restricted-globals': ['error', ...NodeGlobals]
  53. }
  54. },
  55. // Packages targeting Node
  56. {
  57. files: [
  58. 'packages/{compiler-sfc,compiler-ssr,server-renderer,reactivity-transform}/**'
  59. ],
  60. rules: {
  61. 'no-restricted-globals': ['error', ...DOMGlobals],
  62. 'no-restricted-syntax': 'off'
  63. }
  64. },
  65. // Private package, browser only + no syntax restrictions
  66. {
  67. files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
  68. rules: {
  69. 'no-restricted-globals': ['error', ...NodeGlobals],
  70. 'no-restricted-syntax': 'off'
  71. }
  72. },
  73. // Node scripts
  74. {
  75. files: [
  76. 'scripts/**',
  77. '*.{js,ts}',
  78. 'packages/**/index.js',
  79. 'packages/size-check/**'
  80. ],
  81. rules: {
  82. 'no-restricted-globals': 'off',
  83. 'no-restricted-syntax': 'off'
  84. }
  85. }
  86. ]
  87. }