简体   繁体   English

React Prettier自动修复

[英]React Prettier auto fix

React JSX React JSX

<Hello><Hello/>

to

<Hello/>

How can I fix code with prettier when I save code on VS code? 将代码保存在VS代码中时,如何更漂亮地修复代码? Which setting should I edit? 我应该编辑哪个设置?

install eslint-plugin-react . 安装eslint-plugin-react For reference please check below link 供参考,请检查以下链接

https://github.com/yannickcr/eslint-plugin-react https://github.com/yannickcr/eslint-plugin-react

Hope this will help you. 希望这会帮助你。

If you are using the Prettier plugin in VS Code, do this: 如果您在VS Code中使用Prettier插件,请执行以下操作:

  • Open the user settings - CTRL + , 打开用户设置-CTRL +,
  • Search "Format on Save" and turn it on 搜索“保存时格式化”并将其打开

This will use the formatter, in this case prettier, to format your code whenever you save. 每当保存时,它将使用格式化程序(在这种情况下为更漂亮)来格式化代码。

This has nothing to do with Eslint plugin as other people are saying. 正如其他人所说,这与Eslint插件无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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