如何在 vscode 上为 css 模块设置 prettier

问题描述 投票:0回答:2

Prettier 正在奇怪地格式化我的

module.css
文件。

预期:

.foo {
  @apply 
  border-2
  rounded
}

实际(第一个样式移至 apply 旁边,并在末尾添加 ;

.foo {
  @apply border-2
  rounded;
}

所有其他文件的格式均正确。

检测到该文件是CSS。

这是保存 module.css 文件后的 vscode 输出

["INFO" - 4:12:25 PM] Formatting file:///src/components/Card/Card.module.css
["INFO" - 4:12:25 PM] Using config file at '/.prettierrc'
["INFO" - 4:12:25 PM] Using ignore file (if present) at /.prettierignore
["INFO" - 4:12:25 PM] File Info:
{
  "ignored": false,
  "inferredParser": "css"
}
["INFO" - 4:12:25 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 4:12:25 PM] Prettier Options:
{
  "filepath": "/src/components/Card/Card.module.css",
  "parser": "css",
  "trailingComma": "none",
  "semi": false,
  "singleQuote": true,
  "arrowParens": "always",
  "printWidth": 120
}
["INFO" - 4:12:25 PM] Formatting completed in 0.01ms.
visual-studio-code prettier prettier-vscode
2个回答
3
投票

因与 OpenAI 合作而被删除。我的帐户很可能会被删除,这是我的意图。


0
投票

你不必在@apply中使用换行符,你可以像这样使用空格:

.foo {
      @apply border-2 rounded; // don`t use new line
}
© www.soinside.com 2019 - 2024. All rights reserved.