.eslintrc.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.exports = {
  2. root: true,
  3. env: {
  4. node: true
  5. },
  6. 'extends': [
  7. 'plugin:vue/essential',
  8. '@vue/standard'
  9. ],
  10. rules: {
  11. 'indent': [0, 2],
  12. // allow paren-less arrow functions
  13. 'arrow-parens': 0,
  14. // allow async-await
  15. 'generator-star-spacing': 0,
  16. // no whitespace
  17. 'space-before-function-paren': ['error', {
  18. 'anonymous': 'never',
  19. 'named': 'never',
  20. 'asyncArrow': 'always'
  21. }],
  22. // 多行注释允许无空格
  23. 'spaced-comment': ['error', 'always', { 'exceptions': ['*'] }],
  24. // 禁止使用alert confirm prompt
  25. 'no-alert': process.env.NODE_ENV === 'production' ? 1 : 0,
  26. // 使用三元操作符
  27. 'no-ternary': 0,
  28. // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
  29. 'no-unneeded-ternary': 0,
  30. // 嵌套块深度
  31. 'max-depth': [0, 3],
  32. // 循环复杂度
  33. 'complexity': [0, 10],
  34. // allow async-await
  35. // 'generator-star-spacing': 'off',
  36. 'no-console': process.env.NODE_ENV === 'production' ? 'off' : 'off',
  37. 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  38. },
  39. parserOptions: {
  40. parser: 'babel-eslint'
  41. },
  42. // 全局变量
  43. globals: {
  44. '$': true,
  45. 'echarts': true,
  46. 'vm': true
  47. }
  48. }