.eslintrc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {
  2. "extends": [
  3. "standard",
  4. "standard-jsx",
  5. "standard-react",
  6. "prettier",
  7. "prettier/react",
  8. "prettier/standard",
  9. "plugin:jsx-a11y/recommended"
  10. ],
  11. "plugins": [
  12. "jsx-a11y",
  13. "mocha",
  14. "chai-expect",
  15. "chai-friendly"
  16. ],
  17. "parser": "babel-eslint",
  18. "env": {
  19. "browser": true,
  20. "mocha": true
  21. },
  22. "settings": {
  23. // Tell eslint-plugin-react to detect which version of React we are using
  24. "react": {
  25. "version": "detect"
  26. }
  27. },
  28. "rules": {
  29. // Fix conflict between prettier & standard by overriding to prefer
  30. // double quotes
  31. "jsx-quotes": ["error", "prefer-double"],
  32. // Override weird behaviour of jsx-a11y label-has-for (says labels must be
  33. // nested *and* have for/id attributes)
  34. "jsx-a11y/label-has-for": [
  35. "error",
  36. {
  37. "required": {
  38. "some": [
  39. "nesting",
  40. "id"
  41. ]
  42. }
  43. }
  44. ],
  45. // Swap the no-unused-expressions rule with a more chai-friendly one
  46. "no-unused-expressions": 0,
  47. "chai-friendly/no-unused-expressions": "error"
  48. },
  49. "overrides": [
  50. // NOTE: changing paths may require updating them in the Makefile too.
  51. {
  52. // Test specific rules
  53. "files": ["**/test/*/src/**/*.js"],
  54. "globals": {
  55. "expect": true
  56. },
  57. "rules": {
  58. // mocha-specific rules
  59. "mocha/handle-done-callback": "error",
  60. "mocha/no-exclusive-tests": "error",
  61. "mocha/no-global-tests": "error",
  62. "mocha/no-identical-title": "error",
  63. "mocha/no-nested-tests": "error",
  64. "mocha/no-pending-tests": "error",
  65. "mocha/no-skipped-tests": "error",
  66. "mocha/no-mocha-arrows": "error",
  67. // chai-specific rules
  68. "chai-expect/missing-assertion": "error",
  69. "chai-expect/terminating-properties": "error",
  70. // prefer-arrow-callback applies to all callbacks, not just ones in mocha tests.
  71. // we don't enforce this at the top-level - just in tests to manage `this` scope
  72. // based on mocha's context mechanism
  73. "mocha/prefer-arrow-callback": "error"
  74. }
  75. },
  76. {
  77. // Frontend test specific rules
  78. "files": ["**/test/karma/**/*.js"],
  79. "globals": {
  80. "expect": true,
  81. "$": true
  82. }
  83. },
  84. {
  85. // Backend specific rules
  86. "files": ["**/app/src/**/*.js"],
  87. "rules": {
  88. // don't allow console.log in backend code
  89. "no-console": "error"
  90. }
  91. },
  92. {
  93. // Frontend specific rules
  94. "files": ["**/frontend/js/**/*.js"],
  95. "globals": {
  96. "$": true,
  97. "angular": true,
  98. "ace": true,
  99. "ga": true,
  100. "Raven": true, // Backwards compat for Sentry reporting
  101. "sl_console": true,
  102. "sl_debugging": true,
  103. // Injected in layout.pug
  104. "user_id": true,
  105. "ExposedSettings": true
  106. }
  107. }
  108. ]
  109. }