Node.js ESLint:分析错误:意外的令牌instanceOf
在Node.JS项目中,我正在重构, 添加以下语句时,我遇到一个wierd lint错误:Node.js ESLint:分析错误:意外的令牌instanceOf,node.js,eslint,instanceof,Node.js,Eslint,Instanceof,在Node.JS项目中,我正在重构, 添加以下语句时,我遇到一个wierd lint错误: try { ... } catch (e) { if (e instanceOf MyCustomError) { ... } } 该项目使用的是eslint版本5.16.0,这是my.eslintrc.json: { "env": { "node": true, "commonjs": true, "es6": tr
try {
...
} catch (e) {
if (e instanceOf MyCustomError) {
...
}
}
该项目使用的是eslint版本5.16.0,这是my.eslintrc.json:
{
"env": {
"node": true,
"commonjs": true,
"es6": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["import"],
"rules": {
"max-len": 0,
"switch-colon-spacing": 0,
"no-tabs": 0,
"linebreak-style": 0,
"semi": 0,
"new-cap": 0,
"arrow-parens": 0,
"indent": 0,
"object-curly-spacing": 0,
"comma-dangle": 0,
"camelcase": 0,
"import/named": 2,
"import/namespace": 2,
"import/default": 2,
"import/export": 2,
"import/no-unresolved": 0
}
}
Can't find anything about that error in the internet.
Any help would be appreciated!
Thanks in advance
我发现了这个问题
这是一个输入错误:
instanceof
而不是instanceof
请使用问题的编辑链接添加其他信息。回答后按钮只能用于完整回答问题。-这是一个完整的答案@SurajKumar
{
"env": {
"node": true,
"commonjs": true,
"es6": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["import"],
"rules": {
"max-len": 0,
"switch-colon-spacing": 0,
"no-tabs": 0,
"linebreak-style": 0,
"semi": 0,
"new-cap": 0,
"arrow-parens": 0,
"indent": 0,
"object-curly-spacing": 0,
"comma-dangle": 0,
"camelcase": 0,
"import/named": 2,
"import/namespace": 2,
"import/default": 2,
"import/export": 2,
"import/no-unresolved": 0
}
}
Can't find anything about that error in the internet.
Any help would be appreciated!
Thanks in advance