.eslintrc.json 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. {
  2. "env": {
  3. "browser": true,
  4. "node": true,
  5. "es6": true
  6. },
  7. "globals": {
  8. "React": false,
  9. "ReactDOM": false
  10. },
  11. "parser": "babel-eslint",
  12. "plugins": [
  13. "react"
  14. ],
  15. "ecmaFeatures": {
  16. "arrowFunctions": true,
  17. "binaryLiterals": true,
  18. "blockBindings": true,
  19. "classes": true,
  20. "defaultParams": true,
  21. "destructuring": true,
  22. "forOf": true,
  23. "generators": true,
  24. "modules": true,
  25. "objectLiteralComputedProperties": true,
  26. "objectLiteralDuplicateProperties": true,
  27. "objectLiteralShorthandMethods": true,
  28. "objectLiteralShorthandProperties": true,
  29. "octalLiterals": true,
  30. "regexUFlag": true,
  31. "regexYFlag": true,
  32. "spread": true,
  33. "superInFunctions": true,
  34. "templateStrings": true,
  35. "unicodeCodePointEscapes": true,
  36. "globalReturn": true,
  37. "jsx": true
  38. },
  39. "rules": {
  40. //
  41. //Possible Errors
  42. //
  43. // The following rules point out areas where you might have made mistakes.
  44. //
  45. "comma-dangle": 2,
  46. // disallow or enforce trailing commas
  47. "no-cond-assign": 2,
  48. // disallow assignment in conditional expressions
  49. "no-console": 1,
  50. // disallow use of console (off by default in the node environment)
  51. "no-constant-condition": 2,
  52. // disallow use of constant expressions in conditions
  53. "no-control-regex": 2,
  54. // disallow control characters in regular expressions
  55. "no-debugger": 2,
  56. // disallow use of debugger
  57. "no-dupe-args": 2,
  58. // disallow duplicate arguments in functions
  59. "no-dupe-keys": 2,
  60. // disallow duplicate keys when creating object literals
  61. "no-duplicate-case": 2,
  62. // disallow a duplicate case label.
  63. "no-empty": 2,
  64. // disallow empty statements
  65. "no-empty-character-class": 2,
  66. // disallow the use of empty character classes in regular expressions
  67. "no-ex-assign": 2,
  68. // disallow assigning to the exception in a catch block
  69. "no-extra-boolean-cast": 2,
  70. // disallow double-negation boolean casts in a boolean context
  71. "no-extra-parens": 1, // disallow unnecessary parentheses (off by default)
  72. "no-extra-semi": 2, // disallow unnecessary semicolons
  73. "no-func-assign": 2,
  74. // disallow overwriting functions written as function declarations
  75. "no-inner-declarations": 2,
  76. // disallow function or variable declarations in nested blocks
  77. "no-invalid-regexp": 2,
  78. // disallow invalid regular expression strings in the RegExp constructor
  79. "no-irregular-whitespace": 2,
  80. // disallow irregular whitespace outside of strings and comments
  81. "no-negated-in-lhs": 2,
  82. // disallow negation of the left operand of an in expression
  83. "no-obj-calls": 2,
  84. // disallow the use of object properties of the global object (Math and JSON) as functions
  85. "no-regex-spaces": 2,
  86. // disallow multiple spaces in a regular expression literal
  87. "quote-props": 2,
  88. // disallow reserved words being used as object literal keys (off by default)
  89. "no-sparse-arrays": 2,
  90. // disallow sparse arrays
  91. "no-unreachable": 2,
  92. // disallow unreachable statements after a return,throw, continue, or break statement
  93. "use-isnan": 2,
  94. // disallow comparisons with the value NaN
  95. "valid-jsdoc": 2,
  96. // Ensure JSDoc comments are valid (off by default)
  97. "valid-typeof": 2,
  98. // Ensure that the results of typeof are compared against a valid string
  99. //
  100. // Best Practices
  101. //
  102. // These are rules designed to prevent you from making mistakes.
  103. // They either prescribe a better way of doing something or help you avoid footguns.
  104. //
  105. "block-scoped-var": 0,
  106. // treat var statements as if they were block scoped (off by default). 0: deep destructuring is not compatible https://github.com/eslint/eslint/issues/1863
  107. "complexity": 0,
  108. // specify the maximum cyclomatic complexity allowed in a program (off by default)
  109. "consistent-return": 2,
  110. // require return statements to either always or never specify values
  111. "curly": 2,
  112. // specify curly brace conventions for all control statements
  113. "default-case": 2,
  114. // require default case in switch statements (off by default)
  115. "dot-notation": 2,
  116. // encourages use of dot notation whenever possible
  117. "eqeqeq": 2,
  118. // require the use of === and !==
  119. "guard-for-in": 2,
  120. // make sure for-in loops have an if statement (off by default)
  121. "no-alert": 2,
  122. // disallow the use of alert, confirm, and prompt
  123. "no-caller": 2,
  124. // disallow use of arguments.caller or arguments.callee
  125. "no-div-regex": 2,
  126. // disallow division operators explicitly at beginning of regular expression (off by default)
  127. "no-else-return": 2,
  128. // disallow else after a return in an if (off by default)
  129. "no-eq-null": 2,
  130. // disallow comparisons to null without a type-checking operator (off by default)
  131. "no-eval": 2,
  132. // disallow use of eval()
  133. "no-extend-native": 2,
  134. // disallow adding to native types
  135. "no-extra-bind": 2,
  136. // disallow unnecessary function binding
  137. "no-fallthrough": 2,
  138. // disallow fallthrough of case statements
  139. "no-floating-decimal": 2,
  140. // disallow the use of leading or trailing decimal points in numeric literals (off by default)
  141. "no-implied-eval": 2,
  142. // disallow use of eval()-like methods
  143. "no-iterator": 2,
  144. // disallow usage of __iterator__ property
  145. "no-labels": 2,
  146. // disallow use of labeled statements
  147. "no-lone-blocks": 2,
  148. // disallow unnecessary nested blocks
  149. "no-loop-func": 2,
  150. // disallow creation of functions within loops
  151. "no-multi-spaces": 2,
  152. // disallow use of multiple spaces
  153. "no-multi-str": 2,
  154. // disallow use of multiline strings
  155. "no-native-reassign": 2,
  156. // disallow reassignments of native objects
  157. "no-new": 2,
  158. // disallow use of new operator when not part of the assignment or comparison
  159. "no-new-func": 2,
  160. // disallow use of new operator for Function object
  161. "no-new-wrappers": 2,
  162. // disallows creating new instances of String,Number, and Boolean
  163. "no-octal": 2, // disallow use of octal literals
  164. "no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
  165. "no-param-reassign": 2,
  166. // disallow reassignment of function parameters (off by default)
  167. "no-process-env": 2,
  168. // disallow use of process.env (off by default)
  169. "no-proto": 2,
  170. // disallow usage of __proto__ property
  171. "no-redeclare": 2,
  172. // disallow declaring the same variable more then once
  173. "no-return-assign": 2,
  174. // disallow use of assignment in return statement
  175. "no-script-url": 2,
  176. // disallow use of javascript: urls.
  177. "no-self-compare": 2,
  178. // disallow comparisons where both sides are exactly the same (off by default)
  179. "no-sequences": 2,
  180. // disallow use of comma operator
  181. "no-throw-literal": 2,
  182. // restrict what can be thrown as an exception (off by default)
  183. "no-unused-expressions": 2,
  184. // disallow usage of expressions in statement position
  185. "no-void": 2,
  186. // disallow use of void operator (off by default)
  187. "no-warning-comments": [
  188. 0,
  189. {
  190. "terms": [
  191. "todo",
  192. "fixme"
  193. ],
  194. "location": "start"
  195. }
  196. ],
  197. // disallow usage of configurable warning terms in comments": 2, // e.g. TODO or FIXME (off by default)
  198. "no-with": 2,
  199. // disallow use of the with statement
  200. "radix": 2,
  201. // require use of the second argument for parseInt() (off by default)
  202. "vars-on-top": 2,
  203. // requires to declare all vars on top of their containing scope (off by default)
  204. "wrap-iife": 2,
  205. // require immediate function invocation to be wrapped in parentheses (off by default)
  206. "yoda": 2,
  207. // require or disallow Yoda conditions
  208. //
  209. // Strict Mode
  210. //
  211. // These rules relate to using strict mode.
  212. //
  213. "strict": 0,
  214. // controls location of Use Strict Directives. 0: required by `babel-eslint`
  215. //
  216. // Variables
  217. //
  218. // These rules have to do with variable declarations.
  219. //
  220. "no-catch-shadow": 2,
  221. // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
  222. "no-delete-var": 2,
  223. // disallow deletion of variables
  224. "no-label-var": 2,
  225. // disallow labels that share a name with a variable
  226. "no-shadow": 2,
  227. // disallow declaration of variables already declared in the outer scope
  228. "no-shadow-restricted-names": 2,
  229. // disallow shadowing of names such as arguments
  230. "no-undef": 2,
  231. // disallow use of undeclared variables unless mentioned in a /*global */ block
  232. "no-undef-init": 2,
  233. // disallow use of undefined when initializing variables
  234. "no-undefined": 2,
  235. // disallow use of undefined variable (off by default)
  236. "no-unused-vars": 2,
  237. // disallow declaration of variables that are not used in the code
  238. "no-use-before-define": 2,
  239. // disallow use of variables before they are defined
  240. //
  241. //Stylistic Issues
  242. //
  243. // These rules are purely matters of style and are quite subjective.
  244. //
  245. "indent": [
  246. 1,
  247. 2
  248. ],
  249. // this option sets a specific tab width for your code (off by default)
  250. "brace-style": 1,
  251. // enforce one true brace style (off by default)
  252. "camelcase": 1,
  253. // require camel case names
  254. "comma-spacing": [
  255. 1,
  256. {
  257. "before": false,
  258. "after": true
  259. }
  260. ],
  261. // enforce spacing before and after comma
  262. "comma-style": [
  263. 1,
  264. "last"
  265. ],
  266. // enforce one true comma style (off by default)
  267. "consistent-this": [
  268. 1,
  269. "_this"
  270. ],
  271. // enforces consistent naming when capturing the current execution context (off by default)
  272. "eol-last": 1,
  273. // enforce newline at the end of file, with no multiple empty lines
  274. "func-names": 0,
  275. // require function expressions to have a name (off by default)
  276. "func-style": 0,
  277. // enforces use of function declarations or expressions (off by default)
  278. "key-spacing": [
  279. 1,
  280. {
  281. "beforeColon": false,
  282. "afterColon": true
  283. }
  284. ],
  285. // enforces spacing between keys and values in object literal properties
  286. "max-nested-callbacks": [1, 3],
  287. // specify the maximum depth callbacks can be nested (off by default)
  288. "new-cap": [1, { "newIsCap": true, "capIsNew": false }
  289. ],
  290. // require a capital letter for constructors
  291. "new-parens": 1,
  292. // disallow the omission of parentheses when invoking a constructor with no arguments
  293. "newline-after-var": 0,
  294. // allow/disallow an empty newline after var statement (off by default)
  295. "no-array-constructor": 1,
  296. // disallow use of the Array constructor
  297. "no-inline-comments": 1,
  298. // disallow comments inline after code (off by default)
  299. "no-lonely-if": 1,
  300. // disallow if as the only statement in an else block (off by default)
  301. "no-mixed-spaces-and-tabs": 1,
  302. // disallow mixed spaces and tabs for indentation
  303. "no-multiple-empty-lines": [
  304. 1,
  305. {
  306. "max": 2
  307. }
  308. ],
  309. // disallow multiple empty lines (off by default)
  310. "no-nested-ternary": 1,
  311. // disallow nested ternary expressions (off by default)
  312. "no-new-object": 1,
  313. // disallow use of the Object constructor
  314. "no-spaced-func": 1,
  315. // disallow space between function identifier and application
  316. "no-ternary": 0,
  317. // disallow the use of ternary operators (off by default)
  318. "no-trailing-spaces": 1,
  319. // disallow trailing whitespace at the end of lines
  320. "no-underscore-dangle": 1,
  321. // disallow dangling underscores in identifiers
  322. "no-extra-parens": 0, // disallow wrapping of non-IIFE statements in parens
  323. "one-var": [
  324. 1,
  325. "never"
  326. ],
  327. // allow just one var statement per function (off by default)
  328. "operator-assignment": [
  329. 1,
  330. "never"
  331. ],
  332. // require assignment operator shorthand where possible or prohibit it entirely (off by default)
  333. "padded-blocks": [
  334. 1,
  335. "never"
  336. ],
  337. // enforce padding within blocks (off by default)
  338. "quote-props": [
  339. 1,
  340. "as-needed"
  341. ],
  342. // require quotes around object literal property names (off by default)
  343. "quotes": [
  344. 1,
  345. "single"
  346. ],
  347. // specify whether double or single quotes should be used
  348. "semi": [
  349. 1,
  350. "always"
  351. ],
  352. // require or disallow use of semicolons instead of ASI
  353. "semi-spacing": [
  354. 1,
  355. {
  356. "before": false,
  357. "after": true
  358. }
  359. ],
  360. // enforce spacing before and after semicolons
  361. "sort-vars": 0,
  362. // sort variables within the same declaration block (off by default)
  363. "keyword-spacing": ["error", { "before": true, "after": true }], // require a space after certain keywords (off by default)
  364. "space-before-blocks": [
  365. 1,
  366. "always"
  367. ],
  368. // require or disallow space before blocks (off by default)
  369. "space-before-function-paren": [
  370. 1,
  371. {
  372. "anonymous": "always",
  373. "named": "never"
  374. }
  375. ],
  376. // require or disallow space before function opening parenthesis (off by default)
  377. "object-curly-spacing": 1,
  378. "array-bracket-spacing": 1,
  379. "computed-property-spacing": 1,
  380. // require or disallow spaces inside brackets (off by default)
  381. "space-in-parens": [
  382. 1,
  383. "never"
  384. ],
  385. // require or disallow spaces inside parentheses (off by default)
  386. "space-infix-ops": ["error", {"int32Hint": false}],
  387. // require spaces around operators
  388. "space-unary-ops": [
  389. 1,
  390. {
  391. "words": true,
  392. "nonwords": false
  393. }
  394. ],
  395. // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
  396. "spaced-comment": [1, "always"],
  397. // require or disallow a space immediately following the // in a line comment (off by default)
  398. "wrap-regex": 0,
  399. // require regex literals to be wrapped in parentheses (off by default)
  400. //
  401. // ECMAScript 6
  402. //
  403. // These rules are only relevant to ES6 environments and are off by default.
  404. //
  405. "no-var": 2,
  406. // require let or const instead of var (off by default)
  407. "generator-star-spacing": [
  408. 2,
  409. "before"
  410. ],
  411. // enforce the spacing around the * in generator functions (off by default)
  412. //
  413. // Legacy
  414. //
  415. // The following rules are included for compatibility with JSHint and JSLint.
  416. // While the names of the rules may not match up with the JSHint/JSLint counterpart,
  417. // the functionality is the same.
  418. //
  419. "max-depth": [
  420. 2,
  421. 3
  422. ],
  423. // specify the maximum depth that blocks can be nested (off by default)
  424. "max-len": [
  425. 2,
  426. 100,
  427. 2
  428. ],
  429. // specify the maximum length of a line in your program (off by default)
  430. "max-params": [
  431. 2,
  432. 5
  433. ],
  434. // limits the number of parameters that can be used in the function declaration. (off by default)
  435. "max-statements": 0,
  436. // specify the maximum number of statement allowed in a function (off by default)
  437. "no-bitwise": 0,
  438. // disallow use of bitwise operators (off by default)
  439. "no-plusplus": 2,
  440. // disallow use of unary operators, ++ and -- (off by default)
  441. //
  442. // eslint-plugin-react
  443. //
  444. // React specific linting rules for ESLint
  445. //
  446. "react/display-name": 0,
  447. // Prevent missing displayName in a React component definition
  448. //"react/jsx-quotes": [ 2, "double", "avoid-escape"],
  449. // Enforce quote style for JSX attributes
  450. "react/jsx-no-undef": 2,
  451. // Disallow undeclared variables in JSX
  452. "react/jsx-sort-props": 0,
  453. // Enforce props alphabetical sorting
  454. "react/jsx-uses-react": 2,
  455. // Prevent React to be incorrectly marked as unused
  456. "react/jsx-uses-vars": 2,
  457. // Prevent variables used in JSX to be incorrectly marked as unused
  458. "react/no-did-mount-set-state": 2,
  459. // Prevent usage of setState in componentDidMount
  460. "react/no-did-update-set-state": 2,
  461. // Prevent usage of setState in componentDidUpdate
  462. "react/no-multi-comp": 0,
  463. // Prevent multiple component definition per file
  464. "react/no-unknown-property": 2,
  465. // Prevent usage of unknown DOM property
  466. "react/prop-types": 2,
  467. // Prevent missing props validation in a React component definition
  468. "react/react-in-jsx-scope": 2,
  469. // Prevent missing React when using JSX
  470. "react/self-closing-comp": 2,
  471. // Prevent extra closing tags for components without children
  472. "react/jsx-wrap-multilines": 2 // Prevent missing parentheses around multilines JSX
  473. }
  474. }