.eslintrc.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. module.exports = {
  2. root: true,
  3. env: {
  4. es2021: true,
  5. node: true,
  6. es6: true,
  7. },
  8. globals: {
  9. process: true,
  10. require: true,
  11. module: true,
  12. AMap: true,
  13. qq: true,
  14. uni: true,
  15. uniApp: true
  16. },
  17. extends: ['plugin:vue/strongly-recommended', 'eslint:recommended'],
  18. parserOptions: {
  19. 'ecmaVersion': 2021,
  20. 'sourceType': 'module',
  21. },
  22. rules: {
  23. // "off"或者0 //关闭规则关闭
  24. // "warn"或者1 //在打开的规则作为警告(不影响退出代码)
  25. // "error"或者2 //把规则作为一个错误(退出代码触发时为1)
  26. 'vue/multi-word-component-names': 0,
  27. 'no-console': 0, //禁止使用console
  28. 'no-mixed-spaces-and-tabs': 0,
  29. 'vue/attribute-hyphenation': 0,
  30. 'no-catch-shadow': 2, //禁止catch子句参数与外部作用域变量同名
  31. 'no-const-assign': 2, //禁止修改const声明的变量
  32. 'no-constant-condition': 2, //禁止在条件中使用常量表达式 if(true) if(1)
  33. 'no-debugger': 0, //禁止使用debugger
  34. 'no-delete-var': 2, //不能对var声明的变量使用delete操作符
  35. 'no-dupe-keys': 2, //在创建对象字面量时不允许键重复 {a:1,a:1}
  36. 'no-dupe-args': 2, //函数参数不能重复
  37. 'no-duplicate-case': 2, //switch中的case标签不能重复
  38. 'no-else-return': 0, //如果if语句里面有return,后面不能跟else语句
  39. 'no-empty': 2, //块语句中的内容不能为空
  40. 'no-empty-character-class': 2, //正则表达式中的[]内容不能为空
  41. 'no-empty-label': 0, //禁止使用空label
  42. 'no-eq-null': 2, //禁止对null使用==或!=运算符
  43. 'no-extra-boolean-cast': 2, //禁止不必要的bool转换
  44. 'no-extra-parens': 2, //禁止非必要的括号
  45. 'no-func-assign': 2, //禁止重复的函数声明
  46. 'no-implicit-coercion': 2, //禁止隐式转换
  47. 'no-inline-comments': 0, //禁止行内备注
  48. 'no-irregular-whitespace': 2, //不能有不规则的空格
  49. 'no-lone-blocks': 2, //禁止不必要的嵌套块
  50. 'no-loop-func': 1, //禁止在循环中使用函数(如果没有引用外部变量不形成闭包就可以)
  51. 'linebreak-style': [0, 'windows'], //换行风格
  52. 'no-multi-spaces': 1, //不能用多余的空格
  53. 'no-multiple-empty-lines': [1, { max: 2 }], //空行最多不能超过2行
  54. 'no-negated-in-lhs': 2, //in 操作符的左边不能有!
  55. 'no-nested-ternary': 0, //禁止使用嵌套的三目运算
  56. 'no-new': 1, //禁止在使用new构造一个实例后不赋值
  57. 'no-new-func': 1, //禁止使用new Function
  58. 'no-new-object': 2, //禁止使用new Object()
  59. 'no-new-require': 2, //禁止使用new require
  60. 'no-new-wrappers': 2, //禁止使用new创建包装实例,new String new Boolean new Number
  61. 'no-obj-calls': 2, //不能调用内置的全局对象,比如Math() JSON()
  62. 'no-octal': 2, //禁止使用八进制数字
  63. 'no-octal-escape': 2, //禁止使用八进制转义序列
  64. 'no-param-reassign': 0, //禁止给参数重新赋值
  65. 'no-plusplus': 0, //禁止使用++,--
  66. 'no-process-env': 0, //禁止使用process.env
  67. 'no-process-exit': 0, //禁止使用process.exit()
  68. 'no-proto': 2, //禁止使用__proto__属性
  69. 'no-redeclare': 2, //禁止重复声明变量
  70. 'no-return-assign': 1, //return 语句中不能有赋值表达式
  71. 'no-script-url': 0, //禁止使用javascript:void(0)
  72. 'no-self-compare': 2, //不能比较自身
  73. 'no-sequences': 0, //禁止使用逗号运算符
  74. 'no-shadow': 0, //外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
  75. 'no-ternary': 0, //禁止使用三目运算符
  76. 'no-trailing-spaces': 1, //一行结束后面不要有空格
  77. // 允许js中使用未命明的对象
  78. 'no-undef': 0, //不能有未定义的变量
  79. 'no-undef-init': 2, //变量初始化时不能直接给它赋值为undefined
  80. 'no-undefined': 0, //不能使用undefined
  81. 'camelcase': 2, //强制驼峰法命名
  82. 'quotes': [1, 'single'], //引号类型 `` "" '
  83. // vue html的属性单行最多属性
  84. 'vue/max-attributes-per-line': ['error', {
  85. 'singleline': {
  86. 'max': 5 // 最大
  87. },
  88. 'multiline': {
  89. 'max': 1 // 最小
  90. }
  91. }],
  92. 'vue/no-v-model-argument': 0,
  93. 'vue/singleline-html-element-content-newline': 0,
  94. // 强制html标签闭合
  95. 'vue/html-self-closing': 0,
  96. // eslint提示:不允许向模板添加多个根节点
  97. 'vue/no-multiple-template-root': 0,
  98. 'no-unused-vars': 0,
  99. },
  100. };