ESLint在括号中显示错误 [英] ESLint showing errors in Brackets
问题描述
我的JavaScript代码运行正常,除了ESLint显示我有错误,例如:
My javascript code is working perfectly except ESLint is showing that I have errors, such as:
错误: myFunction为[no-unused-vars]
"ERROR: 'myFunction' is defined but never used. [no-unused-vars]"
和
错误:未定义'文档'。[no-undef]
"ERROR: 'document' is not defined. [no-undef]"
只是一个问题,因为我使用的是外部js文件。我可以在 brackets.json或 defaultPreferences.json中添加什么以阻止这些ESLint错误标记/通知出现?
This is only a problem because I am using an external js file. What can I put into "brackets.json" or "defaultPreferences.json" to stop these ESLint error markers/notifications from appearing?
我们非常感谢您的帮助。
Any help is much appreciated.
推荐答案
我遇到了同样的问题:创建一个 package.json 文件作为项目的根目录,然后放入ESLint文档中定义的eslintConfig对象中的ESLint配置:
I had the same problem: create a package.json file a the root of your project and put you ESLint configuration in a eslintConfig object as defined in the ESLint documentation:
{
"eslintConfig": {
"globals": {
"Vue": true
},
"env": {
"browser": true,
"es6": true,
"jquery": true
},
"extends": [
"eslint:recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-console": 0,
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
]
}
}
}
良好的编码!
这篇关于ESLint在括号中显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!