.eslintrc.js 3.0 KB

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