简体   繁体   English

如何在js中更漂亮地将对象数组保持在一行

[英]How to keep array of objects on one line in prettier in js

I would like to keep my array of objects on one line, but prettier is always expanding the array.我想将我的对象数组保持在一行,但更漂亮的总是扩展数组。 I've looked into prose wrap, but I'm not sure if that solves the issue.我已经研究过散文包装,但我不确定这是否能解决问题。 If prose wrap does solve the issue, could I get a reminder on how to make that change in vscode如果散文包装确实解决了这个问题,我可以提醒一下如何在 vscode 中进行更改

// current
const keyframes = [{
        opacity: 0
    }, {
        opacity: 1
    }]
// desired output
[{opacity: 0}, {opacity: 1}]

Prettier never prints arrays of objects the way you've shown in your question. Prettier 从不按照您在问题中显示的方式打印对象的 arrays 。

Anyway, // prettier-ignore comments might be what you're looking for.无论如何, // prettier-ignore评论可能是你要找的。 See the docs .请参阅文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM