.eslintrc.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. const normalGlobals = [];
  2. const hueGlobals = [
  3. // global_js_constants.mako
  4. 'AUTOCOMPLETE_TIMEOUT',
  5. 'CACHEABLE_TTL',
  6. 'CSRF_TOKEN',
  7. 'DOCUMENT_TYPES',
  8. 'DROPZONE_HOME_DIR',
  9. 'ENABLE_SQL_SYNTAX_CHECK',
  10. 'HAS_MULTI_CLUSTER',
  11. 'HAS_CATALOG',
  12. 'HAS_OPTIMIZER',
  13. 'HAS_WORKLOAD_ANALYTICS',
  14. 'HUE_I18n',
  15. 'HUE_VERSION',
  16. 'IS_K8S_ONLY',
  17. 'IS_NEW_INDEXER_ENABLED',
  18. 'IS_S3_ENABLED',
  19. 'isIE11',
  20. 'KO_DATERANGEPICKER_LABELS',
  21. 'LOGGED_USERGROUPS',
  22. 'LOGGED_USERNAME',
  23. 'METASTORE_PARTITION_LIMIT',
  24. 'USER_HOME_DIR',
  25. 'WorkerGlobalScope',
  26. // other misc
  27. 'ace',
  28. 'CodeMirror',
  29. 'impalaDagre',
  30. 'less',
  31. 'MediumEditor',
  32. 'moment',
  33. 'Role',
  34. 'trackOnGA',
  35. '__webpack_public_path__',
  36. // jest
  37. 'afterAll',
  38. 'afterEach',
  39. 'beforeAll',
  40. 'beforeEach',
  41. 'describe',
  42. 'expect',
  43. 'fail',
  44. 'fdescribe',
  45. 'fit',
  46. 'it',
  47. 'jest',
  48. 'spyOn',
  49. 'xdescribe',
  50. 'xit'
  51. ];
  52. const globals = normalGlobals.concat(hueGlobals).reduce((acc, key) => {
  53. acc[key] = true;
  54. return acc;
  55. }, {});
  56. module.exports = {
  57. env: {
  58. browser: true,
  59. node: true,
  60. es6: true,
  61. jasmine: true
  62. },
  63. overrides: [
  64. {
  65. files: ['*.vue'],
  66. extends: [
  67. 'plugin:prettier/recommended',
  68. 'plugin:vue/vue3-recommended',
  69. 'plugin:@typescript-eslint/recommended'
  70. ],
  71. parser: 'vue-eslint-parser',
  72. plugins: ['vue', '@typescript-eslint']
  73. },
  74. {
  75. files: ['*.ts'],
  76. extends: ['plugin:@typescript-eslint/recommended'],
  77. parser: '@typescript-eslint/parser',
  78. plugins: ['jest', '@typescript-eslint']
  79. }
  80. ],
  81. extends: ['plugin:prettier/recommended'],
  82. globals: globals,
  83. parser: 'babel-eslint',
  84. parserOptions: {
  85. parser: 'babel-eslint',
  86. ecmaVersion: 2017,
  87. sourceType: 'module',
  88. ecmaFeatures: {
  89. legacyDecorators: true
  90. }
  91. },
  92. plugins: ['jest'],
  93. rules: {
  94. 'jest/no-focused-tests': 'error',
  95. 'jest/valid-expect': 'error',
  96. 'new-cap': 0,
  97. 'no-console': 0,
  98. 'no-restricted-syntax': [
  99. 'error',
  100. {
  101. selector:
  102. 'CallExpression[callee.object.name="console"][callee.property.name!=/^(warn|error|info|trace)$/]',
  103. message: 'Unexpected property on console object was called'
  104. }
  105. ],
  106. 'no-extra-boolean-cast': 0,
  107. 'no-invalid-this': 0,
  108. 'no-lonely-if': 2,
  109. 'no-throw-literal': 0,
  110. 'no-unused-vars': [
  111. 'error',
  112. {
  113. vars: 'all',
  114. args: 'none',
  115. ignoreRestSiblings: true,
  116. varsIgnorePattern: '_[a-zA-Z0-9_]+'
  117. }
  118. ],
  119. 'no-useless-constructor': 2,
  120. 'no-var': 1,
  121. 'no-undef': 2,
  122. 'one-var': 0,
  123. 'prefer-arrow-callback': 2,
  124. 'prefer-const': ['warn', { destructuring: 'all' }],
  125. 'require-jsdoc': 0,
  126. strict: 0,
  127. 'valid-jsdoc': 0,
  128. curly: [2, 'all']
  129. },
  130. settings: {}
  131. };