.eslintrc.js 3.7 KB

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