eslint.config.mjs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // 引入vue模版的eslint
  2. import pluginVue from 'eslint-plugin-vue'
  3. import eslint from '@eslint/js'
  4. // ts-eslint解析器,使 eslint 可以解析 ts 语法
  5. import tseslint from 'typescript-eslint'
  6. // vue文件解析器
  7. import vueParser from 'vue-eslint-parser'
  8. import prettier from 'eslint-plugin-prettier'
  9. export default tseslint.config({
  10. // ignores: ['node_modules', 'prettier.config.cjs', 'dist*'],
  11. files: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.vue'],
  12. // tseslint.config添加了extends扁平函数,直接用。否则是eslint9.0版本是没有extends的
  13. extends: [
  14. eslint.configs.recommended,
  15. ...tseslint.configs.recommended,
  16. ...pluginVue.configs['flat/essential']
  17. ],
  18. plugins: {
  19. prettier
  20. },
  21. languageOptions: {
  22. parser: vueParser, // 使用vue解析器,这个可以识别vue文件
  23. parserOptions: {
  24. parser: tseslint.parser, // 在vue文件上使用ts解析器
  25. sourceType: 'module',
  26. ecmaVersion: 2020,
  27. ecmaFeatures: {
  28. jsx: true
  29. }
  30. }
  31. },
  32. rules: {
  33. 'prettier/prettier': 'error',
  34. 'no-useless-escape': 0,
  35. 'no-undef': 0,
  36. 'vue/no-setup-props-destructure': 0,
  37. 'vue/script-setup-uses-vars': 1,
  38. 'vue/no-reserved-component-names': 0,
  39. '@typescript-eslint/ban-ts-ignore': 0,
  40. '@typescript-eslint/explicit-function-return-type': 0,
  41. '@typescript-eslint/no-explicit-any': 0,
  42. '@typescript-eslint/no-var-requires': 0,
  43. '@typescript-eslint/no-empty-function': 0,
  44. 'vue/custom-event-name-casing': 0,
  45. 'no-use-before-define': 0,
  46. '@typescript-eslint/no-use-before-define': 0,
  47. '@typescript-eslint/ban-ts-comment': 0,
  48. '@typescript-eslint/ban-types': 0,
  49. '@typescript-eslint/no-non-null-assertion': 0,
  50. '@typescript-eslint/explicit-module-boundary-types': 0,
  51. '@typescript-eslint/no-unused-vars': 0,
  52. 'no-unused-vars': 0,
  53. 'space-before-function-paren': 0,
  54. 'vue/attributes-order': 0,
  55. 'vue/one-component-per-file': 0,
  56. 'vue/html-closing-bracket-newline': 0,
  57. 'vue/max-attributes-per-line': 0,
  58. 'vue/multiline-html-element-content-newline': 0,
  59. 'vue/singleline-html-element-content-newline': 0,
  60. 'vue/attribute-hyphenation': 0,
  61. 'vue/require-default-prop': 0,
  62. 'vue/require-explicit-emits': 0,
  63. 'vue/html-self-closing': [
  64. 1,
  65. {
  66. html: {
  67. void: 'always',
  68. normal: 'never',
  69. component: 'always'
  70. },
  71. svg: 'always',
  72. math: 'always'
  73. }
  74. ],
  75. 'vue/multi-word-component-names': 0,
  76. 'vue/no-v-html': 0,
  77. 'vue/require-toggle-inside-transition': 0
  78. }
  79. })