.eslintrc.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: 185 }],
  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. 'vue/multi-word-component-names': 'off',
  49. // 标签自闭合相关设置
  50. 'vue/html-self-closing': [
  51. 'warn',
  52. {
  53. html: {
  54. void: 'always',
  55. normal: 'always',
  56. component: 'always',
  57. },
  58. },
  59. ],
  60. 'no-unused-vars': [0, {
  61. // function 参数未使用不检查
  62. 'args': 'none',
  63. }],
  64. 'vue/v-on-event-hyphenation': ['warn', 'always', {
  65. 'autofix': true,
  66. 'ignore': [],
  67. }],
  68. 'vue/no-unused-components': 'off',
  69. 'no-unused-vars': 'off',
  70. 'vue/no-parsing-error': [
  71. 2,
  72. {
  73. 'x-invalid-end-tag': false,
  74. },
  75. ],
  76. 'camelcase': [0,{
  77. 'properties': 'always',
  78. }],
  79. },
  80. 'globals': {
  81. 'document': true,
  82. 'localStorage': true,
  83. 'window': true,
  84. 'BootstrapDialog': true,
  85. 'moment': true,
  86. 'gantt': true,
  87. '__webpack_public_path__': true,
  88. 'Notify': true,
  89. 'Vue': true,
  90. 'Handsontable': true,
  91. },
  92. };