.eslintrc.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. module.exports = {
  2. // 如果想要在不同的目录中使用不同的 .eslintrc, 就需要在该目录中添加如下的配置项:
  3. // 告诉eslint找.eslintrc配置文件不能往父级查找
  4. // root: true,
  5. // 此项是用来提供插件的,插件名称省略了eslint-plugin-,下面这个配置是用来规范vue的
  6. // plugins: ['vue'],
  7. extends: [
  8. // add more generic rulesets here, such as:
  9. 'eslint:recommended', // eslint推荐规则预设
  10. 'plugin:vue/vue3-recommended', // eslint-plugin-vue推荐的适用于vue3的规则预设
  11. ],
  12. parser: 'vue-eslint-parser',
  13. // 自定义 parser
  14. parserOptions: {
  15. parser: '@babel/eslint-parser',
  16. sourceType: 'module',
  17. },
  18. env: {
  19. browser: true,
  20. node: true,
  21. es6: true,
  22. jquery: true,
  23. },
  24. rules: {
  25. // override/add rules settings here, such as:
  26. 'vue/no-unused-vars': 'error',
  27. // 此规则禁用不必要的分号。
  28. 'no-extra-semi': 'off',
  29. // 该规则强制使用一致的分号
  30. semi: ['error', 'always'],
  31. // 该规则强制使用一致的反勾号、双引号或单引号。
  32. quotes: ['error', 'single'],
  33. // 该规则旨在强制使用一致的缩进风格。默认是 4个空格。
  34. indent: ['error', 2],
  35. // 该规则旨在通过限制代码行的长度来提高代码的可读性和可维护性。
  36. // 一行的长度为行中的 Unicode 字符的数量。
  37. 'max-len': ['error', { code: 999 }],
  38. // 这个规则强制在对象和数组字面量中使用一致的拖尾逗号。
  39. // "always-multiline" 当最后一个元素或属性与闭括号 ] 或 } 在 不同的行时,要求使用拖尾逗号;当在 同一行时,禁止使用拖尾逗号。
  40. 'comma-dangle': ['error', 'always-multiline'],
  41. // 该规则强制箭头函数单个参数是否要使用圆括号括起来
  42. // "as-needed":在可以省略括号的地方强制不使用括号
  43. 'arrow-parens': ['error', 'as-needed'],
  44. // 此规则在单行元素的内容之前和之后强制换行。
  45. 'vue/singleline-html-element-content-newline': 'off',
  46. // 限制每行最多能写多少个属性
  47. 'vue/max-attributes-per-line': 'off',
  48. // 标签自闭合相关设置
  49. 'vue/html-self-closing': [
  50. 'warn',
  51. {
  52. html: {
  53. void: 'always',
  54. normal: 'always',
  55. component: 'always',
  56. },
  57. },
  58. ],
  59. 'no-unused-vars': [0, {
  60. // function 参数未使用不检查
  61. 'args': 'none',
  62. }],
  63. 'vue/v-on-event-hyphenation': ['warn', 'always', {
  64. 'autofix': true,
  65. 'ignore': [],
  66. }],
  67. },
  68. 'globals':{
  69. 'document': true,
  70. 'localStorage': true,
  71. 'window': true,
  72. 'BootstrapDialog': true,
  73. 'moment': true,
  74. 'echarts': true,
  75. 'layer': true,
  76. 'Handsontable': true,
  77. 'dd': true,
  78. 'plugin': true,
  79. 'wx':true,
  80. 'mui': true,
  81. 'Loading': true,
  82. "BarcodeDetector": true,
  83. "ZXING_SCANNER": false,
  84. "SOFT_INPUT": false,
  85. "SOUND_PLAY": false,
  86. },
  87. };