.eslintrc.json 16 KB

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