.eslintrc.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const normalGlobals = [];
  2. const hueGlobals = [
  3. // global_js_constants.mako
  4. 'AUTOCOMPLETE_TIMEOUT', 'CACHEABLE_TTL', 'CSRF_TOKEN', 'DOCUMENT_TYPES', 'DROPZONE_HOME_DIR',
  5. 'ENABLE_SQL_SYNTAX_CHECK', 'HAS_MULTI_CLUSTER', 'HAS_CATALOG', 'HAS_OPTIMIZER', 'HAS_WORKLOAD_ANALYTICS',
  6. 'HUE_I18n', 'HUE_VERSION', 'IS_K8S_ONLY', 'IS_NEW_INDEXER_ENABLED', 'IS_S3_ENABLED',
  7. 'isIE11', 'KO_DATERANGEPICKER_LABELS', 'LOGGED_USERGROUPS', 'LOGGED_USERNAME', 'METASTORE_PARTITION_LIMIT',
  8. 'USER_HOME_DIR', 'WorkerGlobalScope',
  9. // other misc
  10. 'ace', 'CodeMirror', 'impalaDagre', 'less', 'MediumEditor', 'moment', 'Role', 'trackOnGA', '__webpack_public_path__',
  11. // jest
  12. 'afterAll', 'afterEach', 'beforeAll', 'beforeEach', 'describe', 'expect', 'fail', 'fdescribe', 'fit', 'it', 'jest',
  13. 'spyOn', 'xdescribe', 'xit'
  14. ];
  15. const globals = normalGlobals.concat(hueGlobals).reduce((acc, key) => {
  16. acc[key] = true;
  17. return acc;
  18. }, {});
  19. module.exports = {
  20. env: {
  21. browser: true,
  22. node: true,
  23. es6: true,
  24. jasmine: true
  25. },
  26. extends: [
  27. 'plugin:prettier/recommended'
  28. ],
  29. globals: globals,
  30. parser: 'babel-eslint',
  31. parserOptions: {
  32. ecmaVersion: 2017,
  33. sourceType: 'module',
  34. ecmaFeatures: {
  35. }
  36. },
  37. plugins: [
  38. 'jest'
  39. ],
  40. rules: {
  41. 'jest/no-focused-tests': 'error',
  42. 'jest/valid-expect': 'error',
  43. 'new-cap': 0,
  44. 'no-console': 0,
  45. 'no-restricted-syntax': [
  46. 'error',
  47. {
  48. 'selector': 'CallExpression[callee.object.name="console"][callee.property.name!=/^(warn|error|info|trace)$/]',
  49. 'message': 'Unexpected property on console object was called'
  50. }
  51. ],
  52. 'no-extra-boolean-cast': 0,
  53. 'no-invalid-this': 0,
  54. 'no-lonely-if': 2,
  55. 'no-throw-literal': 0,
  56. 'no-unused-vars': [
  57. 'error',
  58. {
  59. vars: 'all',
  60. args: 'none',
  61. ignoreRestSiblings: true,
  62. varsIgnorePattern: '_[a-zA-Z0-9_]+'
  63. }
  64. ],
  65. 'no-useless-constructor': 2,
  66. 'no-var': 1,
  67. 'no-undef': 2,
  68. 'one-var': 0,
  69. 'prefer-arrow-callback': 2,
  70. 'prefer-const': ['warn', { destructuring: 'all' }],
  71. 'require-jsdoc': 0,
  72. strict: 0,
  73. 'valid-jsdoc': 0,
  74. curly: [2, 'all']
  75. },
  76. settings: {
  77. }
  78. };