[英]In VSCode, is it possible to apply eslinter formatting rules to just a block of code?
I was able to figure out how to apply eslinter formatting rules to an entire file. 我能够弄清楚如何将eslinter格式设置规则应用于整个文件。 However, I'd like to be able to apply it to just a part of the file (selected block of code).
但是,我希望能够将其仅应用于文件的一部分(选定的代码块)。
I currently have Atom configured to do this (using Beautify package with ESLint Fixer as the Default Beautifier for Javascript). 我目前已配置Atom来执行此操作(使用带有ESLint Fixer的Beautify包作为Javascript的默认Beautifier)。 This allows me to select a block of code and run Beautify on it.
这使我可以选择一个代码块并在其上运行Beautify。
I'd like to move over to VSCode but really need this functionality. 我想转到VSCode,但确实需要此功能。
I don't think there's a direct way to do it. 我认为没有直接的方法可以做到。 A workaround:
解决方法:
/* eslint-disable */
at the top of the file. /* eslint-disable */
放在文件顶部。 Then, before the block you want to lint, put /* eslint-enable */
and after the block /* eslint-disable */
. /* eslint-enable */
的块之前,将/* eslint-enable */
放在块/* eslint-disable */
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.