Hem*_*mal 2 eslint js-beautify visual-studio-code prettier
这是在做我的头!花了 2 个小时试图找出导致以下行为的原因并不断出现空白。
我正在迁移到 VSCode,我的 React JSX 组件会自动换行成多行。当一个组件有多个属性时,这很好(也很好),但会使一些文件非常长且非常不可读。
举个例子 - 定义反应路由器路由的文件。它们都很小,理想情况下,每行一个使您的应用程序的路由非常易读,而不是每 7 行左右定义每条路由。
VS Code 自动将文件格式化为的示例:
<Authenticated
path="/new"
component={NewCorrespondence}
{...this.props}
/>
<Authenticated
path="/inbox"
component={Inbox}
{...this.props}
/>
<Authenticated
path="/sent"
component={Sent}
{...this.props}
/>
Run Code Online (Sandbox Code Playgroud)
它应该是什么样子
<Authenticated path="/new" component={NewCorrespondence} {...this.props} />
<Authenticated path="/inbox" component={Inbox} {...this.props} />
<Authenticated path="/sent" component={Sent} {...this.props} />
Run Code Online (Sandbox Code Playgroud)
处理此问题的 VSCode 中的设置是什么?有没有办法将其配置为仅在长度超过 x 个字符时包装这些行?
好的,所以回答我自己的问题。这是漂亮包的printWidth设置。prettierrc 配置文件被忽略,但直接从 VSCode 设置宽度解决了这个问题。
所以这里的问题是我如何设置配置文件(不同的问题!)。
| 归档时间: |
|
| 查看次数: |
1213 次 |
| 最近记录: |