.eslintrc.cjs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // eslint配置,用于校验代码
  2. module.exports = {
  3. // env指定环境 支持的环境: browser node commonjs es6 es2016~es2022...
  4. // 环境很多,详情查看文档https://zh-hans.eslint.org/docs/latest/use/configure/language-options
  5. "env": {
  6. "browser": true,
  7. "es2021": true,
  8. "node": true,
  9. },
  10. // 使用插件配置
  11. "extends": [
  12. "eslint:recommended",
  13. "plugin:vue/vue3-essential",
  14. "plugin:@typescript-eslint/recommended"
  15. ],
  16. // "overrides": [
  17. // {
  18. // "env": {
  19. // "node": true
  20. // },
  21. // "files": [
  22. // ".eslintrc.{js,cjs}"
  23. // ],
  24. // "parserOptions": {
  25. // "sourceType": "script"
  26. // }
  27. // }
  28. // ],
  29. // 配置支持的js语言选项
  30. "parserOptions": {
  31. "ecmaVersion": "latest",
  32. "sourceType": "module",
  33. "parser": "@typescript-eslint/parser"
  34. },
  35. // eslint第三方插件配置
  36. "plugins": [
  37. "vue",
  38. "@typescript-eslint"
  39. ],
  40. // eslint规则配置,还有很多规则配置项,在官网查看 https://eslint.org/docs/latest/rules/
  41. "rules": {
  42. '@typescript-eslint/no-var-requires': 0, //解决报错:Require statement not part of import statement.
  43. 'vue/multi-word-component-names': 'off', //关闭组件命名规则校验
  44. // => 前后有空格
  45. "arrow-spacing": [
  46. 2,
  47. {
  48. before: true,
  49. after: true,
  50. },
  51. ],
  52. "block-spacing": [2, "always"],
  53. // 对象字面量项尾是否有逗号
  54. "comma-dangle": [2, "always-multiline"],
  55. }
  56. }