Two of the most prominent utilities in web development today are ESLint and Microsoft's Visual Studio Code. I enjoy using both, and I love the integration between both tools, but warnings from ESLint inside Visual Studio Code aren't fulfilling -- I'd rather lint errors be fixed each time I save.
当今Web开发中最著名的两个实用程序是ESLint和Microsoft的Visual Studio Code。 我喜欢同时使用这两种工具,而且我喜欢这两种工具之间的集成,但是Visual Studio Code中来自ESLint的警告并没有实现-我宁愿每次保存时都修正lint错误。
Complete the following steps to make Visual Studio Code fix any lint errors when a file is saved:
完成以下步骤以使Visual Studio Code在保存文件时修复所有棉绒错误:
Open the following file path:
~/Library/Application Support/Code/User/settings.json
打开以下文件路径:
~/Library/Application Support/Code/User/settings.json
- Within the JSON structure, add the following: 在JSON结构中,添加以下内容:
{ // ... Existing JSON here ... "editor.codeActionsOnSave": { "source.fixAll": true }}
Every time you save applicable files within Visual Studio Code, ESLint will be run to fix any errors.
每次在Visual Studio Code中保存适用的文件时,将运行ESLint修复任何错误。
For me this is a massive time savings. There is some risk that this task might take a while one large files but for me it's worth it.
对我来说,这可节省大量时间。 这项任务可能需要花费一个大文件一段时间,但是对我来说这是值得的。
翻译自: