.eslintrc.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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': 'error',
  59. '@typescript-eslint/explicit-module-boundary-types': 'error',
  60. 'vue/max-attributes-per-line': [
  61. 'error',
  62. {
  63. singleline: 10,
  64. multiline: {
  65. max: 1,
  66. allowFirstLine: false
  67. }
  68. }
  69. ],
  70. 'vue/html-self-closing': [
  71. 'error',
  72. {
  73. html: {
  74. void: 'any'
  75. }
  76. }
  77. ],
  78. 'vue/singleline-html-element-content-newline': 'off' // Conflicts with prettier
  79. };
  80. const jestRules = {
  81. 'jest/no-focused-tests': 'error',
  82. 'jest/valid-expect': 'error',
  83. 'new-cap': 'off',
  84. 'no-console': 'off',
  85. 'no-restricted-syntax': [
  86. 'error',
  87. {
  88. selector:
  89. 'CallExpression[callee.object.name="console"][callee.property.name!=/^(warn|error|info|trace)$/]',
  90. message: 'Unexpected property on console object was called'
  91. }
  92. ],
  93. 'no-extra-boolean-cast': 'off',
  94. 'no-invalid-this': 'off',
  95. 'no-lonely-if': 'error',
  96. 'no-throw-literal': 'off',
  97. 'no-unused-vars': [
  98. 'error',
  99. {
  100. vars: 'all',
  101. args: 'none',
  102. ignoreRestSiblings: true,
  103. varsIgnorePattern: '_[a-zA-Z0-9_]+'
  104. }
  105. ],
  106. 'no-useless-constructor': 'error',
  107. 'no-var': 'error',
  108. 'no-undef': 'error',
  109. 'one-var': 'off',
  110. 'prefer-arrow-callback': 'error',
  111. 'prefer-const': ['warn', { destructuring: 'all' }],
  112. 'require-jsdoc': 'off',
  113. strict: 'off',
  114. 'valid-jsdoc': 'off',
  115. curly: ['error', 'all']
  116. };
  117. module.exports = {
  118. env: {
  119. browser: true,
  120. node: true,
  121. es6: true,
  122. jasmine: true
  123. },
  124. overrides: [
  125. {
  126. files: ['*.vue'],
  127. extends: [
  128. 'plugin:prettier/recommended',
  129. 'plugin:vue/vue3-recommended',
  130. 'plugin:@typescript-eslint/recommended'
  131. ],
  132. parser: 'vue-eslint-parser',
  133. parserOptions: {
  134. parser: '@typescript-eslint/parser'
  135. },
  136. plugins: ['vue', '@typescript-eslint'],
  137. rules: jsTsVueRules
  138. },
  139. {
  140. files: ['*.d.ts'],
  141. extends: ['plugin:@typescript-eslint/recommended'],
  142. parser: '@typescript-eslint/parser',
  143. plugins: ['jest', '@typescript-eslint'],
  144. rules: jsTsVueRules
  145. },
  146. {
  147. files: ['*.ts', '*.tsx'],
  148. extends: ['plugin:@typescript-eslint/recommended'],
  149. parser: '@typescript-eslint/parser',
  150. plugins: ['jest', '@typescript-eslint'],
  151. rules: jsTsVueRules
  152. }
  153. ],
  154. extends: ['plugin:prettier/recommended'],
  155. globals: globals,
  156. parser: '@babel/eslint-parser',
  157. parserOptions: {
  158. parser: '@babel/eslint-parser',
  159. ecmaVersion: 2017,
  160. sourceType: 'module',
  161. ecmaFeatures: {
  162. legacyDecorators: true
  163. }
  164. },
  165. plugins: ['jest'],
  166. rules: jestRules,
  167. settings: {}
  168. };