有没有办法阻止更漂亮/更漂亮的现在将函数参数分解为新行 [英] Is there a way to stop prettier / prettier-now from breaking function arguments into new lines

查看:35
本文介绍了有没有办法阻止更漂亮/更漂亮的现在将函数参数分解为新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 prettier/prettier-now 格式化保存时,当一个函数环绕另一个函数时,它会换行,我想知道是否有阻止这种行为的方法?

When using prettier / prettier-now to format on save, when a function wraps around another function it breaks to a new line, I was wondering if there was a to stop this behavior?

例如:

所需的输出:

app.get('/campgrounds/:id', catchAsync(async (req, res) => {
    const campground = await Campground.findById(req.params.id);
    res.render('campgrounds/show', { campground });
}));

Prettier/Prettier-now 输出:

Prettier / Prettier-now output:

app.get(
    '/campgrounds/:id',
    catchAsync(async (req, res) => {
        const campground = await Campground.findById(req.params.id);
        res.render('campgrounds/show', { campground });
    })
);

推荐答案

您可以使用以下命令告诉 prettier 停止格式化代码块注释//更漂亮的忽略

You can tell prettier to stop formatting a block of code by using Comment // prettier-ignore

例如:

A(
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
)

// prettier-ignore
B(
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
)
will be transformed to:

A(1, 0, 0, 0, 1, 0, 0, 0, 1);
    
// prettier-ignore
B(
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
)

这篇关于有没有办法阻止更漂亮/更漂亮的现在将函数参数分解为新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆