.eslintrc.js 3.7 KB

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