.eslintrc.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. module.exports = {
  2. env: {
  3. browser: true,
  4. es2021: true,
  5. node: true,
  6. },
  7. extends: [
  8. 'plugin:vue/vue3-recommended',
  9. 'eslint:recommended',
  10. 'plugin:vue/vue3-essential',
  11. 'plugin:@typescript-eslint/recommended',
  12. 'plugin:prettier/recommended',
  13. ],
  14. parser: 'vue-eslint-parser',
  15. parserOptions: {
  16. ecmaVersion: 'latest',
  17. parser: '@typescript-eslint/parser',
  18. sourceType: 'module',
  19. ecmaFeatures: {
  20. jsx: true,
  21. },
  22. },
  23. plugins: ['vue', '@typescript-eslint'],
  24. globals: {
  25. defineProps: 'readonly',
  26. defineEmits: 'readonly',
  27. },
  28. rules: {
  29. 'no-console': 'off', // 禁止调用console对象的方法。
  30. '@typescript-eslint/no-explicit-any': 'off', // 禁止使用 any 类型
  31. 'no-use-before-define': 'off',
  32. '@typescript-eslint/no-use-before-define': 'off',
  33. '@typescript-eslint/ban-ts-comment': 'off',
  34. '@typescript-eslint/no-empty-function': ['off'], // 关闭空函数警告
  35. '@typescript-eslint/no-inferrable-types': 'off', // 可以轻松推断的显式类型可能会增加不必要的冗长
  36. '@typescript-eslint/no-namespace': 'off', // 禁止使用自定义 TypeScript 模块和命名空间
  37. '@typescript-eslint/ban-types': 'off', // 禁止使用特定类型
  38. 'vue/multi-word-component-names': 'off', // 要求组件名称始终为 “-” 链接的单词
  39. 'vue/no-v-html': 'off', // 禁止使用 v-html
  40. 'no-undef': 'off',
  41. 'no-redeclare': 'off',
  42. 'no-self-assign': 'off',
  43. 'no-sparse-arrays': 'off',
  44. 'vue/valid-v-for': 'off',
  45. 'vue/no-unused-vars': 'off',
  46. 'vue/require-v-for-key': 'off',
  47. 'no-useless-escape': 'off',
  48. 'vue/require-explicit-emits': 'off',
  49. 'no-case-declarations': 'off', // 不允许在 case 子句中使用词法声明
  50. //禁止非空断言非空断言是在变量后面添加一个感叹号(!),表示该变量一定存在,不会为 null 或 undefined
  51. '@typescript-eslint/no-non-null-assertion': 'off',
  52. 'vue/require-prop-types': 'off',
  53. '@typescript-eslint/no-this-alias': 'off',
  54. 'no-async-promise-executor': 'off',
  55. 'vue/no-template-shadow': 'off',
  56. 'vue/require-default-prop': 'off', // 此规则要求为每个 prop 为必填时,必须提供默认值
  57. '@typescript-eslint/no-unused-vars': [
  58. // // 禁止定义未使用的变量
  59. 'off',
  60. {
  61. argsIgnorePattern: '^_',
  62. varsIgnorePattern: '^_',
  63. },
  64. ],
  65. // Prettier 格式规则
  66. 'prettier/prettier': [
  67. 'error',
  68. {
  69. tabWidth: 2,
  70. useTabs: false,
  71. singleQuote: true,
  72. semi: false,
  73. trailingComma: 'es5',
  74. bracketSpacing: true,
  75. endOfLine: 'auto',
  76. },
  77. ],
  78. },
  79. }