.eslintrc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. "className",
  188. "children",
  189. "location",
  190. "params"
  191. ]
  192. }
  193. ],
  194. "react/react-in-jsx-scope": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
  195. "react/self-closing-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
  196. "react/sort-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
  197. // Disabled because of prettier
  198. "react/jsx-wrap-multilines": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md
  199. /**
  200. * Imports (defaults from airbnb guide unless noted)
  201. * https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
  202. */
  203. // ensure imports point to files/modules that can be resolved
  204. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
  205. "import/no-unresolved": [2, { commonjs: true, caseSensitive: true }],
  206. // ensure named imports coupled with named exports
  207. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
  208. "import/named": 0,
  209. // ensure default import coupled with default export
  210. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
  211. "import/default": 0,
  212. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
  213. "import/namespace": 0,
  214. // disallow invalid exports, e.g. multiple defaults
  215. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
  216. "import/export": 2,
  217. // Redflags
  218. // do not allow a default import name to match a named export (airbnb: error)
  219. // Issue with `DefaultIssuePlugin` and `app/plugins/index`
  220. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
  221. "import/no-named-as-default": 0,
  222. // warn on accessing default export property names that are also named exports (airbnb: error)
  223. // This cannot be abled because of how `utils` is exported, as well as how it used in getsentry
  224. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
  225. "import/no-named-as-default-member": 0,
  226. // disallow use of jsdoc-marked-deprecated imports
  227. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
  228. "import/no-deprecated": 0,
  229. // Forbid mutable exports (airbnb: error)
  230. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
  231. // TODO: enable?
  232. "import/no-mutable-exports": 0,
  233. // disallow require()
  234. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
  235. "import/no-commonjs": 0,
  236. // disallow AMD require/define
  237. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
  238. "import/no-amd": 2,
  239. // No Node.js builtin modules (airbnb: off)
  240. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
  241. "import/no-nodejs-modules": 2,
  242. // Stylistic
  243. // disallow non-import statements appearing before import statements
  244. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
  245. "import/first": [2, "absolute-first"],
  246. // disallow duplicate imports
  247. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
  248. "import/no-duplicates": 2,
  249. // disallow namespace imports
  250. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
  251. "import/no-namespace": 0,
  252. // Ensure consistent use of file extension within the import path
  253. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
  254. // TODO this fucks up getsentry
  255. "import/extensions": [0, "always", {
  256. "js": "never",
  257. "jsx": "never"
  258. }],
  259. // Enforce a convention in module import order
  260. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
  261. // TODO: enable?
  262. "import/order": [0, {
  263. "groups": [["builtin", "external", "internal"], "parent", "sibling", "index"],
  264. "newlines-between": "ignore"
  265. }],
  266. // Require a newline after the last import/require in a group
  267. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
  268. "import/newline-after-import": 2,
  269. // Require modules with a single export to use a default export (airbnb: error)
  270. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
  271. "import/prefer-default-export": 0,
  272. // Restrict which files can be imported in a given folder
  273. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
  274. "import/no-restricted-paths": 0,
  275. // Forbid modules to have too many dependencies
  276. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
  277. "import/max-dependencies": [0, { max: 10 }],
  278. // Forbid import of modules using absolute paths
  279. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
  280. "import/no-absolute-path": 2,
  281. // Forbid require() calls with expressions (airbnb: error)
  282. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
  283. "import/no-dynamic-require": 0,
  284. // prevent importing the submodules of other modules
  285. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
  286. "import/no-internal-modules": [0, {
  287. "allow": []
  288. }],
  289. // Warn if a module could be mistakenly parsed as a script by a consumer
  290. // leveraging Unambiguous JavaScript Grammar
  291. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
  292. // this should not be enabled until this proposal has at least been *presented* to TC39.
  293. // At the moment, it"s not a thing.
  294. "import/unambiguous": 0,
  295. // Forbid Webpack loader syntax in imports
  296. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
  297. "import/no-webpack-loader-syntax": 2,
  298. // Prevent unassigned imports
  299. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
  300. // importing for side effects is perfectly acceptable, if you need side effects.
  301. "import/no-unassigned-import": 0,
  302. // Prevent importing the default as if it were named
  303. // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
  304. "import/no-named-default": 2,
  305. // Reports if a module"s default export is unnamed
  306. // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
  307. "import/no-anonymous-default-export": [0, {
  308. "allowArray": false,
  309. "allowArrowFunction": false,
  310. "allowAnonymousClass": false,
  311. "allowAnonymousFunction": false,
  312. "allowLiteral": false,
  313. "allowObject": false
  314. }],
  315. /**
  316. * Custom
  317. */
  318. "getsentry/jsx-needs-il8n": 0, // highlights literals in JSX components w/o translation tags
  319. }
  320. }