.eslintrc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. {
  2. "env": {
  3. "browser": true,
  4. "node": true,
  5. "commonjs": true
  6. },
  7. "ecmaFeatures": {
  8. // lambda表达式
  9. "arrowFunctions": true,
  10. // 解构赋值
  11. "destructuring": true,
  12. // class
  13. "classes": true,
  14. // http://es6.ruanyifeng.com/#docs/function#函数参数的默认值
  15. "defaultParams": true,
  16. // 块级作用域,允许使用let const
  17. "blockBindings": true,
  18. // 允许使用模块,模块内默认严格模式
  19. "modules": true,
  20. // 允许字面量定义对象时,用表达式做属性名
  21. // http://es6.ruanyifeng.com/#docs/object#属性名表达式
  22. "objectLiteralComputedProperties": true,
  23. // 允许对象字面量方法名简写
  24. /*var o = {
  25. method() {
  26. return "Hello!";
  27. }
  28. };
  29. 等同于
  30. var o = {
  31. method: function() {
  32. return "Hello!";
  33. }
  34. };
  35. */
  36. "objectLiteralShorthandMethods": true,
  37. /*
  38. 对象字面量属性名简写
  39. var foo = 'bar';
  40. var baz = {foo};
  41. baz // {foo: "bar"}
  42. // 等同于
  43. var baz = {foo: foo};
  44. */
  45. "objectLiteralShorthandProperties": true,
  46. // http://es6.ruanyifeng.com/#docs/function#rest参数
  47. "restParams": true,
  48. // http://es6.ruanyifeng.com/#docs/function#扩展运算符
  49. "spread": true,
  50. // http://es6.ruanyifeng.com/#docs/iterator#for---of循环
  51. "forOf": true,
  52. // http://es6.ruanyifeng.com/#docs/generator
  53. "generators": true,
  54. // http://es6.ruanyifeng.com/#docs/string#模板字符串
  55. "templateStrings": true,
  56. "superInFunctions": true,
  57. // http://es6.ruanyifeng.com/#docs/object#对象的扩展运算符
  58. "experimentalObjectRestSpread": true
  59. },
  60. "rules": {
  61. // 定义对象的set存取器属性时,强制定义get
  62. "accessor-pairs": 2,
  63. // 指定数组的元素之间要以空格隔开(,后面), never参数:[ 之前和 ] 之后不能带空格,always参数:[ 之前和 ] 之后必须带空格
  64. "array-bracket-spacing": [2, "never"],
  65. // 在块级作用域外访问块内定义的变量是否报错提示
  66. "block-scoped-var": 0,
  67. // if while function 后面的{必须与if在同一行,java风格。
  68. "brace-style": [2, "1tbs", { "allowSingleLine": true }],
  69. // 双峰驼命名格式
  70. "camelcase": 2,
  71. // 数组和对象键值对最后一个逗号, never参数:不能带末尾的逗号, always参数:必须带末尾的逗号,
  72. // always-multiline:多行模式必须带逗号,单行模式不能带逗号
  73. "comma-dangle": [2, "never"],
  74. // 控制逗号前后的空格
  75. "comma-spacing": [2, { "before": false, "after": true }],
  76. // 控制逗号在行尾出现还是在行首出现
  77. // http://eslint.org/docs/rules/comma-style
  78. "comma-style": [2, "last"],
  79. // 圈复杂度
  80. "complexity": [2,9],
  81. // 以方括号取对象属性时,[ 后面和 ] 前面是否需要空格, 可选参数 never, always
  82. "computed-property-spacing": [2,"never"],
  83. // 强制方法必须返回值,TypeScript强类型,不配置
  84. "consistent-return": 0,
  85. // 用于指统一在回调函数中指向this的变量名,箭头函数中的this已经可以指向外层调用者,应该没卵用了
  86. // e.g [0,"that"] 指定只能 var that = this. that不能指向其他任何值,this也不能赋值给that以外的其他值
  87. "consistent-this": 0,
  88. // 强制在子类构造函数中用super()调用父类构造函数,TypeScrip的编译器也会提示
  89. "constructor-super": 0,
  90. // if else while for do后面的代码块是否需要{ }包围,参数:
  91. // multi 只有块中有多行语句时才需要{ }包围
  92. // multi-line 只有块中有多行语句时才需要{ }包围, 但是块中的执行语句只有一行时,
  93. // 块中的语句只能跟和if语句在同一行。if (foo) foo++; else doSomething();
  94. // multi-or-nest 只有块中有多行语句时才需要{ }包围, 如果块中的执行语句只有一行,执行语句可以零另起一行也可以跟在if语句后面
  95. // [2, "multi", "consistent"] 保持前后语句的{ }一致
  96. // default: [2, "all"] 全都需要{ }包围
  97. "curly": [2, "all"],
  98. // switch语句强制default分支,也可添加 // no default 注释取消此次警告
  99. "default-case": 2,
  100. // 强制object.key 中 . 的位置,参数:
  101. // property,'.'号应与属性在同一行
  102. // object, '.' 号应与对象名在同一行
  103. "dot-location": [2, "property"],
  104. // 强制使用.号取属性
  105. // 参数: allowKeywords:true 使用保留字做属性名时,只能使用.方式取属性
  106. // false 使用保留字做属性名时, 只能使用[]方式取属性 e.g [2, {"allowKeywords": false}]
  107. // allowPattern: 当属性名匹配提供的正则表达式时,允许使用[]方式取值,否则只能用.号取值 e.g [2, {"allowPattern": "^[a-z]+(_[a-z]+)+$"}]
  108. "dot-notation": [2, {"allowKeywords": true}],
  109. // 文件末尾强制换行
  110. "eol-last": 2,
  111. // 使用 === 替代 ==
  112. "eqeqeq": [2, "allow-null"],
  113. // 方法表达式是否需要命名
  114. "func-names": 0,
  115. // 方法定义风格,参数:
  116. // declaration: 强制使用方法声明的方式,function f(){} e.g [2, "declaration"]
  117. // expression:强制使用方法表达式的方式,var f = function() {} e.g [2, "expression"]
  118. // allowArrowFunctions: declaration风格中允许箭头函数。 e.g [2, "declaration", { "allowArrowFunctions": true }]
  119. "func-style": 0,
  120. "generator-star-spacing": [2, { "before": true, "after": true }],
  121. "guard-for-in": 0,
  122. "handle-callback-err": [2, "^(err|error)$" ],
  123. "indent": [2, 2, { "SwitchCase": 1 }],
  124. "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
  125. "linebreak-style": 0,
  126. "lines-around-comment": 0,
  127. "max-nested-callbacks": 0,
  128. "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
  129. "new-parens": 2,
  130. "newline-after-var": 0,
  131. "no-alert": 0,
  132. "no-array-constructor": 2,
  133. "no-caller": 2,
  134. "no-catch-shadow": 0,
  135. "no-cond-assign": 2,
  136. "no-console": 0,
  137. "no-constant-condition": 0,
  138. "no-continue": 0,
  139. "no-control-regex": 2,
  140. "no-debugger": 2,
  141. "no-delete-var": 2,
  142. "no-div-regex": 0,
  143. "no-dupe-args": 2,
  144. "no-dupe-keys": 2,
  145. "no-duplicate-case": 2,
  146. "no-else-return": 0,
  147. "no-empty": 0,
  148. "no-empty-character-class": 2,
  149. "no-empty-label": 2,
  150. "no-eq-null": 0,
  151. "no-eval": 2,
  152. "no-ex-assign": 2,
  153. "no-extend-native": 2,
  154. "no-extra-bind": 2,
  155. "no-extra-boolean-cast": 2,
  156. "no-extra-parens": 0,
  157. "no-extra-semi": 0,
  158. "no-fallthrough": 2,
  159. "no-floating-decimal": 2,
  160. "no-func-assign": 2,
  161. "no-implied-eval": 2,
  162. "no-inline-comments": 0,
  163. "no-inner-declarations": [2, "functions"],
  164. "no-invalid-regexp": 2,
  165. "no-irregular-whitespace": 2,
  166. "no-iterator": 2,
  167. "no-label-var": 2,
  168. "no-labels": 2,
  169. "no-lone-blocks": 2,
  170. "no-lonely-if": 0,
  171. "no-loop-func": 0,
  172. "no-mixed-requires": 0,
  173. "no-mixed-spaces-and-tabs": 2,
  174. "no-multi-spaces": 2,
  175. "no-multi-str": 2,
  176. "no-multiple-empty-lines": [2, { "max": 1 }],
  177. "no-native-reassign": 2,
  178. "no-negated-in-lhs": 2,
  179. "no-nested-ternary": 0,
  180. "no-new": 2,
  181. "no-new-func": 0,
  182. "no-new-object": 2,
  183. "no-new-require": 2,
  184. "no-new-wrappers": 2,
  185. "no-obj-calls": 2,
  186. "no-octal": 2,
  187. "no-octal-escape": 2,
  188. "no-param-reassign": 0,
  189. "no-path-concat": 0,
  190. "no-process-env": 0,
  191. "no-process-exit": 0,
  192. "no-proto": 0,
  193. "no-redeclare": 2,
  194. "no-regex-spaces": 2,
  195. "no-restricted-modules": 0,
  196. "no-return-assign": 2,
  197. "no-script-url": 0,
  198. "no-self-compare": 2,
  199. "no-sequences": 2,
  200. "no-shadow": 0,
  201. "no-shadow-restricted-names": 2,
  202. "no-spaced-func": 2,
  203. "no-sparse-arrays": 2,
  204. "no-sync": 0,
  205. "no-ternary": 0,
  206. "no-this-before-super": 2,
  207. "no-throw-literal": 2,
  208. "no-trailing-spaces": 2,
  209. "no-undef": 2,
  210. "no-undef-init": 2,
  211. "no-undefined": 0,
  212. "no-underscore-dangle": 0,
  213. "no-unexpected-multiline": 2,
  214. "no-unneeded-ternary": 2,
  215. "no-unreachable": 2,
  216. "no-unused-expressions": 0,
  217. "no-unused-vars": [2, { "vars": "all", "args": "none" }],
  218. "no-use-before-define": 0,
  219. "no-var": 0,
  220. "no-void": 0,
  221. "no-warning-comments": 0,
  222. "no-with": 2,
  223. "object-curly-spacing": 0,
  224. "object-shorthand": 0,
  225. "one-var": [2, { "initialized": "never" }],
  226. "operator-assignment": 0,
  227. "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
  228. "padded-blocks": 0,
  229. "prefer-const": 0,
  230. "quote-props": 0,
  231. "quotes": [2, "single", "avoid-escape"],
  232. "radix": 2,
  233. "semi": [2, "never"],
  234. "semi-spacing": 0,
  235. "sort-vars": 0,
  236. "space-after-keywords": [2, "always"],
  237. "space-before-blocks": [2, "always"],
  238. "space-before-function-paren": [2, "always"],
  239. "space-in-parens": [2, "never"],
  240. "space-infix-ops": 2,
  241. "space-return-throw-case": 2,
  242. "space-unary-ops": [2, { "words": true, "nonwords": false }],
  243. "spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!"] }],
  244. "strict": 0,
  245. "use-isnan": 2,
  246. "valid-jsdoc": 0,
  247. "valid-typeof": 2,
  248. "vars-on-top": 0,
  249. "wrap-iife": [2, "any"],
  250. "wrap-regex": 0,
  251. "yoda": [2, "never"]
  252. }
  253. }