.eslintrc.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. const normalGlobals = [];
  2. const hueGlobals = [
  3. // global_js_constants.mako
  4. 'CACHEABLE_TTL',
  5. 'CSRF_TOKEN',
  6. 'DOCUMENT_TYPES',
  7. 'DROPZONE_HOME_DIR',
  8. 'ENABLE_SQL_SYNTAX_CHECK',
  9. 'HAS_MULTI_CLUSTER',
  10. 'HAS_CATALOG',
  11. 'HAS_SQL_ANALYZER',
  12. 'HAS_WORKLOAD_ANALYTICS',
  13. 'HUE_I18n',
  14. 'HUE_VERSION',
  15. 'IS_K8S_ONLY',
  16. 'IS_NEW_INDEXER_ENABLED',
  17. 'IS_S3_ENABLED',
  18. 'KO_DATERANGEPICKER_LABELS',
  19. 'LOGGED_USERGROUPS',
  20. 'LOGGED_USERNAME',
  21. 'METASTORE_PARTITION_LIMIT',
  22. 'USER_HOME_DIR',
  23. 'WorkerGlobalScope',
  24. // other misc
  25. 'ace',
  26. 'CodeMirror',
  27. 'impalaDagre',
  28. 'less',
  29. 'MediumEditor',
  30. 'moment',
  31. 'Role',
  32. '__webpack_public_path__',
  33. // jest
  34. 'afterAll',
  35. 'afterEach',
  36. 'beforeAll',
  37. 'beforeEach',
  38. 'describe',
  39. 'expect',
  40. 'fail',
  41. 'fdescribe',
  42. 'fit',
  43. 'it',
  44. 'jest',
  45. 'spyOn',
  46. 'xdescribe',
  47. 'xit'
  48. ];
  49. const globals = normalGlobals.concat(hueGlobals).reduce((acc, key) => {
  50. acc[key] = true;
  51. return acc;
  52. }, {});
  53. const jsTsVueRules = {
  54. 'no-useless-constructor': 'off',
  55. '@typescript-eslint/no-non-null-assertion': 'off',
  56. '@typescript-eslint/no-explicit-any': 'error',
  57. '@typescript-eslint/no-this-alias': 'error',
  58. '@typescript-eslint/no-unused-vars': [
  59. 'error',
  60. {
  61. varsIgnorePattern: '__webpack.*'
  62. }
  63. ],
  64. '@typescript-eslint/explicit-module-boundary-types': 'error',
  65. 'vue/max-attributes-per-line': [
  66. 'error',
  67. {
  68. singleline: 10,
  69. multiline: {
  70. max: 1
  71. }
  72. }
  73. ],
  74. 'vue/html-self-closing': [
  75. 'error',
  76. {
  77. html: {
  78. void: 'any'
  79. }
  80. }
  81. ],
  82. 'vue/multi-word-component-names': 'off',
  83. 'vue/require-toggle-inside-transition': 'off',
  84. 'vue/singleline-html-element-content-newline': 'off' // Conflicts with prettier
  85. };
  86. const jestRules = {
  87. 'jest/no-focused-tests': 'error',
  88. 'jest/valid-expect': 'error',
  89. 'new-cap': 'off',
  90. 'no-console': 'off',
  91. 'no-restricted-syntax': [
  92. 'error',
  93. {
  94. selector:
  95. 'CallExpression[callee.object.name="console"][callee.property.name!=/^(warn|error|info|trace)$/]',
  96. message: 'Unexpected property on console object was called'
  97. }
  98. ],
  99. 'no-extra-boolean-cast': 'off',
  100. 'no-invalid-this': 'off',
  101. 'no-lonely-if': 'error',
  102. 'no-throw-literal': 'off',
  103. 'no-unused-vars': [
  104. 'error',
  105. {
  106. vars: 'all',
  107. args: 'none',
  108. ignoreRestSiblings: true,
  109. varsIgnorePattern: '_[a-zA-Z0-9_]+'
  110. }
  111. ],
  112. 'no-useless-constructor': 'error',
  113. 'no-var': 'error',
  114. 'no-undef': 'error',
  115. 'one-var': 'off',
  116. 'prefer-arrow-callback': 'error',
  117. 'prefer-const': ['warn', { destructuring: 'all' }],
  118. 'require-jsdoc': 'off',
  119. strict: 'off',
  120. 'valid-jsdoc': 'off',
  121. curly: ['error', 'all']
  122. };
  123. module.exports = {
  124. env: {
  125. browser: true,
  126. node: true,
  127. es6: true,
  128. jasmine: true
  129. },
  130. overrides: [
  131. {
  132. files: ['*.vue'],
  133. extends: [
  134. 'plugin:prettier/recommended',
  135. 'plugin:vue/vue3-recommended',
  136. 'plugin:@typescript-eslint/recommended'
  137. ],
  138. parser: 'vue-eslint-parser',
  139. parserOptions: {
  140. parser: '@typescript-eslint/parser'
  141. },
  142. plugins: ['vue', '@typescript-eslint'],
  143. rules: jsTsVueRules
  144. },
  145. {
  146. files: ['*.d.ts'],
  147. extends: ['plugin:@typescript-eslint/recommended'],
  148. parser: '@typescript-eslint/parser',
  149. plugins: ['jest', '@typescript-eslint'],
  150. rules: jsTsVueRules
  151. },
  152. {
  153. files: ['*.ts', '*.tsx'],
  154. extends: ['plugin:@typescript-eslint/recommended', 'plugin:jsx-a11y/recommended'],
  155. parser: '@typescript-eslint/parser',
  156. plugins: ['jest', '@typescript-eslint', 'jsx-a11y'],
  157. rules: jsTsVueRules
  158. }
  159. ],
  160. extends: ['plugin:prettier/recommended'],
  161. globals: globals,
  162. parser: '@babel/eslint-parser',
  163. parserOptions: {
  164. parser: '@babel/eslint-parser',
  165. ecmaVersion: 2017,
  166. sourceType: 'module',
  167. ecmaFeatures: {
  168. legacyDecorators: true
  169. }
  170. },
  171. plugins: ['jest'],
  172. rules: jestRules,
  173. settings: {}
  174. };