.eslintrc.cjs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* eslint-env node */
  2. require('@rushstack/eslint-patch/modern-module-resolution')
  3. module.exports = {
  4. root: true,
  5. 'extends': [
  6. 'plugin:vue/vue3-essential',
  7. 'eslint:recommended',
  8. '@vue/eslint-config-typescript',
  9. '@vue/eslint-config-prettier/skip-formatting'
  10. ],
  11. parserOptions: {
  12. ecmaVersion: 'latest'
  13. },
  14. env: {
  15. node: true
  16. },
  17. /**
  18. * "off" 或 0 ==> 关闭规则
  19. * "warn" 或 1 ==> 打开的规则作为警告(不影响代码执行)
  20. * "error" 或 2 ==> 规则作为一个错误(代码不能执行,界面报错)
  21. */
  22. rules: {
  23. // ===============================>>> eslint (http://eslint.cn/docs/rules)
  24. 'no-var': 'error', // 要求使用 let 或 const 而不是 var
  25. 'prefer-const': 'off', // 使用 let 关键字声明但在初始分配后从未重新分配的变量,要求使用 const
  26. 'eqeqeq': 'warn', // 要求使用 === 和 !==
  27. // ===============================>>> typeScript (https://typescript-eslint.io/rules)
  28. 'no-undef': 'off', // 禁止使用未定义的变量
  29. '@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }],
  30. // ===============================>>> vue (https://eslint.vuejs.org/rules)
  31. 'vue/no-mutating-props': ['error', {
  32. 'shallowOnly': true // 允许修改prop的值,但保持引用不变
  33. }],
  34. 'vue/multi-word-component-names': 'off' // 组件名强制使用短横线连接
  35. }
  36. }