将更改保存到我的create-react-app
应用程序后,我收到此编译器警告:
Compiled with warnings.
./src/components/DurationPicker.js
Line 22: Expected an assignment or function call and instead saw an expression no-unused-expressions
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
有没有一种方法可以使React的警告“可单击”,以便我可以在终端 Pane 中单击警告,然后编辑器将导航到带有警告的文件中的行号? (顺便说一句,我知道我是说这些是“React的警告”,但实际上是ESLint生成的吗?)
老式的Visual Studio通过其“输出” Pane 中的编译器错误来执行此操作,这非常方便。我希望在VS Code中有类似的方法可以做到这一点。
还是在VS Code中已经有办法做到这一点,但是React(或ESLint?)没有以VS Code期望的格式发出其编译警告?
最佳答案
VSCode具有内置的机制来实现您要尝试执行的操作:Problem matchers。
另外,您可能想知道问题匹配器适用于通过VSCode任务系统定义和启动的任务。
但是,如果您只想缓存ESLint错误,则有一个扩展名:https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
关于reactjs - VSCode从终端 Pane 单击以转至React编译警告源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50458310/