我需要以Vs代码为项目中的单个文件(API URLS文件)禁用更漂亮。实际上,我需要将每个API及其URL放在同一行中,但是更漂亮地将它们分成两行。
之前
export const GET_SEARCH_TEACHERS = params => myexampleFunction_app_base(`teachers/search/${params.search}`);
之后
export const GET_SEARCH_TEACHERS = params =>
myexampleFunction_app_base(`teachers/search/${params.search}`);
答案 0 :(得分:7)
如果您希望存储库中的某个文件永远不会被漂亮的文件格式化,则可以将其添加到.prettierignore文件中:Disable Prettier for one file
答案 1 :(得分:2)
感谢 evolutionxbox ,到目前为止,找到了两个解决方案。 首先,我们可以在需要时使用一个程序包在特定页面中切换更漂亮的格式。
格式切换 https://marketplace.visualstudio.com/items?itemName=tombonnike.vscode-status-bar-format-toggle
秒 忽略更漂亮的代码
Prettier提供了一个逃生样式,以忽略代码块或阻止格式化整个文件。 忽略文件
要从格式中排除文件,请在项目根目录中的.prettierignore文件中添加条目,或设置--ignore-path CLI选项。 .prettierignore 使用gitignore语法。 JavaScript
JavaScript注释//更漂亮-忽略会从格式中排除抽象语法树中的下一个节点。
例如:
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
将转换为:
matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
JSX
<div>
{/* prettier-ignore */}
<span ugly format='' />
</div>