简体   繁体   中英

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. 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). This allows me to select a block of code and run Beautify on it.

I'd like to move over to VSCode but really need this functionality.

I don't think there's a direct way to do it. A workaround:

  • Put /* eslint-disable */ at the top of the file. Then, before the block you want to lint, put /* eslint-enable */ and after the block /* eslint-disable */ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM