.eslintrc.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. module.exports = {
  2. root: true,
  3. parser: 'babel-eslint',
  4. parserOptions: {
  5. sourceType: 'module'
  6. },
  7. env: {
  8. browser: true,
  9. node: true
  10. },
  11. extends: 'eslint:recommended',
  12. // required to lint *.vue files
  13. plugins: [
  14. 'html'
  15. ],
  16. // check if imports actually resolve
  17. 'settings': {
  18. 'import/resolver': {
  19. 'webpack': {
  20. 'config': 'build/webpack.base.conf.js'
  21. }
  22. }
  23. },
  24. // add your custom rules here
  25. 'rules': {
  26. // don't require .vue extension when importing
  27. // 'import/extensions': ['error', 'always', {
  28. // 'js': 'never',
  29. // 'vue': 'never'
  30. // }],
  31. // allow debugger during development
  32. 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  33. /*
  34. * Possible Errors
  35. */
  36. // disallow unnecessary parentheses
  37. 'no-extra-parens': ['error', 'all', {'nestedBinaryExpressions': false}],
  38. // disallow negating the left operand of relational operators
  39. 'no-unsafe-negation': 'error',
  40. // enforce valid JSDoc comments
  41. 'valid-jsdoc': 'off',
  42. /*
  43. * Best Practices
  44. */
  45. // enforce return statements in callbacks of array methods
  46. 'array-callback-return': 'error',
  47. // enforce consistent brace style for all control statements
  48. curly: ['error', 'multi-line'],
  49. // enforce consistent newlines before and after dots
  50. 'dot-location': ['error', 'property'],
  51. // enforce dot notation whenever possible
  52. 'dot-notation': 'error',
  53. // require the use of === and !==
  54. 'eqeqeq': ['error', 'smart'],
  55. // disallow the use of arguments.caller or arguments.callee
  56. 'no-caller': 'error',
  57. // disallow empty functions
  58. 'no-empty-function': 'error',
  59. // disallow unnecessary calls to .bind()
  60. 'no-extra-bind': 'error',
  61. // disallow unnecessary labels
  62. 'no-extra-label': 'error',
  63. // disallow leading or trailing decimal points in numeric literals
  64. 'no-floating-decimal': 'error',
  65. // disallow assignments to native objects or read-only global variables
  66. 'no-global-assign': 'error',
  67. // disallow the use of eval()-like methods
  68. 'no-implied-eval': 'error',
  69. // disallow the use of the __iterator__ property
  70. 'no-iterator': 'error',
  71. // disallow unnecessary nested blocks
  72. 'no-lone-blocks': 'error',
  73. // disallow multiple spaces
  74. 'no-multi-spaces': 'error',
  75. // disallow new operators with the String, Number, and Boolean objects
  76. 'no-new-wrappers': 'error',
  77. // disallow octal escape sequences in string literals
  78. 'no-octal-escape': 'error',
  79. // disallow the use of the __proto__ property
  80. 'no-proto': 'error',
  81. // disallow comparisons where both sides are exactly the same
  82. 'no-self-compare': 'error',
  83. // disallow throwing literals as exceptions
  84. 'no-throw-literal': 'error',
  85. // disallow unused expressions
  86. 'no-unused-expressions': 'error',
  87. // disallow unnecessary calls to .call() and .apply()
  88. 'no-useless-call': 'error',
  89. // disallow unnecessary concatenation of literals or template literals
  90. 'no-useless-concat': 'error',
  91. // disallow unnecessary escape characters
  92. 'no-useless-escape': 'error',
  93. // disallow void operators
  94. 'no-void': 'error',
  95. // require parentheses around immediate function invocations
  96. 'wrap-iife': 'error',
  97. // require or disallow “Yoda” conditions
  98. yoda: 'error',
  99. /*
  100. * Variables
  101. */
  102. // disallow labels that share a name with a variable
  103. 'no-label-var': 'error',
  104. // disallow initializing variables to undefined
  105. 'no-undef-init': 'error',
  106. 'no-undef': 'off',
  107. // disallow the use of variables before they are defined
  108. 'no-use-before-define': 'error',
  109. /*
  110. * Node.js and CommonJS
  111. */
  112. // disallow new operators with calls to require
  113. 'no-new-require': 'error',
  114. /*
  115. * Stylistic Issues
  116. */
  117. // enforce consistent spacing inside array brackets
  118. 'array-bracket-spacing': 'error',
  119. // enforce consistent spacing inside single-line blocks
  120. 'block-spacing': 'error',
  121. // enforce consistent brace style for blocks
  122. 'brace-style': ['error', '1tbs', {'allowSingleLine': true}],
  123. // require or disallow trailing commas
  124. 'comma-dangle': 'error',
  125. // enforce consistent spacing before and after commas
  126. 'comma-spacing': 'error',
  127. // enforce consistent comma style
  128. 'comma-style': 'error',
  129. // enforce consistent spacing inside computed property brackets
  130. 'computed-property-spacing': 'error',
  131. // require or disallow spacing between function identifiers and their invocations
  132. 'func-call-spacing': 'error',
  133. // enforce consistent indentation
  134. indent: ['error', 2, {SwitchCase: 1}],
  135. // enforce the consistent use of either double or single quotes in JSX attributes
  136. 'jsx-quotes': 'error',
  137. // enforce consistent spacing between keys and values in object literal properties
  138. 'key-spacing': 'error',
  139. // enforce consistent spacing before and after keywords
  140. 'keyword-spacing': 'error',
  141. // enforce consistent linebreak style
  142. 'linebreak-style': 'error',
  143. // require or disallow newlines around directives
  144. 'lines-around-directive': 'error',
  145. // require constructor names to begin with a capital letter
  146. 'new-cap': 'off',
  147. // require parentheses when invoking a constructor with no arguments
  148. 'new-parens': 'error',
  149. // disallow Array constructors
  150. 'no-array-constructor': 'error',
  151. // disallow Object constructors
  152. 'no-new-object': 'error',
  153. // disallow trailing whitespace at the end of lines
  154. 'no-trailing-spaces': 'error',
  155. // disallow ternary operators when simpler alternatives exist
  156. 'no-unneeded-ternary': 'error',
  157. // disallow whitespace before properties
  158. 'no-whitespace-before-property': 'error',
  159. // enforce consistent spacing inside braces
  160. 'object-curly-spacing': ['error', 'always'],
  161. // require or disallow padding within blocks
  162. 'padded-blocks': ['error', 'never'],
  163. // require quotes around object literal property names
  164. 'quote-props': ['error', 'as-needed'],
  165. // enforce the consistent use of either backticks, double, or single quotes
  166. quotes: ['error', 'single'],
  167. // enforce consistent spacing before and after semicolons
  168. 'semi-spacing': 'error',
  169. // require or disallow semicolons instead of ASI
  170. // semi: ['error', 'never'],
  171. // enforce consistent spacing before blocks
  172. 'space-before-blocks': 'error',
  173. 'no-console': 'off',
  174. // enforce consistent spacing before function definition opening parenthesis
  175. 'space-before-function-paren': ['error', 'never'],
  176. // enforce consistent spacing inside parentheses
  177. 'space-in-parens': 'error',
  178. // require spacing around infix operators
  179. 'space-infix-ops': 'error',
  180. // enforce consistent spacing before or after unary operators
  181. 'space-unary-ops': 'error',
  182. // enforce consistent spacing after the // or /* in a comment
  183. 'spaced-comment': 'error',
  184. // require or disallow Unicode byte order mark (BOM)
  185. 'unicode-bom': 'error',
  186. /*
  187. * ECMAScript 6
  188. */
  189. // require braces around arrow function bodies
  190. 'arrow-body-style': 'error',
  191. // require parentheses around arrow function arguments
  192. 'arrow-parens': ['error', 'as-needed'],
  193. // enforce consistent spacing before and after the arrow in arrow functions
  194. 'arrow-spacing': 'error',
  195. // enforce consistent spacing around * operators in generator functions
  196. 'generator-star-spacing': ['error', 'after'],
  197. // disallow duplicate module imports
  198. 'no-duplicate-imports': 'error',
  199. // disallow unnecessary computed property keys in object literals
  200. 'no-useless-computed-key': 'error',
  201. // disallow unnecessary constructors
  202. 'no-useless-constructor': 'error',
  203. // disallow renaming import, export, and destructured assignments to the same name
  204. 'no-useless-rename': 'error',
  205. // require let or const instead of var
  206. 'no-var': 'error',
  207. // require or disallow method and property shorthand syntax for object literals
  208. 'object-shorthand': 'error',
  209. // require arrow functions as callbacks
  210. 'prefer-arrow-callback': 'error',
  211. // require const declarations for variables that are never reassigned after declared
  212. 'prefer-const': 'error',
  213. // disallow parseInt() in favor of binary, octal, and hexadecimal literals
  214. 'prefer-numeric-literals': 'error',
  215. // require rest parameters instead of arguments
  216. 'prefer-rest-params': 'error',
  217. // require spread operators instead of .apply()
  218. 'prefer-spread': 'error',
  219. // enforce spacing between rest and spread operators and their expressions
  220. 'rest-spread-spacing': 'error',
  221. // require or disallow spacing around embedded expressions of template strings
  222. 'template-curly-spacing': 'error',
  223. // require or disallow spacing around the * in yield* expressions
  224. 'yield-star-spacing': 'error'
  225. }
  226. }