[英]Prettier with CSS settings in VS Code
I have the Prettier extension added to my VS Code editor.我在 VS Code 编辑器中添加了 Prettier 扩展。
When using Less or Sass, the default settings format code like this:使用 Less 或 Sass 时,默认设置格式代码如下:
// Default
.parent_selector {
.child_selector {
color: red;
}
}
// Desired Format
.parent_selector {
.child_selector {
color: red;
}
}
How could I tweak the Prettier CSS settings to achieve this?我如何调整 Prettier CSS 设置来实现这一点? I know it seems trivial, but in bigger code bases it helps readability.
我知道这看起来微不足道,但在更大的代码库中,它有助于提高可读性。
As an alternative method;作为替代方法; It can be achieved by using stylelint plugin and stylelint-config-standard rules.
可以通过使用stylelint插件和stylelint-config-standard规则来实现。
npm install --save-dev stylelint stylelint-config-standard
After installing them, proceed with ctrl+shift+p
on VS Code and run command: stylelint: fix all auto-fixable problems
.安装它们后,在 VS Code 上继续
ctrl+shift+p
并运行命令: stylelint: fix all auto-fixable problems
。
PS: Consider assigning a keyboard shortcut for stylelint: fix all auto-fixable problems
command for easy access. PS:考虑为
stylelint: fix all auto-fixable problems
分配键盘快捷键stylelint: fix all auto-fixable problems
命令,以便于访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.