.eslintrc.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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_OPTIMIZER',
  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. }
  97. },
  98. {
  99. files: ['*.ts'],
  100. extends: ['plugin:@typescript-eslint/recommended'],
  101. parser: '@typescript-eslint/parser',
  102. plugins: ['jest', '@typescript-eslint']
  103. }
  104. ],
  105. extends: ['plugin:prettier/recommended'],
  106. globals: globals,
  107. parser: 'babel-eslint',
  108. parserOptions: {
  109. parser: 'babel-eslint',
  110. ecmaVersion: 2017,
  111. sourceType: 'module',
  112. ecmaFeatures: {
  113. legacyDecorators: true
  114. }
  115. },
  116. plugins: ['jest'],
  117. rules: {
  118. 'jest/no-focused-tests': 'error',
  119. 'jest/valid-expect': 'error',
  120. 'new-cap': 0,
  121. 'no-console': 0,
  122. 'no-restricted-syntax': [
  123. 'error',
  124. {
  125. selector:
  126. 'CallExpression[callee.object.name="console"][callee.property.name!=/^(warn|error|info|trace)$/]',
  127. message: 'Unexpected property on console object was called'
  128. }
  129. ],
  130. 'no-extra-boolean-cast': 0,
  131. 'no-invalid-this': 0,
  132. 'no-lonely-if': 2,
  133. 'no-throw-literal': 0,
  134. 'no-unused-vars': [
  135. 'error',
  136. {
  137. vars: 'all',
  138. args: 'none',
  139. ignoreRestSiblings: true,
  140. varsIgnorePattern: '_[a-zA-Z0-9_]+'
  141. }
  142. ],
  143. 'no-useless-constructor': 2,
  144. 'no-var': 1,
  145. 'no-undef': 2,
  146. 'one-var': 0,
  147. 'prefer-arrow-callback': 2,
  148. 'prefer-const': ['warn', { destructuring: 'all' }],
  149. 'require-jsdoc': 0,
  150. strict: 0,
  151. 'valid-jsdoc': 0,
  152. curly: [2, 'all']
  153. },
  154. settings: {}
  155. };