Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

há 3 anos
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. 'use strict';
  8. // Inspired by https://github.com/airbnb/javascript but less opinionated.
  9. // We use eslint-loader so even warnings are very visible.
  10. // This is why we only use "WARNING" level for potential errors,
  11. // and we don't use "ERROR" level at all.
  12. // In the future, we might create a separate list of rules for production.
  13. // It would probably be more strict.
  14. // The ESLint browser environment defines all browser globals as valid,
  15. // even though most people don't know some of them exist (e.g. `name` or `status`).
  16. // This is dangerous as it hides accidentally undefined variables.
  17. // We blacklist the globals that we deem potentially confusing.
  18. // To use them, explicitly reference them, e.g. `window.name` or `window.status`.
  19. var restrictedGlobals = require('confusing-browser-globals');
  20. module.exports = {
  21. root: true,
  22. parser: 'babel-eslint',
  23. plugins: ['import', 'flowtype', 'jsx-a11y', 'react'],
  24. env: {
  25. browser: true,
  26. commonjs: true,
  27. es6: true,
  28. jest: true,
  29. node: true,
  30. },
  31. parserOptions: {
  32. ecmaVersion: 2018,
  33. sourceType: 'module',
  34. ecmaFeatures: {
  35. jsx: true,
  36. },
  37. },
  38. settings: {
  39. react: {
  40. version: 'detect',
  41. },
  42. },
  43. rules: {
  44. // http://eslint.org/docs/rules/
  45. 'array-callback-return': 'warn',
  46. 'default-case': ['warn', { commentPattern: '^no default$' }],
  47. 'dot-location': ['warn', 'property'],
  48. eqeqeq: ['warn', 'smart'],
  49. 'new-parens': 'warn',
  50. 'no-array-constructor': 'warn',
  51. 'no-caller': 'warn',
  52. 'no-cond-assign': ['warn', 'except-parens'],
  53. 'no-const-assign': 'warn',
  54. 'no-control-regex': 'warn',
  55. 'no-delete-var': 'warn',
  56. 'no-dupe-args': 'warn',
  57. 'no-dupe-class-members': 'warn',
  58. 'no-dupe-keys': 'warn',
  59. 'no-duplicate-case': 'warn',
  60. 'no-empty-character-class': 'warn',
  61. 'no-empty-pattern': 'warn',
  62. 'no-eval': 'warn',
  63. 'no-ex-assign': 'warn',
  64. 'no-extend-native': 'warn',
  65. 'no-extra-bind': 'warn',
  66. 'no-extra-label': 'warn',
  67. 'no-fallthrough': 'warn',
  68. 'no-func-assign': 'warn',
  69. 'no-implied-eval': 'warn',
  70. 'no-invalid-regexp': 'warn',
  71. 'no-iterator': 'warn',
  72. 'no-label-var': 'warn',
  73. 'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
  74. 'no-lone-blocks': 'warn',
  75. 'no-loop-func': 'warn',
  76. 'no-mixed-operators': [
  77. 'warn',
  78. {
  79. groups: [
  80. ['&', '|', '^', '~', '<<', '>>', '>>>'],
  81. ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
  82. ['&&', '||'],
  83. ['in', 'instanceof'],
  84. ],
  85. allowSamePrecedence: false,
  86. },
  87. ],
  88. 'no-multi-str': 'warn',
  89. 'no-native-reassign': 'warn',
  90. 'no-negated-in-lhs': 'warn',
  91. 'no-new-func': 'warn',
  92. 'no-new-object': 'warn',
  93. 'no-new-symbol': 'warn',
  94. 'no-new-wrappers': 'warn',
  95. 'no-obj-calls': 'warn',
  96. 'no-octal': 'warn',
  97. 'no-octal-escape': 'warn',
  98. 'no-redeclare': 'warn',
  99. 'no-regex-spaces': 'warn',
  100. 'no-restricted-syntax': ['warn', 'WithStatement'],
  101. 'no-script-url': 'warn',
  102. 'no-self-assign': 'warn',
  103. 'no-self-compare': 'warn',
  104. 'no-sequences': 'warn',
  105. 'no-shadow-restricted-names': 'warn',
  106. 'no-sparse-arrays': 'warn',
  107. 'no-template-curly-in-string': 'warn',
  108. 'no-this-before-super': 'warn',
  109. 'no-throw-literal': 'warn',
  110. 'no-undef': 'error',
  111. 'no-restricted-globals': ['error'].concat(restrictedGlobals),
  112. 'no-unexpected-multiline': 'warn',
  113. 'no-unreachable': 'warn',
  114. 'no-unused-expressions': [
  115. 'error',
  116. {
  117. allowShortCircuit: true,
  118. allowTernary: true,
  119. allowTaggedTemplates: true,
  120. },
  121. ],
  122. 'no-unused-labels': 'warn',
  123. 'no-unused-vars': [
  124. 'warn',
  125. {
  126. args: 'none',
  127. ignoreRestSiblings: true,
  128. },
  129. ],
  130. 'no-use-before-define': [
  131. 'warn',
  132. {
  133. functions: false,
  134. classes: false,
  135. variables: false,
  136. },
  137. ],
  138. 'no-useless-computed-key': 'warn',
  139. 'no-useless-concat': 'warn',
  140. 'no-useless-constructor': 'warn',
  141. 'no-useless-escape': 'warn',
  142. 'no-useless-rename': [
  143. 'warn',
  144. {
  145. ignoreDestructuring: false,
  146. ignoreImport: false,
  147. ignoreExport: false,
  148. },
  149. ],
  150. 'no-with': 'warn',
  151. 'no-whitespace-before-property': 'warn',
  152. 'require-yield': 'warn',
  153. 'rest-spread-spacing': ['warn', 'never'],
  154. strict: ['warn', 'never'],
  155. 'unicode-bom': ['warn', 'never'],
  156. 'use-isnan': 'warn',
  157. 'valid-typeof': 'warn',
  158. 'no-restricted-properties': [
  159. 'error',
  160. {
  161. object: 'require',
  162. property: 'ensure',
  163. message:
  164. 'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
  165. },
  166. {
  167. object: 'System',
  168. property: 'import',
  169. message:
  170. 'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
  171. },
  172. ],
  173. 'getter-return': 'warn',
  174. // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
  175. 'import/first': 'error',
  176. 'import/no-amd': 'error',
  177. 'import/no-webpack-loader-syntax': 'error',
  178. // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
  179. 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
  180. 'react/jsx-no-comment-textnodes': 'warn',
  181. 'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }],
  182. 'react/jsx-no-target-blank': 'warn',
  183. 'react/jsx-no-undef': 'error',
  184. 'react/jsx-pascal-case': [
  185. 'warn',
  186. {
  187. allowAllCaps: true,
  188. ignore: [],
  189. },
  190. ],
  191. 'react/jsx-uses-react': 'warn',
  192. 'react/jsx-uses-vars': 'warn',
  193. 'react/no-danger-with-children': 'warn',
  194. // Disabled because of undesirable warnings
  195. // See https://github.com/facebook/create-react-app/issues/5204 for
  196. // blockers until its re-enabled
  197. // 'react/no-deprecated': 'warn',
  198. 'react/no-direct-mutation-state': 'warn',
  199. 'react/no-is-mounted': 'warn',
  200. 'react/no-typos': 'error',
  201. 'react/react-in-jsx-scope': 'error',
  202. 'react/require-render-return': 'error',
  203. 'react/style-prop-object': 'warn',
  204. // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
  205. 'jsx-a11y/accessible-emoji': 'warn',
  206. 'jsx-a11y/alt-text': 'warn',
  207. 'jsx-a11y/anchor-has-content': 'warn',
  208. 'jsx-a11y/anchor-is-valid': [
  209. 'warn',
  210. {
  211. aspects: ['noHref', 'invalidHref'],
  212. },
  213. ],
  214. 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
  215. 'jsx-a11y/aria-props': 'warn',
  216. 'jsx-a11y/aria-proptypes': 'warn',
  217. 'jsx-a11y/aria-role': 'warn',
  218. 'jsx-a11y/aria-unsupported-elements': 'warn',
  219. 'jsx-a11y/heading-has-content': 'warn',
  220. 'jsx-a11y/iframe-has-title': 'warn',
  221. 'jsx-a11y/img-redundant-alt': 'warn',
  222. 'jsx-a11y/no-access-key': 'warn',
  223. 'jsx-a11y/no-distracting-elements': 'warn',
  224. 'jsx-a11y/no-redundant-roles': 'warn',
  225. 'jsx-a11y/role-has-required-aria-props': 'warn',
  226. 'jsx-a11y/role-supports-aria-props': 'warn',
  227. 'jsx-a11y/scope': 'warn',
  228. // https://github.com/gajus/eslint-plugin-flowtype
  229. 'flowtype/define-flow-type': 'warn',
  230. 'flowtype/require-valid-file-annotation': 'warn',
  231. 'flowtype/use-flow-type': 'warn',
  232. },
  233. };