.eslintrc 15 KB

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