es6.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /**
  2. * ES6
  3. */
  4. 'use strict';
  5. module.exports = {
  6. env: {
  7. es6: true,
  8. },
  9. parserOptions: {
  10. ecmaVersion: 6,
  11. },
  12. rules: {
  13. /**
  14. * This rule allows the use of braces around arrow function body, even if they can be omitted
  15. * @see http://eslint.org/docs/rules/arrow-body-style
  16. * @since 3.0.0
  17. * @example
  18. *
  19. * ```js
  20. * // correct
  21. * let foo = () => {
  22. * return 0;
  23. * };
  24. *
  25. * let foo = () => {
  26. * return {
  27. * bar: {
  28. * foo: 1,
  29. * bar: 2,
  30. * }
  31. * };
  32. * };
  33. *
  34. * let foo = () => 0;
  35. *
  36. * let foo = () => ({
  37. * bar: {
  38. * foo: 1,
  39. * bar: 2,
  40. * }
  41. * });
  42. ** ```
  43. */
  44. 'arrow-body-style': 'off',
  45. /**
  46. * This rule disallows the use of parens when they are no required
  47. * @see http://eslint.org/docs/rules/arrow-parens
  48. */
  49. 'arrow-parens': [ 'error', 'as-needed' ],
  50. /**
  51. * This rule normalize style of spacing before and after an arrow function's arrow(`=>`)
  52. * @see http://eslint.org/docs/rules/arrow-spacing
  53. */
  54. 'arrow-spacing': [ 'error', { before: true, after: true }],
  55. /**
  56. * It doesn't check whether or not there is a valid `super()` call
  57. * @see http://eslint.org/docs/rules/constructor-super
  58. */
  59. 'constructor-super': 'off',
  60. /**
  61. * This rule enforces spacing after the `*` of generator functions, but omitting before that
  62. * @see http://eslint.org/docs/rules/generator-star-spacing
  63. * @since 3.0.0
  64. * @example
  65. *
  66. * ```js
  67. * function* generator() {
  68. * yield '44';
  69. * yield '55';
  70. * }
  71. * ```
  72. */
  73. 'generator-star-spacing': [ 'error', { before: false, after: true }],
  74. /**
  75. * This rule disallows modifying variables of class declarations
  76. * @see http://eslint.org/docs/rules/no-class-assign
  77. */
  78. 'no-class-assign': 'error',
  79. /**
  80. * Disallow arrow functions where they could be confused with comparisons
  81. * @see http://eslint.org/docs/rules/no-confusing-arrow
  82. * @example
  83. *
  84. * ```js
  85. * var x = a => 1 ? 2 : 3; // incorrect
  86. * var x = a => (1 ? 2 : 3); // correct
  87. * ````
  88. */
  89. 'no-confusing-arrow': [ 'error', {
  90. allowParens: true,
  91. }],
  92. /**
  93. * Disallow modifying variables that are declared using `const`
  94. * @see http://eslint.org/docs/rules/no-const-assign
  95. */
  96. 'no-const-assign': 'error',
  97. /**
  98. * Disallow duplicate name in class members
  99. * @see http://eslint.org/docs/rules/no-dupe-class-members
  100. */
  101. 'no-dupe-class-members': 'error',
  102. /**
  103. * allow Symbol Constructor
  104. * @see http://eslint.org/docs/rules/no-new-symbol
  105. */
  106. 'no-new-symbol': 'off',
  107. /**
  108. * Disallow use of this/super before calling super() in constructors
  109. * @see http://eslint.org/docs/rules/no-this-before-super
  110. * @since 3.0.0
  111. */
  112. 'no-this-before-super': 'error',
  113. /**
  114. * Disallow unnecessary computed property keys on objects
  115. * @see http://eslint.org/docs/rules/no-useless-computed-key
  116. * @example
  117. *
  118. * ```js
  119. * foo = { ['a' + 'b']: 'foo' }; // correct
  120. * foo = { ['a']: 'bar' }; // incorrect
  121. * ```
  122. */
  123. 'no-useless-computed-key': 'error',
  124. /**
  125. * Disallow unnecessary constructor
  126. * @see http://eslint.org/docs/rules/no-useless-constructor
  127. */
  128. 'no-useless-constructor': 'error',
  129. /**
  130. * require `let` or `const` instead of `var`
  131. * @see http://eslint.org/docs/rules/no-var
  132. */
  133. 'no-var': 'error',
  134. /**
  135. * Require Object Literal Shorthand Syntax
  136. * @see http://eslint.org/docs/rules/object-shorthand
  137. * @since 3.0.0
  138. * @example
  139. *
  140. * ```js
  141. * // correct
  142. * // properties
  143. * const foo = { x, y, z };
  144. *
  145. * // methods
  146. * const foo = {
  147. * a() {},
  148. * b() {}
  149. * };
  150. *
  151. * const bar = {
  152. * ConstructorFunction: function() {}
  153. * };
  154. *
  155. * // incorrect
  156. * const foo = {
  157. * 'a-b'() {}
  158. * };
  159. * ```
  160. */
  161. 'object-shorthand': [ 'error', 'always', {
  162. avoidQuotes: true,
  163. ignoreConstructors: false,
  164. }],
  165. /**
  166. * If a variable is never reassigned, using the `const` declaration is better
  167. * @see http://eslint.org/docs/rules/prefer-const
  168. * @since 3.0.0
  169. * @example
  170. *
  171. * 1. Specially, if all variables in destructuring should be `const`,
  172. * this rule warns the variables
  173. *
  174. * ```js
  175. * // incorrect
  176. * let { a, b } = obj;
  177. * console.log(a, b);
  178. *
  179. * // correct
  180. * let { a, b } = obj;
  181. * a = a + 1;
  182. * console.log(a, b);
  183. * ```
  184. */
  185. 'prefer-const': [ 'error', {
  186. destructuring: 'all',
  187. ignoreReadBeforeAssign: true,
  188. }],
  189. /**
  190. * This rule doesn't prefer using Reflect methods where applicable
  191. * @see http://eslint.org/docs/rules/prefer-reflect
  192. */
  193. 'prefer-reflect': 'off',
  194. /**
  195. * This rule doesn't prefer using the rest parameters instead of `arguments`
  196. * @see http://eslint.org/docs/rules/prefer-rest-params
  197. * @since 3.0.0
  198. */
  199. 'prefer-rest-params': 'off',
  200. /**
  201. * This rule doesn't prefer using the spread operator instead of `.apply()`
  202. * @see http://eslint.org/docs/rules/prefer-spread
  203. */
  204. 'prefer-spread': 'off',
  205. /**
  206. * Suggest using template syntax instead of string concat
  207. * @see http://eslint.org/docs/rules/prefer-template
  208. */
  209. 'prefer-template': 'off',
  210. /**
  211. * This rule doesn't require a valid `yield` in generator functions
  212. * @see http://eslint.org/docs/rules/require-yield
  213. */
  214. 'require-yield': 'off',
  215. /**
  216. * This rule disallows usage of spacing in template strings
  217. * @see http://eslint.org/docs/rules/template-curly-spacing
  218. * @example
  219. *
  220. * ```js
  221. * // incorrect
  222. * `${ bar }`;
  223. * `hello, ${ people.name}!`;
  224. * `hello, ${people.name }!`;
  225. *
  226. * // correct
  227. * `${bar}`;
  228. * `hello, ${people.name}!`;
  229. *
  230. * // specially, this is correct
  231. * `${
  232. * bar
  233. * }`;
  234. * ```
  235. */
  236. 'template-curly-spacing': 'error',
  237. /**
  238. * Enforce spacing after the `*` in `yield*` expressions
  239. * @see http://eslint.org/docs/rules/yield-star-spacing
  240. */
  241. 'yield-star-spacing': [ 'error', { before: false, after: true }],
  242. /**
  243. * only pass instances of the built-in Error object to the reject() function
  244. * @see https://eslint.org/docs/rules/prefer-promise-reject-errors
  245. */
  246. 'prefer-promise-reject-errors': 'error',
  247. },
  248. };