.eslintrc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. {
  2. "parser": "babel-eslint",
  3. "ecmaFeatures": {
  4. "jsx": true,
  5. "modules": true
  6. },
  7. "env": {
  8. "browser": true,
  9. "es6": true,
  10. "jest": true,
  11. "jquery": true // hard-loaded into vendor.js
  12. },
  13. "globals": {
  14. "require": false,
  15. "expect": false,
  16. "sinon": false,
  17. "MockApiClient": true,
  18. "TestStubs": true,
  19. "Raven": true,
  20. "jest": true
  21. },
  22. "plugins": [
  23. "react",
  24. "import",
  25. "getsentry"
  26. ],
  27. "settings": {
  28. "import/resolver": "webpack",
  29. "import/extensions": [".js", ".jsx"]
  30. },
  31. "rules": {
  32. /**
  33. * Strict mode
  34. */
  35. "strict": [
  36. 2,
  37. "global"
  38. ], // http://eslint.org/docs/rules/strict
  39. /**
  40. * ES6
  41. */
  42. "no-var": 2, // http://eslint.org/docs/rules/no-var
  43. "prefer-const": 0, // http://eslint.org/docs/rules/prefer-const
  44. /**
  45. * Variables
  46. */
  47. "no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
  48. "no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
  49. "no-undef": 2, // http://eslint.org/docs/rules/no-undef
  50. "no-unused-vars": [
  51. 2,
  52. { // http://eslint.org/docs/rules/no-unused-vars
  53. "vars": "local",
  54. "args": "none"
  55. }
  56. ],
  57. "no-use-before-define": 2, // http://eslint.org/docs/rules/no-use-before-define
  58. /**
  59. * Possible errors
  60. */
  61. "comma-dangle": [
  62. 0,
  63. "always-multiline"
  64. ], // http://eslint.org/docs/rules/comma-dangle
  65. "no-cond-assign": [
  66. 2,
  67. "always"
  68. ], // http://eslint.org/docs/rules/no-cond-assign
  69. "no-console": 1, // http://eslint.org/docs/rules/no-console
  70. "no-debugger": 1, // http://eslint.org/docs/rules/no-debugger
  71. "no-alert": 2, // http://eslint.org/docs/rules/no-alert
  72. "no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition
  73. "no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
  74. "no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
  75. "no-empty": 2, // http://eslint.org/docs/rules/no-empty
  76. "no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
  77. "no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
  78. "no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi
  79. "no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign
  80. "no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations
  81. "no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp
  82. "no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace
  83. "no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls
  84. "no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays
  85. "no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
  86. "semi": [
  87. 2,
  88. "always"
  89. ], // http://eslint.org/docs/rules/semi.html
  90. "use-isnan": 2, // http://eslint.org/docs/rules/use-isnan
  91. "block-scoped-var": 2, // http://eslint.org/docs/rules/block-scoped-var
  92. /**
  93. * Best practices
  94. */
  95. "consistent-return": 2, // http://eslint.org/docs/rules/consistent-return
  96. "curly": 0, // http://eslint.org/docs/rules/curly [REVISIT ME]
  97. "default-case": 2, // http://eslint.org/docs/rules/default-case
  98. "dot-notation": [
  99. 2,
  100. { // http://eslint.org/docs/rules/dot-notation
  101. "allowKeywords": true
  102. }
  103. ],
  104. "eqeqeq": 0, // http://eslint.org/docs/rules/eqeqeq [REVISIT ME]
  105. "guard-for-in": 0, // http://eslint.org/docs/rules/guard-for-in [REVISIT ME]
  106. "jsx-quotes": [
  107. 2,
  108. "prefer-double"
  109. ], // http://eslint.org/docs/rules/jsx-quotes
  110. "no-caller": 2, // http://eslint.org/docs/rules/no-caller
  111. "no-else-return": 0, // http://eslint.org/docs/rules/no-else-return [REVISIT ME]
  112. "no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null
  113. "no-eval": 2, // http://eslint.org/docs/rules/no-eval
  114. "no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native
  115. "no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind
  116. "no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough
  117. "no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal
  118. "no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval
  119. "no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks
  120. "no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func
  121. "no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str
  122. "no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign
  123. "no-new": 2, // http://eslint.org/docs/rules/no-new
  124. "no-new-func": 2, // http://eslint.org/docs/rules/no-new-func
  125. "no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers
  126. "no-octal": 2, // http://eslint.org/docs/rules/no-octal
  127. "no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape
  128. "no-param-reassign": 0, // http://eslint.org/docs/rules/no-param-reassign [REVISIT ME]
  129. "no-proto": 2, // http://eslint.org/docs/rules/no-proto
  130. "no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare
  131. "no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign
  132. "no-script-url": 2, // http://eslint.org/docs/rules/no-script-url
  133. "no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare
  134. "no-sequences": 2, // http://eslint.org/docs/rules/no-sequences
  135. "no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal
  136. "no-with": 2, // http://eslint.org/docs/rules/no-with
  137. "quotes": [
  138. 2,
  139. "single",
  140. {
  141. "avoidEscape": true
  142. }
  143. ], // http://eslint.org/docs/rules/quotes.html
  144. "radix": 2, // http://eslint.org/docs/rules/radix
  145. "computed-property-spacing": [
  146. 2,
  147. "never"
  148. ], // http://eslint.org/docs/rules/space-in-brackets.html
  149. "array-bracket-spacing": [
  150. 2,
  151. "never"
  152. ], // http://eslint.org/docs/rules/space-in-brackets.html
  153. "object-curly-spacing": [
  154. 2,
  155. "never"
  156. ], // http://eslint.org/docs/rules/space-in-brackets.html
  157. "object-shorthand": [2, "properties"], // https://eslint.org/docs/rules/object-shorthand
  158. "space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops.html
  159. "vars-on-top": 0, // http://eslint.org/docs/rules/vars-on-top
  160. "wrap-iife": [
  161. 2,
  162. "any"
  163. ], // http://eslint.org/docs/rules/wrap-iife
  164. "yoda": 2, // http://eslint.org/docs/rules/yoda
  165. /**
  166. * React
  167. */
  168. "react/display-name": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
  169. "react/no-multi-comp": [
  170. 0,
  171. {
  172. "ignoreStateless": true
  173. }
  174. ], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
  175. "react/jsx-key": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
  176. "react/jsx-no-undef": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
  177. "react/jsx-no-duplicate-props": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
  178. "react/jsx-uses-react": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
  179. "react/jsx-uses-vars": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
  180. "react/no-did-mount-set-state": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
  181. "react/no-did-update-set-state": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md"
  182. "react/no-unknown-property": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
  183. "react/prop-types": [
  184. 2,
  185. {
  186. "ignore": [
  187. "style",
  188. "className",
  189. "children",
  190. "location",
  191. "params"
  192. ]
  193. }
  194. ],
  195. "react/react-in-jsx-scope": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
  196. "react/self-closing-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
  197. "react/sort-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
  198. // Disabled because of prettier
  199. "react/jsx-wrap-multilines": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md
  200. /**
  201. * Imports (defaults from airbnb guide unless noted)
  202. * https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
  203. */
  204. // ensure imports point to files/modules that can be resolved
  205. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
  206. "import/no-unresolved": [2, { commonjs: true, caseSensitive: true }],
  207. // ensure named imports coupled with named exports
  208. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
  209. "import/named": 0,
  210. // ensure default import coupled with default export
  211. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
  212. "import/default": 0,
  213. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
  214. "import/namespace": 0,
  215. // disallow invalid exports, e.g. multiple defaults
  216. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
  217. "import/export": 2,
  218. // Redflags
  219. // do not allow a default import name to match a named export (airbnb: error)
  220. // Issue with `DefaultIssuePlugin` and `app/plugins/index`
  221. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
  222. "import/no-named-as-default": 0,
  223. // warn on accessing default export property names that are also named exports (airbnb: error)
  224. // This cannot be abled because of how `utils` is exported, as well as how it used in getsentry
  225. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
  226. "import/no-named-as-default-member": 0,
  227. // disallow use of jsdoc-marked-deprecated imports
  228. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
  229. "import/no-deprecated": 0,
  230. // Forbid mutable exports (airbnb: error)
  231. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
  232. // TODO: enable?
  233. "import/no-mutable-exports": 0,
  234. // disallow require()
  235. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
  236. "import/no-commonjs": 0,
  237. // disallow AMD require/define
  238. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
  239. "import/no-amd": 2,
  240. // No Node.js builtin modules (airbnb: off)
  241. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
  242. "import/no-nodejs-modules": 2,
  243. // Stylistic
  244. // disallow non-import statements appearing before import statements
  245. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
  246. "import/first": [2, "absolute-first"],
  247. // disallow duplicate imports
  248. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
  249. "import/no-duplicates": 2,
  250. // disallow namespace imports
  251. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
  252. "import/no-namespace": 0,
  253. // Ensure consistent use of file extension within the import path
  254. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
  255. // TODO this fucks up getsentry
  256. "import/extensions": [0, "always", {
  257. "js": "never",
  258. "jsx": "never"
  259. }],
  260. // Enforce a convention in module import order
  261. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
  262. // TODO: enable?
  263. "import/order": [0, {
  264. "groups": [["builtin", "external", "internal"], "parent", "sibling", "index"],
  265. "newlines-between": "ignore"
  266. }],
  267. // Require a newline after the last import/require in a group
  268. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
  269. "import/newline-after-import": 2,
  270. // Require modules with a single export to use a default export (airbnb: error)
  271. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
  272. "import/prefer-default-export": 0,
  273. // Restrict which files can be imported in a given folder
  274. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
  275. "import/no-restricted-paths": 0,
  276. // Forbid modules to have too many dependencies
  277. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
  278. "import/max-dependencies": [0, { max: 10 }],
  279. // Forbid import of modules using absolute paths
  280. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
  281. "import/no-absolute-path": 2,
  282. // Forbid require() calls with expressions (airbnb: error)
  283. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
  284. "import/no-dynamic-require": 0,
  285. // prevent importing the submodules of other modules
  286. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
  287. "import/no-internal-modules": [0, {
  288. "allow": []
  289. }],
  290. // Warn if a module could be mistakenly parsed as a script by a consumer
  291. // leveraging Unambiguous JavaScript Grammar
  292. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
  293. // this should not be enabled until this proposal has at least been *presented* to TC39.
  294. // At the moment, it"s not a thing.
  295. "import/unambiguous": 0,
  296. // Forbid Webpack loader syntax in imports
  297. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
  298. "import/no-webpack-loader-syntax": 2,
  299. // Prevent unassigned imports
  300. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
  301. // importing for side effects is perfectly acceptable, if you need side effects.
  302. "import/no-unassigned-import": 0,
  303. // Prevent importing the default as if it were named
  304. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
  305. "import/no-named-default": 2,
  306. // Reports if a module"s default export is unnamed
  307. // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
  308. "import/no-anonymous-default-export": [0, {
  309. "allowArray": false,
  310. "allowArrowFunction": false,
  311. "allowAnonymousClass": false,
  312. "allowAnonymousFunction": false,
  313. "allowLiteral": false,
  314. "allowObject": false
  315. }],
  316. /**
  317. * Custom
  318. */
  319. "getsentry/jsx-needs-il8n": 0, // highlights literals in JSX components w/o translation tags
  320. }
  321. }