VUE脚本标签中的更漂亮的破坏功能
我想将IF功能保留在一行中,而无需使用三元格式,但更漂亮的格式破坏了它,我在Prettier formitier文档中没有找到该选项
。 .vue 文件
想要的输出
<script>
export default {
methods: {
changeSlide(slideIndex) {
if (slideIndex >= this.slides.length) { slideIndex = 0 }
}
},
}
</script>
我的Prettier
<script>
export default {
methods: {
changeSlide(slideIndex) {
if (slideIndex >= this.slides.length) {
slideIndex = 0
}
}
},
}
</script>
我正在使用NUXT(VUEJS)
Config:
{
"semi": false,
"singleQuote": true,
"tabWidth": 4,
"useTabs": true,
"printWidth": 120
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是带有VSCODE扩展名或通过ESLINT的更漂亮的?我建议第二种方法顺便说一句,对于nice
linter
linter +formatter
combo 。这还将为您提供禁用权利
linting +格式 +格式 + formatting + formatting + formatting + formatting
代码,总体上更加灵活。如果您使用的是第一种方法,则可以尝试此范围忽略< /a>方法。
您可以使用
// prettier-ignore-ignore
忽略整个事情,但我怀疑您可以在之后启用它。如您在选项中,没有什么可以帮助那里的选项。但是,要漂亮的目的是被认为是可以自以为是的,因此合法的是,您没有Eslint可以带来的全部灵活性。有一些准则,例如一个“ nofollow Noreferrer”>以特定的写作方式。打败了更漂亮的目的:使用它,并停止一劳永逸地讨论每种拉动请求上的样式,因此为什么它具有自以为是,并且没有那么多可配置的选项。
一个简单的(但 meh hack)将是设置
“ printWidth”:200
,这可能以某种方式工作,但并不能真正灵活。TLDR:使用Eslint + Prettier组合(无VSCODE扩展)进行完全露面的柔性配置,或者让Prettier Do tos to and To Blitier Do The Condect的格式。
You're using Prettier with a VScode extension or via ESlint? I recommend the second approach btw, for a nice
linter
+formatter
combo.This will also give you the right to disable
linting + formatting
of a specific line or block of code, so quite more flexiible overall.If you're using the first approach, then you could maybe try this Range ignore approach.
You could use
// prettier-ignore
to ignore the whole thing but I doubt you can enable it back afterwards. As you saw in the options, there is nothing that can help there. But the purpose of Prettier is to be opinionated so it's legit that you don't have the whole flexibility that ESlint could bring to the table.There are some guidelines like the one from Airbnb, this is great but then you need your whole team to agree on a specific way of writing things. Which defeats the purpose of Prettier: use it and stop discussing the style on each Pull Request once and for all, hence why it's opinionated and have not that much configurable options.
A simple (yet meh hack) would be to set
"printWidth": 200
, this may somehow work but not really flexible.TLDR: use an ESlint + Prettier combo (without the VScode extension) for a fully fledged flexible configuration or let Prettier do it's opinionated formatting.