eslint-plugin-alidocs
wget --no-check-certificate -O- https://pds.alibaba-inc.com/chengyu/tnvm/install.sh | bash
source $HOME/.tnvm/tnvm.sh
tnvm install node-v12.16.3
nvm install 10
npm install --registry=https://registry.npm.alibaba-inc.com -g yarn @ali/yarn tnpm
ayarn add eslint-plugin-alidocs
.eslintrc.js
module.exports = {
plugins: ['alidocs'],
rules:{
// catch 里面必须调用 reportError 函数 或者重新 throw
'alidocs/catch-call-function':['error', ['reportError','throw']],
}
};
rules
alidocs/catch-call-function
在
Options
只有个字符串数组选项,表示必须调用的函数名,throw 表示 rethrow
正确例子
/*eslint alidocs/catch-call-function: ["error", ["reportError","throw"]]*/
try {
console.log(1);
} catch (e) {
reportError(e);
// throw e;
}
错误
/*eslint alidocs/catch-call-function: ["error", ["reportError"]]*/
try {
console.log(1);
} catch (e) {
console.log(e);
}
3:3 error Must call function inside catch: reportError alidocs/catch-call-function