.eslintrc.js 3.7 KB

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