.eslintrc.cjs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const autoImport = require('./.eslintrc-auto-import.json')
  2. module.exports = {
  3. env: {
  4. browser: true,
  5. es2021: true,
  6. node: true
  7. },
  8. extends: [
  9. 'eslint:recommended',
  10. 'plugin:vue/vue3-essential',
  11. // eslint-plugin-import 插件, @see https://www.npmjs.com/package/eslint-plugin-import
  12. 'plugin:import/recommended',
  13. // eslint-config-airbnb-base 插件 已经改用 eslint-config-standard 插件
  14. 'standard',
  15. // 1. 接入 prettier 的规则
  16. 'prettier',
  17. 'plugin:prettier/recommended'
  18. ],
  19. ignorePatterns: ['**/uni_modules/**', '**/node_modules/**', '**/dist/**'],
  20. overrides: [
  21. {
  22. env: {
  23. node: true
  24. },
  25. files: ['.eslintrc.{js,cjs}'],
  26. parserOptions: {
  27. sourceType: 'script'
  28. }
  29. }
  30. ],
  31. plugins: [
  32. 'vue',
  33. // 2. 加入 prettier 的 eslint 插件
  34. 'prettier'
  35. ],
  36. rules: {
  37. // 3. 注意要加上这一句,开启 prettier 自动修复的功能
  38. 'prettier/prettier': 'error',
  39. // turn on errors for missing imports
  40. 'import/no-unresolved': 'off',
  41. // 对后缀的检测,否则 import 一个ts文件也会报错,需要手动添加'.ts', 增加了下面的配置后就不用了
  42. 'import/extensions': 'off',
  43. // 只允许1个默认导出,关闭,否则不能随意export xxx
  44. 'import/prefer-default-export': ['off'],
  45. 'no-console': ['off'],
  46. // 'no-unused-vars': ['off'],
  47. // 解决vite.config.js报错问题
  48. 'import/no-extraneous-dependencies': 'off',
  49. 'no-plusplus': 'off',
  50. 'no-shadow': 'off',
  51. 'vue/multi-word-component-names': 'off',
  52. 'no-underscore-dangle': 'off',
  53. 'no-use-before-define': 'off',
  54. 'no-undef': 'off',
  55. 'no-debugger': 'off',
  56. 'no-unused-vars': 'off',
  57. 'no-param-reassign': 'off',
  58. 'no-new': 'off',
  59. 'vue/no-v-text-v-html-on-component': 'off',
  60. 'new-cap': 'off',
  61. 'import/no-named-as-default': 'off',
  62. 'import/no-absolute-path': 'off',
  63. 'no-case-declarations': 'off'
  64. },
  65. globals: {
  66. $t: true,
  67. uni: true,
  68. UniApp: true,
  69. wx: true,
  70. WechatMiniprogram: true,
  71. getCurrentPages: true,
  72. UniHelper: true,
  73. Page: true,
  74. App: true,
  75. NodeJS: true,
  76. ...autoImport.globals
  77. }
  78. }