Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

.eslintrc.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. module.exports = {
  2. 'extends': '../.eslintrc.js',
  3. 'parserOptions': {
  4. 'ecmaFeatures': {
  5. 'jsx': true
  6. }
  7. },
  8. 'plugins': [
  9. // ESLint's rule no-duplicate-imports does not understand Flow's import
  10. // type. Fortunately, eslint-plugin-import understands Flow's import
  11. // type.
  12. 'import',
  13. 'jsdoc',
  14. 'react',
  15. 'react-native'
  16. ],
  17. 'rules': {
  18. // Possible Errors group
  19. 'no-cond-assign': 2,
  20. 'no-console': 0,
  21. 'no-constant-condition': 2,
  22. 'no-control-regex': 2,
  23. 'no-debugger': 2,
  24. 'no-dupe-args': 2,
  25. 'no-dupe-keys': 2,
  26. 'no-duplicate-case': 2,
  27. 'no-empty': 2,
  28. 'no-empty-character-class': 2,
  29. 'no-ex-assign': 2,
  30. 'no-extra-boolean-cast': 2,
  31. 'no-extra-parens': [
  32. 'error',
  33. 'all',
  34. { 'nestedBinaryExpressions': false }
  35. ],
  36. 'no-extra-semi': 2,
  37. 'no-func-assign': 2,
  38. 'no-inner-declarations': 2,
  39. 'no-invalid-regexp': 2,
  40. 'no-irregular-whitespace': 2,
  41. 'no-negated-in-lhs': 2,
  42. 'no-obj-calls': 2,
  43. 'no-prototype-builtins': 0,
  44. 'no-regex-spaces': 2,
  45. 'no-sparse-arrays': 2,
  46. 'no-unexpected-multiline': 2,
  47. 'no-unreachable': 2,
  48. 'no-unsafe-finally': 2,
  49. 'use-isnan': 2,
  50. // Currently, we are using both valid-jsdoc and 'jsdoc' plugin. In the
  51. // future we might stick to one as soon as it has all the features.
  52. 'valid-jsdoc': [
  53. 'error',
  54. {
  55. 'matchDescription': '.+',
  56. 'prefer': {
  57. 'arg': 'param',
  58. 'argument': 'param',
  59. 'return': 'returns'
  60. },
  61. 'preferType': {
  62. 'array': 'Array',
  63. 'Boolean': 'boolean',
  64. 'function': 'Function',
  65. 'Number': 'number',
  66. 'object': 'Object',
  67. 'String': 'string'
  68. },
  69. 'requireParamDescription': true,
  70. 'requireReturn': true,
  71. 'requireReturnDescription': false,
  72. 'requireReturnType': true
  73. }
  74. ],
  75. 'valid-typeof': 2,
  76. // Best Practices group
  77. 'accessor-pairs': 0,
  78. 'array-callback-return': 2,
  79. 'block-scoped-var': 0,
  80. 'complexity': 0,
  81. 'consistent-return': 0,
  82. 'curly': 2,
  83. 'default-case': 0,
  84. 'dot-location': [ 'error', 'property' ],
  85. 'dot-notation': 2,
  86. 'eqeqeq': 2,
  87. 'guard-for-in': 2,
  88. 'no-alert': 2,
  89. 'no-caller': 2,
  90. 'no-case-declarations': 2,
  91. 'no-div-regex': 0,
  92. 'no-else-return': 2,
  93. 'no-empty-function': 2,
  94. 'no-empty-pattern': 2,
  95. 'no-eq-null': 2,
  96. 'no-eval': 2,
  97. 'no-extend-native': 2,
  98. 'no-extra-bind': 2,
  99. 'no-extra-label': 2,
  100. 'no-fallthrough': 2,
  101. 'no-floating-decimal': 2,
  102. 'no-implicit-coercion': 2,
  103. 'no-implicit-globals': 2,
  104. 'no-implied-eval': 2,
  105. 'no-invalid-this': 2,
  106. 'no-iterator': 2,
  107. 'no-labels': 2,
  108. 'no-lone-blocks': 2,
  109. 'no-loop-func': 2,
  110. 'no-magic-numbers': 0,
  111. 'no-multi-spaces': 2,
  112. 'no-multi-str': 2,
  113. 'no-native-reassign': 2,
  114. 'no-new': 2,
  115. 'no-new-func': 2,
  116. 'no-new-wrappers': 2,
  117. 'no-octal': 2,
  118. 'no-octal-escape': 2,
  119. 'no-param-reassign': 2,
  120. 'no-proto': 2,
  121. 'no-redeclare': 2,
  122. 'no-return-assign': 2,
  123. 'no-script-url': 2,
  124. 'no-self-assign': 2,
  125. 'no-self-compare': 2,
  126. 'no-sequences': 2,
  127. 'no-throw-literal': 2,
  128. 'no-unmodified-loop-condition': 2,
  129. 'no-unused-expressions': [
  130. 'error',
  131. {
  132. 'allowShortCircuit': true,
  133. 'allowTernary': true
  134. }
  135. ],
  136. 'no-unused-labels': 2,
  137. 'no-useless-call': 2,
  138. 'no-useless-concat': 2,
  139. 'no-useless-escape': 2,
  140. 'no-void': 2,
  141. 'no-warning-comments': 0,
  142. 'no-with': 2,
  143. 'radix': 2,
  144. 'vars-on-top': 2,
  145. 'wrap-iife': [ 'error', 'inside' ],
  146. 'yoda': 2,
  147. // Strict Mode group
  148. 'strict': 2,
  149. // Variables group
  150. 'init-declarations': 0,
  151. 'no-catch-shadow': 2,
  152. 'no-delete-var': 2,
  153. 'no-label-var': 2,
  154. 'no-restricted-globals': 0,
  155. 'no-shadow': 2,
  156. 'no-shadow-restricted-names': 2,
  157. 'no-undef': 2,
  158. 'no-undef-init': 2,
  159. 'no-undefined': 0,
  160. 'no-unused-vars': 2,
  161. 'no-use-before-define': [ 'error', { 'functions': false } ],
  162. // Stylistic issues group
  163. 'array-bracket-spacing': [
  164. 'error',
  165. 'always',
  166. { 'objectsInArrays': true }
  167. ],
  168. 'block-spacing': [ 'error', 'always' ],
  169. 'brace-style': 2,
  170. 'camelcase': 2,
  171. 'comma-dangle': 2,
  172. 'comma-spacing': 2,
  173. 'comma-style': 2,
  174. 'computed-property-spacing': 2,
  175. 'consistent-this': [ 'error', 'self' ],
  176. 'eol-last': 2,
  177. 'func-names': 0,
  178. 'func-style': 0,
  179. 'id-blacklist': 0,
  180. 'id-length': 0,
  181. 'id-match': 0,
  182. 'indent': [ 'error', 4, { 'SwitchCase': 0 } ],
  183. 'jsx-quotes': [ 'error', 'prefer-single' ],
  184. 'key-spacing': 2,
  185. 'keyword-spacing': 2,
  186. 'linebreak-style': [ 'error', 'unix' ],
  187. 'lines-around-comment': [
  188. 'error',
  189. {
  190. 'allowBlockStart': true,
  191. 'allowObjectStart': true,
  192. 'beforeBlockComment': true,
  193. 'beforeLineComment': true
  194. }
  195. ],
  196. 'max-depth': 2,
  197. 'max-len': [ 'error', 80 ],
  198. 'max-lines': 0,
  199. 'max-nested-callbacks': 2,
  200. 'max-params': 2,
  201. 'max-statements': 0,
  202. 'max-statements-per-line': 2,
  203. 'multiline-ternary': 0,
  204. 'new-cap': 2,
  205. 'new-parens': 2,
  206. 'newline-after-var': 2,
  207. 'newline-before-return': 2,
  208. 'newline-per-chained-call': 2,
  209. 'no-array-constructor': 2,
  210. 'no-bitwise': 2,
  211. 'no-continue': 2,
  212. 'no-inline-comments': 0,
  213. 'no-lonely-if': 2,
  214. 'no-mixed-operators': 2,
  215. 'no-mixed-spaces-and-tabs': 2,
  216. 'no-multiple-empty-lines': 2,
  217. 'no-negated-condition': 2,
  218. 'no-nested-ternary': 0,
  219. 'no-new-object': 2,
  220. 'no-plusplus': 0,
  221. 'no-restricted-syntax': 0,
  222. 'no-spaced-func': 2,
  223. 'no-tabs': 2,
  224. 'no-ternary': 0,
  225. 'no-trailing-spaces': 2,
  226. 'no-underscore-dangle': 0,
  227. 'no-unneeded-ternary': 2,
  228. 'no-whitespace-before-property': 2,
  229. 'object-curly-newline': 0,
  230. 'object-curly-spacing': [ 'error', 'always' ],
  231. 'object-property-newline': 2,
  232. 'one-var': 0,
  233. 'one-var-declaration-per-line': 0,
  234. 'operator-assignment': 0,
  235. 'operator-linebreak': [ 'error', 'before' ],
  236. 'padded-blocks': 0,
  237. 'quote-props': 0,
  238. 'quotes': [ 'error', 'single' ],
  239. 'require-jsdoc': [
  240. 'error',
  241. {
  242. 'require': {
  243. 'ClassDeclaration': true,
  244. 'FunctionDeclaration': true,
  245. 'MethodDefinition': true
  246. }
  247. }
  248. ],
  249. 'semi': [ 'error', 'always' ],
  250. 'semi-spacing': 2,
  251. 'sort-vars': 2,
  252. 'space-before-blocks': 2,
  253. 'space-before-function-paren': [ 'error', 'never' ],
  254. 'space-in-parens': [ 'error', 'never' ],
  255. 'space-infix-ops': 2,
  256. 'space-unary-ops': 2,
  257. 'spaced-comment': 2,
  258. 'unicode-bom': 0,
  259. 'wrap-regex': 0,
  260. // ES6 group rules
  261. 'arrow-body-style': [
  262. 'error',
  263. 'as-needed',
  264. { requireReturnForObjectLiteral: true }
  265. ],
  266. 'arrow-parens': [ 'error', 'as-needed' ],
  267. 'arrow-spacing': 2,
  268. 'constructor-super': 2,
  269. 'generator-star-spacing': 2,
  270. 'no-class-assign': 2,
  271. 'no-confusing-arrow': 2,
  272. 'no-const-assign': 2,
  273. 'no-dupe-class-members': 2,
  274. 'no-new-symbol': 2,
  275. 'no-restricted-imports': 0,
  276. 'no-this-before-super': 2,
  277. 'no-useless-computed-key': 2,
  278. 'no-useless-constructor': 2,
  279. 'no-useless-rename': 2,
  280. 'no-var': 2,
  281. 'object-shorthand': [
  282. 'error',
  283. 'always',
  284. { 'avoidQuotes': true }
  285. ],
  286. 'prefer-arrow-callback': [ 'error', { 'allowNamedFunctions': true } ],
  287. 'prefer-const': 2,
  288. 'prefer-reflect': 0,
  289. 'prefer-rest-params': 2,
  290. 'prefer-spread': 2,
  291. 'prefer-template': 2,
  292. 'require-yield': 2,
  293. 'rest-spread-spacing': 2,
  294. 'sort-imports': 0,
  295. 'template-curly-spacing': 2,
  296. 'yield-star-spacing': 2,
  297. 'import/no-duplicates': 2,
  298. // JsDoc plugin rules group. The following rules are in addition to
  299. // valid-jsdoc rule.
  300. 'jsdoc/check-param-names': 0,
  301. 'jsdoc/check-tag-names': 2,
  302. 'jsdoc/check-types': 0,
  303. 'jsdoc/newline-after-description': 2,
  304. // XXX Because the following plugin is not very smart about words which
  305. // legitimately begin with uppercase characters mid-sentence, set it to
  306. // warn only.
  307. 'jsdoc/require-description-complete-sentence': 1,
  308. 'jsdoc/require-hyphen-before-param-description': 2,
  309. // The following 5 rules are covered by valid-jsdoc, so disable them.
  310. 'jsdoc/require-param': 0,
  311. 'jsdoc/require-param-description': 0,
  312. 'jsdoc/require-param-type': 0,
  313. 'jsdoc/require-returns-description': 0,
  314. 'jsdoc/require-returns-type': 0,
  315. // React plugin rules group
  316. 'react/display-name': 0,
  317. 'react/forbid-prop-types': 0,
  318. 'react/no-danger': 2,
  319. 'react/no-deprecated': 2,
  320. 'react/no-did-mount-set-state': 2,
  321. 'react/no-did-update-set-state': 2,
  322. 'react/no-direct-mutation-state': 2,
  323. 'react/no-find-dom-node': 2,
  324. 'react/no-is-mounted': 2,
  325. 'react/no-multi-comp': 2,
  326. 'react/no-render-return-value': 2,
  327. 'react/no-set-state': 0,
  328. 'react/no-string-refs': 2,
  329. 'react/no-unknown-property': 2,
  330. 'react/prefer-es6-class': 2,
  331. 'react/prefer-stateless-function': 0,
  332. 'react/prop-types': 2,
  333. 'react/react-in-jsx-scope': 2,
  334. 'react/require-extension': 0,
  335. 'react/require-optimization': 0,
  336. 'react/require-render-return': 2,
  337. 'react/self-closing-comp': 2,
  338. 'react/sort-comp': 0,
  339. 'react/sort-prop-types': 2,
  340. // React plugin JSX-specific rule group
  341. 'react/jsx-boolean-value': [ 'error', 'always' ],
  342. 'react/jsx-closing-bracket-location': [
  343. 'error',
  344. 'after-props'
  345. ],
  346. 'react/jsx-curly-spacing': [
  347. 'error',
  348. 'always',
  349. {
  350. 'spacing': {
  351. 'objectLiterals': 'never'
  352. }
  353. }
  354. ],
  355. 'react/jsx-equals-spacing': [ 'error', 'always' ],
  356. 'react/jsx-filename-extension': 0,
  357. 'react/jsx-first-prop-new-line': [ 'error', 'multiline' ],
  358. 'react/jsx-handler-names': [
  359. 'error',
  360. {
  361. 'eventHandlerPrefix': '_on',
  362. 'eventHandlerPropPrefix': 'on'
  363. }
  364. ],
  365. 'react/jsx-indent': 2,
  366. 'react/jsx-indent-props': 2,
  367. 'react/jsx-key': 2,
  368. 'react/jsx-max-props-per-line': 2,
  369. 'react/jsx-no-bind': 2,
  370. 'react/jsx-no-comment-textnodes': 2,
  371. 'react/jsx-no-duplicate-props': 2,
  372. 'react/jsx-no-literals': 0,
  373. 'react/jsx-no-target-blank': 2,
  374. 'react/jsx-no-undef': 2,
  375. 'react/jsx-pascal-case': 2,
  376. 'react/jsx-sort-props': 2,
  377. 'react/jsx-space-before-closing': 2,
  378. 'react/jsx-uses-react': 2,
  379. 'react/jsx-uses-vars': 2,
  380. 'react/jsx-wrap-multilines': 2,
  381. // React-Mative plugin rules group
  382. 'react-native/no-color-literals': 2,
  383. 'react-native/no-inline-styles': 2,
  384. 'react-native/no-unused-styles': 2,
  385. 'react-native/split-platform-components': 2
  386. }
  387. };