javascript - 有没有办法阻止 prettier / prettier-now 将函数参数分解为新行
问题描述
当使用 prettier / prettier-now 在保存时格式化时,当一个函数环绕另一个函数时,它会换行,我想知道是否有一个停止这种行为?
例如:
期望的输出:
app.get('/campgrounds/:id', catchAsync(async (req, res) => {
const campground = await Campground.findById(req.params.id);
res.render('campgrounds/show', { campground });
}));
Prettier / Prettier-now 输出:
app.get(
'/campgrounds/:id',
catchAsync(async (req, res) => {
const campground = await Campground.findById(req.params.id);
res.render('campgrounds/show', { campground });
})
);
解决方案
您可以使用 Comment // prettier-ignore 告诉 prettier 停止格式化代码块
例如:
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
)
推荐阅读
- mysql - MySql:如果我将 binlog 格式设置为 row,dose change buffer 仍然有效吗?
- fortran - 将数据存储在一维数组中
- jquery - “node_modules”文件夹的用途是什么?
- c++ - C++ 项目的 MakeFile
- python-3.x - 我怎样才能退回新的雪花?
- javascript - K6 负载测试 - 如何为整个测试运行创建顺序 ID
- angular - Angular 货币代码不适用于旧 Angular 版本
- python - python的正则化超几何函数1f2?
- angular - 在生产循环内时,角度 [隐藏] 不起作用
- graphql - 在 Apollo 客户端中突变后删除缓存