首页 文章

如何更改.less文件上更漂亮的行为?

提问于
浏览
0

我在我的Typescript项目中使用Visual Studio Code和prettier . 它还格式化less文件 .

What prettier does is putting every selector on a single line..

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4... {
    margin: 0;
    padding: 0;
}

Ends up as a very loooooooooooooong chain of selectors:

body,
div,
dl,
dt,
...
{
    margin: 0;
    padding: 0;
}

What I would like Prettier is, to just leave me alone (on this specific aspect. in .less files.) Keep them in a line (or several) if I wanted to. Or on multiple, if that is, what he finds:

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4... {
    margin: 0;
    padding: 0;
}

ul,
ol {
    list-style: none;
}

Btw: 我可以“证明”,通过在这些选择器之前放置一条 // prettier-ignore 线,只有更漂亮的手,而不是vscode或我的tslint中的任何内置东西 . 这也是一个本地解决方案,但我想要一个更通用的解决方案......而不必在所有这些方面抛出反linter评论......)

更新:

也许解决方案是在将 .less 文件指向不同的解析器附近 . 但是我找不到单一的示例代码,如何告诉我更漂亮的postcss-Preferences然后......

{
    "singleQuote": true,
    "printWidth": 140,
    "overrides": [{
        "files": "*.less",
        "options": {
            "parser": "postcss"
        }
    }]
}

1 回答

相关问题