.eslintrc.js 3.7 KB

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