.eslintrc.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. module.exports = {
  2. root: true,
  3. env: {
  4. node: true
  5. },
  6. parser: '@typescript-eslint/parser', // 关键
  7. plugins: ['@typescript-eslint'],
  8. 'extends': [
  9. 'plugin:vue/essential',
  10. 'eslint:recommended'
  11. ],
  12. rules: {
  13. 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
  14. 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
  15. "no-unused-vars":"off", //关闭声明后未被使用的变量或参数
  16. "no-prototype-builtins": "off", // 允许直接调用Object.prototype方法
  17. "vue/no-unused-components": "off", // 允许未使用的组件
  18. "vue/no-unused-vars": "off", // 允许模板中未使用的变量
  19. "vue/no-parsing-error": "off", // 允许Vue模板解析错误
  20. "no-redeclare": "off", // 允许重复声明
  21. "no-self-assign": "off", // 允许自我赋值
  22. "vue/no-mutating-props": "off", // 允许修改props
  23. "vue/no-use-v-if-with-v-for": "off", // 允许v-if与v-for一起使用
  24. "vue/require-valid-default-prop": "off", // 允许props默认值不是函数
  25. "no-irregular-whitespace": "off" // 允许不规则空白
  26. },
  27. parserOptions: {
  28. ecmaVersion: 2020,
  29. sourceType: 'module',
  30. project: './tsconfig.json', // 如有类型检查规则
  31. extraFileExtensions: ['.vue']
  32. },
  33. overrides: [
  34. {
  35. files: ['*.ts', '*.tsx', '*.d.ts'],
  36. rules: {
  37. // 如有需要关掉历史规则
  38. }
  39. },
  40. {
  41. files: ['*.vue'],
  42. parser: 'vue-eslint-parser',
  43. parserOptions: {
  44. parser: '@typescript-eslint/parser',
  45. extraFileExtensions: ['.vue'],
  46. ecmaVersion: 2020,
  47. sourceType: 'module'
  48. }
  49. }
  50. ]
  51. }