.eslintrc.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // ESLint 检查 .vue 文件需要单独配置编辑器:
  2. // https://eslint.vuejs.org/user-guide/#editor-integrations
  3. module.exports = {
  4. root: true,
  5. env: {
  6. browser: true,
  7. commonjs: true,
  8. es6: true,
  9. jest: true,
  10. jquery: true,
  11. node: true,
  12. },
  13. 'extends': [
  14. 'eslint:recommended',
  15. // "plugin:vue/base",
  16. 'plugin:vue/recommended',
  17. ],
  18. parserOptions: {
  19. parser: 'babel-eslint'
  20. // "parser": "@babel/eslint-parser"
  21. },
  22. rules: {
  23. 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  24. 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  25. 'semi': ['error', 'never'],
  26. "no-unused-vars": ["warn", {
  27. "vars": "all",
  28. "args": "after-used",
  29. "ignoreRestSiblings": false
  30. }],
  31. "keyword-spacing": ["error", { "before": true, "after": true }],
  32. "object-curly-spacing": ["error", "always"],
  33. "space-infix-ops": ["error"],
  34. 'key-spacing': ["error", {
  35. "mode": "strict"
  36. }],
  37. "comma-spacing": ["error", { "before": false, "after": true }],
  38. "func-call-spacing": ["error", "never"],
  39. "semi-spacing": ["error", { "before": false, "after": true }],
  40. "space-before-blocks": ["error", "always"],
  41. 'no-trailing-spaces': 'error',
  42. 'no-multi-spaces': 'error',
  43. "indent": ["error", 2],
  44. 'no-empty': 'off',
  45. // 默认不启用:为了避免细微的 bug,最好直接从 Object.prototype 调用挂载于prototype上的方法方法。例如,foo.hasOwnProperty("bar") 应该替换为 Object.prototype.hasOwnProperty.call(foo, "bar")。
  46. 'no-prototype-builtins': "off",
  47. },
  48. globals: {
  49. globalConfig: true,
  50. globalApi: true,
  51. globalUtils: true,
  52. globalMapState: true,
  53. globalMapGetters: true,
  54. globalMapMutations: true,
  55. store: true,
  56. utils: true,
  57. }
  58. }