.eslintrc.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. module.exports = {
  2. // When adding items to this file please check for effects on sub-directories.
  3. "parser": "babel-eslint",
  4. "parserOptions": {
  5. "ecmaVersion": 2018,
  6. "ecmaFeatures": {
  7. "jsx": true
  8. },
  9. "sourceType": "module"
  10. },
  11. "env": {
  12. "node": true
  13. },
  14. "plugins": [
  15. "import", // require("eslint-plugin-import")
  16. "react", // require("eslint-plugin-react")
  17. "jsx-a11y" // require("eslint-plugin-jsx-a11y")
  18. // Temporarily disabled since they aren't vendored into in mozilla central yet
  19. // "react-hooks", // require("react-hooks")
  20. // "fetch-options", // require("eslint-plugin-fetch-options")
  21. ],
  22. "settings": {
  23. "react": {
  24. "version": "16.2.0"
  25. }
  26. },
  27. "extends": [
  28. "eslint:recommended",
  29. "plugin:jsx-a11y/recommended", // require("eslint-plugin-jsx-a11y")
  30. "plugin:mozilla/recommended", // require("eslint-plugin-mozilla")
  31. "plugin:mozilla/browser-test",
  32. "plugin:mozilla/mochitest-test",
  33. "plugin:mozilla/xpcshell-test"
  34. ],
  35. "globals": {
  36. // Remove this when m-c updates their eslint: See https://github.com/mozilla/activity-stream/pull/4219
  37. "RPMSendAsyncMessage": true,
  38. "NewTabPagePreloading": true,
  39. },
  40. "overrides": [
  41. {
  42. // These files use fluent-dom to insert content
  43. "files": [
  44. "content-src/asrouter/templates/OnboardingMessage/**",
  45. "content-src/asrouter/templates/Trailhead/**",
  46. ],
  47. "rules": {
  48. "jsx-a11y/anchor-has-content": 0,
  49. "jsx-a11y/heading-has-content": 0,
  50. }
  51. },
  52. {
  53. // Use a configuration that's more appropriate for JSMs
  54. "files": "**/*.jsm",
  55. "parserOptions": {
  56. "sourceType": "script"
  57. },
  58. "env": {
  59. "node": false
  60. },
  61. "rules": {
  62. "no-implicit-globals": 0
  63. }
  64. }
  65. ],
  66. "rules": {
  67. // "react-hooks/rules-of-hooks": 2,
  68. // "fetch-options/no-fetch-credentials": 2,
  69. "react/jsx-boolean-value": [2, "always"],
  70. "react/jsx-closing-bracket-location": [2, "after-props"],
  71. "react/jsx-curly-spacing": [2, "never"],
  72. "react/jsx-equals-spacing": [2, "never"],
  73. "react/jsx-key": 2,
  74. "react/jsx-no-bind": 2,
  75. "react/jsx-no-comment-textnodes": 2,
  76. "react/jsx-no-duplicate-props": 2,
  77. "react/jsx-no-target-blank": 2,
  78. "react/jsx-no-undef": 2,
  79. "react/jsx-pascal-case": 2,
  80. "react/jsx-tag-spacing": 2,
  81. "react/jsx-uses-react": 2,
  82. "react/jsx-uses-vars": 2,
  83. "react/jsx-wrap-multilines": 2,
  84. "react/no-access-state-in-setstate": 2,
  85. "react/no-danger": 2,
  86. "react/no-deprecated": 2,
  87. "react/no-did-mount-set-state": 2,
  88. "react/no-did-update-set-state": 2,
  89. "react/no-direct-mutation-state": 2,
  90. "react/no-is-mounted": 2,
  91. "react/no-unknown-property": 2,
  92. "react/require-render-return": 2,
  93. "react/self-closing-comp": 2,
  94. "accessor-pairs": [2, {"setWithoutGet": true, "getWithoutSet": false}],
  95. "array-bracket-newline": [2, "consistent"],
  96. "array-bracket-spacing": [2, "never"],
  97. "array-callback-return": 2,
  98. "array-element-newline": 0,
  99. "arrow-body-style": [2, "as-needed"],
  100. "arrow-parens": [2, "as-needed"],
  101. "block-scoped-var": 2,
  102. "callback-return": 0,
  103. "camelcase": 0,
  104. "capitalized-comments": 0,
  105. "class-methods-use-this": 0,
  106. "consistent-this": [2, "use-bind"],
  107. "curly": [2, "all"],
  108. "default-case": 0,
  109. "dot-location": [2, "property"],
  110. "eqeqeq": 2,
  111. "for-direction": 2,
  112. "func-name-matching": 2,
  113. "func-names": 0,
  114. "func-style": 0,
  115. "function-paren-newline": 0,
  116. "getter-return": 2,
  117. "global-require": 0,
  118. "guard-for-in": 2,
  119. "handle-callback-err": 2,
  120. "id-blacklist": 0,
  121. "id-length": 0,
  122. "id-match": 0,
  123. "implicit-arrow-linebreak": 0,
  124. // XXX Switch back to indent once mozilla-central has decided what it is using.
  125. "indent": 0,
  126. "indent-legacy": ["error", 2, {"SwitchCase": 1}],
  127. "init-declarations": 0,
  128. "jsx-quotes": [2, "prefer-double"],
  129. "line-comment-position": 0,
  130. "lines-around-comment": ["error", {
  131. "allowClassStart": true,
  132. "allowObjectStart": true,
  133. "beforeBlockComment": true
  134. }],
  135. "lines-between-class-members": 2,
  136. "max-depth": [2, 4],
  137. "max-len": 0,
  138. "max-lines": 0,
  139. "max-nested-callbacks": [2, 4],
  140. "max-params": [2, 6],
  141. "max-statements": [2, 50],
  142. "max-statements-per-line": [2, {"max": 2}],
  143. "multiline-comment-style": 0,
  144. "multiline-ternary": 0,
  145. "new-cap": [2, {"newIsCap": true, "capIsNew": false}],
  146. "new-parens": 2,
  147. "newline-after-var": 0,
  148. "newline-before-return": 0,
  149. "newline-per-chained-call": [2, {"ignoreChainWithDepth": 3}],
  150. "no-alert": 2,
  151. "no-await-in-loop": 0,
  152. "no-bitwise": 0,
  153. "no-buffer-constructor": 2,
  154. "no-catch-shadow": 2,
  155. "no-confusing-arrow": [2, {"allowParens": true}],
  156. "no-console": 1,
  157. "no-continue": 0,
  158. "no-div-regex": 2,
  159. "no-duplicate-imports": 2,
  160. "no-empty-function": 0,
  161. "no-eq-null": 2,
  162. "no-extend-native": 2,
  163. "no-extra-label": 2,
  164. "no-extra-parens": 0,
  165. "no-floating-decimal": 2,
  166. "no-implicit-coercion": [2, {"allow": ["!!"]}],
  167. "no-implicit-globals": 2,
  168. "no-inline-comments": 0,
  169. "no-invalid-this": 0,
  170. "no-label-var": 2,
  171. "no-loop-func": 2,
  172. "no-magic-numbers": 0,
  173. "no-mixed-operators": [2, {"allowSamePrecedence": true, "groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["==", "!=", "===", "!==", ">", ">=", "<", "<="], ["&&", "||"], ["in", "instanceof"]]}],
  174. "no-mixed-requires": 2,
  175. "no-multi-assign": 2,
  176. "no-multi-str": 2,
  177. "no-multiple-empty-lines": [2, {"max": 1, "maxBOF": 0, "maxEOF": 0}],
  178. "no-negated-condition": 0,
  179. "no-negated-in-lhs": 2,
  180. "no-new": 2,
  181. "no-new-func": 2,
  182. "no-new-require": 2,
  183. "no-octal-escape": 2,
  184. "no-param-reassign": 2,
  185. "no-path-concat": 2,
  186. "no-plusplus": 0,
  187. "no-process-env": 0,
  188. "no-process-exit": 2,
  189. "no-proto": 2,
  190. "no-prototype-builtins": 2,
  191. "no-restricted-globals": 0,
  192. "no-restricted-imports": 0,
  193. "no-restricted-modules": 0,
  194. "no-restricted-properties": 0,
  195. "no-restricted-syntax": 0,
  196. "no-return-assign": [2, "except-parens"],
  197. "no-script-url": 2,
  198. "no-shadow": 2,
  199. "no-spaced-func": 2,
  200. "no-sync": 0,
  201. "no-template-curly-in-string": 2,
  202. "no-ternary": 0,
  203. "no-undef-init": 2,
  204. "no-undefined": 0,
  205. "no-underscore-dangle": 0,
  206. "no-unmodified-loop-condition": 2,
  207. "no-unused-expressions": 2,
  208. "no-use-before-define": 2,
  209. "no-useless-computed-key": 2,
  210. "no-useless-constructor": 2,
  211. "no-useless-rename": 2,
  212. "no-var": 2,
  213. "no-void": 2,
  214. "no-warning-comments": 0, // TODO: Change to `1`?
  215. "nonblock-statement-body-position": 2,
  216. "object-curly-newline": [2, {"multiline": true, "consistent": true}],
  217. "object-curly-spacing": [2, "never"],
  218. "object-property-newline": [2, {"allowMultiplePropertiesPerLine": true}],
  219. "one-var": [2, "never"],
  220. "one-var-declaration-per-line": [2, "initializations"],
  221. "operator-assignment": [2, "always"],
  222. "operator-linebreak": [2, "after"],
  223. "padding-line-between-statements": 0,
  224. "prefer-arrow-callback": ["error", {"allowNamedFunctions": true}],
  225. "prefer-const": 0, // TODO: Change to `1`?
  226. "prefer-destructuring": [2, {"AssignmentExpression": {"array": true}, "VariableDeclarator": {"array": true, "object": true}}],
  227. "prefer-numeric-literals": 2,
  228. "prefer-promise-reject-errors": 2,
  229. "prefer-reflect": 0,
  230. "prefer-rest-params": 2,
  231. "prefer-spread": 2,
  232. "prefer-template": 2,
  233. "quote-props": [2, "consistent"],
  234. "radix": [2, "always"],
  235. "require-await": 2,
  236. "require-jsdoc": 0,
  237. "semi-spacing": [2, {"before": false, "after": true}],
  238. "semi-style": 2,
  239. "sort-imports": [2, {"ignoreCase": true}],
  240. "sort-keys": 0,
  241. "sort-vars": 2,
  242. "space-in-parens": [2, "never"],
  243. "strict": 0,
  244. "switch-colon-spacing": 2,
  245. "symbol-description": 2,
  246. "template-curly-spacing": [2, "never"],
  247. "template-tag-spacing": 2,
  248. "unicode-bom": [2, "never"],
  249. "valid-jsdoc": [0, {"requireReturn": false, "requireParamDescription": false, "requireReturnDescription": false}],
  250. "vars-on-top": 2,
  251. "wrap-iife": [2, "inside"],
  252. "wrap-regex": 0,
  253. "yield-star-spacing": [2, "after"],
  254. "yoda": [2, "never"]
  255. }
  256. };