[英]Make Intellij IDEA handle global JS variables defined in ESLint config
I define some global variables in my project's .eslintrc
, and this config file is detected correctly by ESLint when I run ESLint as a script. 我在项目的
.eslintrc
定义了一些全局变量,当我将ESLint作为脚本运行时,ESLint会正确检测到此配置文件。
Now, I would like to configure IntelliJ IDEA so that its JavaScript inspector notices that I have defined these global variables in .eslintrc
, and doesn't bother me with "Missing import statement" warnings for these variables. 现在,我想配置IntelliJ IDEA,以便它的JavaScript检查器注意到我已经在
.eslintrc
定义了这些全局变量,并且不会因为这些变量的“Missing import statement”警告而烦恼。
For example, both ReactDOM
and React
are global variables defined in my .eslintrc
, so I would like the warnings in this screenshot to disappear: 例如,
ReactDOM
和React
都是我的.eslintrc
定义的全局变量,所以我希望此屏幕截图中的警告消失:
FYI, the JavaScript language version selected in the project settings is "React JSX (JSX in ECMAScript 6)". 仅供参考,在项目设置中选择的JavaScript语言版本是“React JSX(ECMAScript 6中的JSX)”。
As far as I know, ESlint is configured correctly in the settings: 据我所知,ESlint在设置中配置正确:
What am I missing? 我错过了什么?
(I am using the currently latest version of IntelliJ IDEA: 2016.3.4) (我使用的是当前最新版本的IntelliJ IDEA:2016.3.4)
ESLint configuration doesn't affect IDEA own inspections; ESLint配置不会影响IDEA自己的检查; you need to suppress 'Missing Import statement' inspection using
Alt+Enter
, Right
, 'Suppress for statement'
; 你需要使用
Alt+Enter
, Right
, 'Suppress for statement'
来禁止'缺少导入语句'检查;
there is a feature request to respect env
and globals
from .eslintrc
- see https://youtrack.jetbrains.com/issue/WEB-21957 从
.eslintrc
有一个尊重env
和globals
的功能请求 - 请参阅https://youtrack.jetbrains.com/issue/WEB-21957
You can turn off the inspections by hand that generate the above message. 您可以手动关闭检查以生成上述消息。 The one you are looking for is found here:
您正在寻找的那个在这里找到:
If you use a well configured eslint and .editorconfig you arguably don't need IDEA's own inspections for Javascript at all. 如果您使用配置良好的eslint和.editorconfig,您可能根本不需要IDEA自己的Javascript检查。 I have it setup like this:
我有这样设置:
.idea
folder (it's hidden, found in the root of your project) .idea
文件夹(它隐藏,在项目的根目录中找到) Code quality tools
and ESlint
Code quality tools
和ESlint
editorconfig
and make sure you have the plugin active, together with an .editorconfig file . editorconfig
并确保将插件与.editorconfig文件一起激活。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.