1.error Expected an assignment or function call and instead saw an expression no-unused-expressions
需要有一个声明或者函数的调用而不是单单看到一个表达式在这里插入代码片
2.‘xxx’ is assigned a value but never used no-unused-vars
2.1 ‘xxx’ is defined a value but never used no-unused-vars
分配了值但未被使用, 定义了未使用
一般注释处理
3.Unexpected mutation of “xxx” prop vue/no-mutating-props
vue2中单项数据流的概念,这是Vue官方防止从子组件意外变更父级组件的状态内容
解决:
props:{
flag: Boolean
}
data(){
selfFlag: this.flag
}
4.error Expected error to be handled handle-callback-err
异常没有处理,如catch,对error处理一下就🆗
5.error Unexpected use of comma operator no-sequences
符号不对,检查一下标点符号
6.error Expected an assignment or function call and inststead saw an expression no-unused-expressions
期望一个赋值或函数调用,却看到一个表达式未使用表达式
7.error Unexpected lexical declaration in case block no-case-declarations
该规则禁止词法声明 (let、const、function 和 class) 出现在 case或default 子句中。
原因是,词法声明在整个 switch 语句块中是可见的,
但是它只有在运行到它定义的 case 语句时,才会进行初始化操作。
为了保证词法声明语句只在当前 case 语句中有效,将你子句包裹在块中。
正确写法:
在switch前声明变量,或用var声明,或用{}将语句在case里包裹起来
const a = 0;
switch (foo) {
case 1: {
let x = 1;
break;
}
case 2: {
const y = 2;
break;
}
case 3: {
function f() {}
break;
}
case 4:
var z = 4;
break;
default: {
class C {}
}
}
8.error Expected the Promise rejection reason to be an Error prefer-promise-reject-errors
promise的reject中需要传入的是一个Error对象.
如:
reject(new Error('err'))
9.error Expected an assignment or function call and instead saw an
expression no-unused-expressions
期望是赋值或函数调用, 不能是一个表达式 ( 意思就是函数没有调用,要加括号=>"()" )
10.error Unexpected use of comma operator no-sequences
写错逗号了,比如将语句结束的";"
写成了"," // 此情况也会导致 第9点的出现
例子:
getTodo(params).then(({code, message, data}) => {
this.current++, // 本该是 ';'
......
}
this.loading = false;
});
430:10 error Expected an assignment or function call and instead saw an
expression no-unused-expressions
446:11 error Unexpected use of comma operator
no-sequences