.eslintrc.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * @Description:
  3. * @Author: zhuoda
  4. * @Date: 2021-11-05
  5. * @LastEditTime: 2022-07-05
  6. * @LastEditors: zhuoda
  7. */
  8. module.exports = {
  9. root: true, //此项是用来告诉eslint找当前配置文件不能往父级查找
  10. env: {
  11. browser: true,
  12. es2021: true,
  13. node: true,
  14. },
  15. parser: 'vue-eslint-parser', //使用vue-eslint-parser 来解析vue文件中的 template和script
  16. parserOptions: {
  17. ecmaVersion: 12, // 默认情况下,ESLint使用的是ECMAScript5语法,此处我们设置的选项是 es12
  18. sourceType: 'module', // 指定js导入的方式
  19. },
  20. extends: ['plugin:vue/vue3-essential', 'eslint:recommended', 'plugin:vue/base'],
  21. globals: {
  22. defineProps: 'readonly',
  23. defineEmits: 'readonly',
  24. defineExpose: 'readonly',
  25. withDefaults: 'readonly',
  26. },
  27. plugins: ['vue'],
  28. rules: {
  29. 'no-unused-vars': [
  30. 'error',
  31. // we are only using this rule to check for unused arguments since TS
  32. // catches unused variables but not args.
  33. { varsIgnorePattern: '.*', args: 'none' },
  34. ],
  35. 'space-before-function-paren': 'off',
  36. 'vue/attributes-order': 'off',
  37. 'vue/one-component-per-file': 'off',
  38. 'vue/html-closing-bracket-newline': 'off',
  39. 'vue/max-attributes-per-line': 'off',
  40. 'vue/multiline-html-element-content-newline': 'off',
  41. 'vue/singleline-html-element-content-newline': 'off',
  42. 'vue/attribute-hyphenation': 'off',
  43. 'vue/require-default-prop': 'off',
  44. 'vue/multi-word-component-names': [
  45. 'error',
  46. {
  47. ignores: ['index'], //需要忽略的组件名
  48. },
  49. ],
  50. 'vue/html-self-closing': [
  51. 'error',
  52. {
  53. html: {
  54. void: 'always',
  55. normal: 'never',
  56. component: 'always',
  57. },
  58. svg: 'always',
  59. math: 'always',
  60. },
  61. ],
  62. // Enable vue/script-setup-uses-vars rule
  63. 'vue/script-setup-uses-vars': 'error',
  64. },
  65. };