.eslintrc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. // Rules reference: http://eslint.org/docs/rules/
  2. {
  3. "extends": [],
  4. "env": {
  5. "browser": true,
  6. "node" : true,
  7. "es6": true,
  8. "mocha": true
  9. },
  10. "globals": {
  11. "expect": true,
  12. "sinon": true,
  13. "module":true,
  14. "Snap":true,
  15. "_":true,
  16. "$":true,
  17. "require":true
  18. },
  19. "parserOptions": {
  20. "ecmaVersion": 2017,
  21. "sourceType": "module",
  22. // ES6 Language Features
  23. "ecmaFeatures": {
  24. "arrowFunctions": true,
  25. "blockBindings": true,
  26. "classes": true,
  27. "defaultParams": true,
  28. "destructuring": true,
  29. "forOf": true,
  30. "generators": true,
  31. "modules": true,
  32. "objectLiteralComputedProperties": true,
  33. "objectLiteralDuplicateProperties": false,
  34. "objectLiteralShorthandMethods": true,
  35. "objectLiteralShorthandProperties": true,
  36. "restParams": true,
  37. "spread": true,
  38. "superInFunctions": false,
  39. "templateStrings": true,
  40. }
  41. },
  42. "rules": {
  43. //=========================================================================
  44. //==================== Possible Errors ====================================
  45. //=========================================================================
  46. // disallow trailing commas in object literals
  47. "comma-dangle": [2, "always-multiline"], //TODO: need discussion
  48. // disallow assignment in conditional expressions
  49. "no-cond-assign": [2, "always"],
  50. // disallow use of console
  51. "no-console": 1,
  52. // disallow use of constant expressions in conditions
  53. "no-constant-condition": [2, { "checkLoops": false }],
  54. // disallow control characters in regular expressions
  55. "no-control-regex": 2,
  56. // disallow use of debugger
  57. "no-debugger": 2,
  58. // disallow duplicate arguments in functions
  59. "no-dupe-args": 2,
  60. // disallow duplicate keys when creating object literals
  61. "no-dupe-keys": 2,
  62. // disallow a duplicate case label.
  63. "no-duplicate-case": 2,
  64. // disallow the use of empty character classes in regular expressions
  65. "no-empty-character-class": 2,
  66. // disallow empty statements
  67. "no-empty": 2,
  68. // disallow assigning to the exception in a catch block
  69. "no-ex-assign": 2,
  70. // disallow double-negation boolean casts in a boolean context
  71. "no-extra-boolean-cast": 2,
  72. // disallow unnecessary parentheses
  73. "no-extra-parens": [2, "functions"],
  74. // disallow unnecessary semicolons
  75. "no-extra-semi": 2,
  76. // disallow overwriting functions written as function declarations
  77. "no-func-assign": 2,
  78. // disallow function or variable declarations in nested blocks
  79. "no-inner-declarations": 2,
  80. // disallow invalid regular expression strings in the RegExp constructor
  81. "no-invalid-regexp": 2,
  82. // disallow irregular whitespace outside of strings and comments
  83. "no-irregular-whitespace": 2,
  84. // disallow negation of the left operand of an in expression
  85. "no-negated-in-lhs": 2,
  86. // disallow the use of object properties of the global object (Math and JSON) as functions
  87. "no-obj-calls": 2,
  88. // disallow multiple spaces in a regular expression literal
  89. "no-regex-spaces": 2,
  90. // disallow sparse arrays
  91. "no-sparse-arrays": 2,
  92. // Avoid code that looks like two expressions but is actually one
  93. "no-unexpected-multiline": 2,
  94. // disallow unreachable statements after a return, throw, continue, or break statement
  95. "no-unreachable": 2,
  96. // disallow comparisons with the value NaN
  97. "use-isnan": 2,
  98. // ensure JSDoc comments are valid
  99. "valid-jsdoc": [2, {
  100. "requireReturn": false,
  101. "requireReturnDescription": false
  102. }],
  103. // ensure that the results of typeof are compared against a valid string
  104. "valid-typeof": 2,
  105. //=========================================================================
  106. //==================== Best Practices =====================================
  107. //=========================================================================
  108. // Enforces getter/setter pairs in objects
  109. "accessor-pairs": 2,
  110. // treat var statements as if they were block scoped
  111. "block-scoped-var": 2,
  112. // specify the maximum cyclomatic complexity allowed in a program
  113. "complexity": [0, 11],
  114. // require return statements to either always or never specify values
  115. "consistent-return": 2,
  116. // specify curly brace conventions for all control statements
  117. "curly": [2, "multi-line"],
  118. // require default case in switch statements
  119. "default-case": 2,
  120. // encourages use of dot notation whenever possible
  121. "dot-notation": [2, { "allowKeywords": true}],
  122. // enforces consistent newlines before or after dots
  123. "dot-location": [2, "property"],
  124. // require the use of === and !==
  125. "eqeqeq": 2,
  126. // make sure for-in loops have an if statement
  127. "guard-for-in": 2,
  128. // disallow the use of alert, confirm, and prompt
  129. "no-alert": 2,
  130. // disallow use of arguments.caller or arguments.callee
  131. "no-caller": 2,
  132. // disallow lexical declarations in case clauses
  133. "no-case-declarations": 2,
  134. // disallow division operators explicitly at beginning of regular expression
  135. "no-div-regex": 2,
  136. // disallow else after a return in an if
  137. "no-else-return": 2,
  138. // disallow use of empty destructuring patterns
  139. "no-empty-pattern": 2,
  140. // disallow comparisons to null without a type-checking operator
  141. "no-eq-null": 2,
  142. // disallow use of eval()
  143. "no-eval": 2,
  144. // disallow adding to native types
  145. "no-extend-native": 2,
  146. // disallow unnecessary function binding
  147. "no-extra-bind": 2,
  148. // disallow fallthrough of case statements
  149. "no-fallthrough": 2,
  150. // disallow the use of leading or trailing decimal points in numeric literals
  151. "no-floating-decimal": 2,
  152. // disallow the type conversions with shorter notations
  153. "no-implicit-coercion": 2,
  154. // disallow use of eval()-like methods
  155. "no-implied-eval": 2,
  156. // disallow this keywords outside of classes or class-like objects
  157. "no-invalid-this":0,
  158. // disallow usage of __iterator__ property
  159. "no-iterator": 2,
  160. // disallow use of labeled statements
  161. "no-labels": 2,
  162. // disallow unnecessary nested blocks
  163. "no-lone-blocks": 2,
  164. // disallow creation of functions within loops
  165. "no-loop-func": 2,
  166. // disallow the use of magic numbers
  167. "no-magic-numbers": 0, //TODO: need discussion
  168. // disallow use of multiple spaces
  169. "no-multi-spaces": 2,
  170. // disallow use of multiline strings
  171. "no-multi-str": 2,
  172. // disallow reassignments of native objects
  173. "no-native-reassign": 2,
  174. // disallow use of new operator for Function object
  175. "no-new-func": 2,
  176. // disallows creating new instances of String,Number, and Boolean
  177. "no-new-wrappers": 2,
  178. // disallow use of new operator when not part of the assignment or comparison
  179. "no-new": 2,
  180. // disallow use of octal escape sequences in string literals, such as
  181. // var foo = "Copyright \251";
  182. "no-octal-escape": 2,
  183. // disallow use of (old style) octal literals
  184. "no-octal": 2,
  185. // disallow reassignment of function parameters
  186. "no-param-reassign": 2,
  187. // disallow use of process.env
  188. "no-process-env": 2,
  189. // disallow usage of __proto__ property
  190. "no-proto": 2,
  191. // disallow declaring the same variable more then once
  192. "no-redeclare": 2,
  193. // disallow use of assignment in return statement
  194. "no-return-assign": 2,
  195. // disallow use of `javascript:` urls.
  196. "no-script-url": 2,
  197. // disallow comparisons where both sides are exactly the same
  198. "no-self-compare": 2,
  199. // disallow use of comma operator
  200. "no-sequences": 2,
  201. // restrict what can be thrown as an exception
  202. "no-throw-literal": 0,
  203. // disallow usage of expressions in statement position
  204. "no-unused-expressions": 2,
  205. // disallow unnecessary .call() and .apply()
  206. "no-useless-call": 2,
  207. // disallow unnecessary concatenation of literals or template literals
  208. "no-useless-concat": 2,
  209. // disallow use of void operator
  210. "no-void": 2,
  211. // disallow usage of configurable warning terms in comments: e.g. todo
  212. "no-warning-comments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
  213. // disallow use of the with statement
  214. "no-with": 2,
  215. // require use of the second argument for parseInt()
  216. "radix": 2,
  217. // requires to declare all vars on top of their containing scope
  218. "vars-on-top": 0,
  219. // require immediate function invocation to be wrapped in parentheses
  220. "wrap-iife": [2, "any"],
  221. // require or disallow Yoda conditions
  222. "yoda": 2,
  223. // //=========================================================================
  224. // //==================== Strict Mode ========================================
  225. // //=========================================================================
  226. // require that all functions are run in strict mode
  227. // "strict": [2, "global"],
  228. //
  229. //=========================================================================
  230. //==================== Variables ==========================================
  231. //=========================================================================
  232. // enforce or disallow variable initializations at definition
  233. "init-declarations": 0,
  234. // disallow the catch clause parameter name being the same as a variable in the outer scope
  235. "no-catch-shadow": 0,
  236. // disallow deletion of variables
  237. "no-delete-var": 2,
  238. // disallow labels that share a name with a variable
  239. "no-label-var": 2,
  240. // disallow shadowing of names such as arguments
  241. "no-shadow-restricted-names": 2,
  242. // disallow declaration of variables already declared in the outer scope
  243. "no-shadow": 2,
  244. // disallow use of undefined when initializing variables
  245. "no-undef-init": 0,
  246. // disallow use of undeclared variables unless mentioned in a /*global */ block
  247. "no-undef": 2,
  248. // disallow use of undefined variable
  249. "no-undefined": 0,
  250. // disallow declaration of variables that are not used in the code
  251. "no-unused-vars": [1, {"vars": "local", "args": "after-used"}],
  252. // disallow use of variables before they are defined
  253. "no-use-before-define": 2,
  254. //=========================================================================
  255. //==================== Node.js ============================================
  256. //=========================================================================
  257. // enforce return after a callback
  258. "callback-return": 0,
  259. // disallow require() outside of the top-level module scope
  260. "global-require": 2,
  261. // enforces error handling in callbacks (node environment)
  262. "handle-callback-err": 2,
  263. // disallow mixing regular variable and require declarations
  264. "no-mixed-requires": 2,
  265. // disallow use of new operator with the require function
  266. "no-new-require": 2,
  267. // disallow string concatenation with __dirname and __filename
  268. "no-path-concat": 1,
  269. // disallow process.exit()
  270. "no-process-exit": 2,
  271. // restrict usage of specified node modules
  272. "no-restricted-modules": 0,
  273. // disallow use of synchronous methods (off by default)
  274. "no-sync": 0,
  275. //=========================================================================
  276. //==================== Stylistic Issues ===================================
  277. //=========================================================================
  278. // enforce spacing inside array brackets
  279. "array-bracket-spacing": 0,
  280. // disallow or enforce spaces inside of single line blocks
  281. "block-spacing": 1,
  282. // enforce one true brace style
  283. "brace-style": [1, "1tbs", {"allowSingleLine": true }],
  284. // require camel case names
  285. "camelcase": [1, {"properties": "always"}],
  286. // enforce spacing before and after comma
  287. "comma-spacing": [1, {"before": false, "after": true}],
  288. // enforce one true comma style
  289. "comma-style": [1, "last"],
  290. // require or disallow padding inside computed properties
  291. "computed-property-spacing": 0,
  292. // enforces consistent naming when capturing the current execution context
  293. "consistent-this": 0,
  294. // enforce newline at the end of file, with no multiple empty lines
  295. "eol-last": 1,
  296. // require function expressions to have a name
  297. "func-names": 0,
  298. // enforces use of function declarations or expressions
  299. "func-style": 0,
  300. // this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
  301. "id-length": 0,
  302. // require identifiers to match the provided regular expression
  303. "id-match": 0,
  304. // this option sets a specific tab width for your code
  305. "indent": [1, 4, {"SwitchCase": 1}],
  306. // specify whether double or single quotes should be used in JSX attributes
  307. "jsx-quotes": [1, "prefer-double"],
  308. // enforces spacing between keys and values in object literal properties
  309. "key-spacing": [1, {"beforeColon": false, "afterColon": true}],
  310. // disallow mixed "LF" and "CRLF" as linebreaks
  311. "linebreak-style": 0,
  312. // enforces empty lines around comments
  313. "lines-around-comment": 0,
  314. // specify the maximum depth that blocks can be nested
  315. "max-depth": [0, 4],
  316. // specify the maximum length of a line in your program
  317. "max-len": [0, 80, 4],
  318. // specify the maximum depth callbacks can be nested
  319. "max-nested-callbacks": 0,
  320. // limits the number of parameters that can be used in the function declaration.
  321. "max-params": [0, 3],
  322. // specify the maximum number of statement allowed in a function
  323. "max-statements": [0, 10],
  324. // require a capital letter for constructors
  325. "new-cap": [1, {"newIsCap": true}],
  326. // disallow the omission of parentheses when invoking a constructor with no arguments
  327. "new-parens": 0,
  328. // allow/disallow an empty newline after var statement
  329. "newline-after-var": 0,
  330. // disallow use of the Array constructor
  331. "no-array-constructor": 0,
  332. // disallow use of bitwise operators
  333. "no-bitwise": 0,
  334. // disallow use of the continue statement
  335. "no-continue": 0,
  336. // disallow comments inline after code
  337. "no-inline-comments": 0,
  338. // disallow if as the only statement in an else block
  339. "no-lonely-if": 0,
  340. // disallow mixed spaces and tabs for indentation
  341. "no-mixed-spaces-and-tabs": 1,
  342. // disallow multiple empty lines
  343. "no-multiple-empty-lines": [1, {"max": 2, "maxEOF": 1}],
  344. // disallow negated conditions
  345. "no-negated-condition": 0,
  346. // disallow nested ternary expressions
  347. "no-nested-ternary": 1,
  348. // disallow use of the Object constructor
  349. "no-new-object": 1,
  350. // disallow use of unary operators, ++ and --
  351. "no-plusplus": 0,
  352. // disallow use of certain syntax in code
  353. "no-restricted-syntax": 0,
  354. // disallow space between function identifier and application
  355. "no-spaced-func": 1,
  356. // disallow the use of ternary operators
  357. "no-ternary": 0,
  358. // disallow trailing whitespace at the end of lines
  359. "no-trailing-spaces": 1,
  360. // disallow dangling underscores in identifiers
  361. "no-underscore-dangle": 0,
  362. // disallow the use of Boolean literals in conditional expressions
  363. "no-unneeded-ternary": 0,
  364. // require or disallow padding inside curly braces
  365. "object-curly-spacing": 0,
  366. // allow just one var statement per function
  367. "one-var": [1, "never"],
  368. // require assignment operator shorthand where possible or prohibit it entirely
  369. "operator-assignment": 0,
  370. // enforce operators to be placed before or after line breaks
  371. "operator-linebreak": 0,
  372. // enforce padding within blocks
  373. "padded-blocks": [1, "never"],
  374. // require quotes around object literal property names
  375. "quote-props": 0,
  376. // specify whether double or single quotes should be used
  377. "quotes": [1, "single", "avoid-escape"],
  378. // Require JSDoc comment
  379. "require-jsdoc": 0,
  380. // enforce spacing before and after semicolons
  381. "semi-spacing": [1, {"before": false, "after": true}],
  382. // require or disallow use of semicolons instead of ASI
  383. "semi": [1, "always"],
  384. // sort variables within the same declaration block
  385. "sort-vars": 0,
  386. // require a space after certain keywords
  387. "keyword-spacing": 1,
  388. // require or disallow space before blocks
  389. "space-before-blocks": 1,
  390. // require or disallow space before function opening parenthesis
  391. "space-before-function-paren": [0, {"anonymous": "always", "named": "never"}],
  392. // require or disallow space before blocks
  393. "space-in-parens": 0,
  394. // require spaces around operators
  395. "space-infix-ops": 1,
  396. // Require or disallow spaces before/after unary operators
  397. "space-unary-ops": 0,
  398. // require or disallow a space immediately following the // or /* in a comment
  399. "spaced-comment": [1, "always", {
  400. "exceptions": ["-", "+", "/", "="],
  401. "markers": ["=", "!"] // space here to support sprockets directives
  402. }],
  403. // require regex literals to be wrapped in parentheses
  404. "wrap-regex": 0,
  405. //=========================================================================
  406. //==================== ES6 Rules ==========================================
  407. //=========================================================================
  408. "arrow-body-style": [1, "as-needed"],
  409. // require parens in arrow function arguments
  410. "arrow-parens": [1, "as-needed"],
  411. // require space before/after arrow function"s arrow
  412. "arrow-spacing": 1,
  413. // verify super() callings in constructors
  414. "constructor-super": 1,
  415. // enforce the spacing around the * in generator functions
  416. "generator-star-spacing": 1,
  417. // disallow arrow functions where a condition is expected
  418. "no-confusing-arrow": 1,
  419. // disallow modifying variables of class declarations
  420. "no-class-assign": 1,
  421. // disallow modifying variables that are declared using const
  422. "no-const-assign": 1,
  423. // disallow duplicate name in class members
  424. "no-dupe-class-members": 1,
  425. // disallow to use this/super before super() calling in constructors.
  426. "no-this-before-super": 1,
  427. // require let or const instead of var
  428. "no-var": 0, //TODO: enable on full migration to es6
  429. // require method and property shorthand syntax for object literals
  430. "object-shorthand": 0,
  431. // suggest using arrow functions as callbacks
  432. "prefer-arrow-callback": 0, //TODO: enable on full migration to es6
  433. // suggest using of const declaration for variables that are never modified after declared
  434. "prefer-const": 0, //TODO: enable on full migration to es6
  435. // suggest using Reflect methods where applicable
  436. "prefer-reflect": 0,
  437. // suggest using the spread operator instead of .apply()
  438. "prefer-spread": 0,
  439. // suggest using template literals instead of strings concatenation
  440. "prefer-template": 0, //TODO: enable on full migration to es6
  441. // disallow generator functions that do not have yield
  442. "require-yield": 0
  443. }
  444. }