[英]Is there a way to stop prettier / prettier-now from breaking function arguments into new lines
當使用 prettier / prettier-now 在保存時格式化時,當 function 環繞另一個 function 時它會換行,我想知道是否有辦法阻止這種行為?
例如:
所需的 output:
app.get('/campgrounds/:id', catchAsync(async (req, res) => {
const campground = await Campground.findById(req.params.id);
res.render('campgrounds/show', { campground });
}));
更漂亮/更漂亮-現在 output:
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
)
當使用 prettier / prettier-now 格式化保存時,當 function 環繞另一個 function 時,它會換行,我想知道是否有停止這種行為?
例如:
所需的 output:
app.get('/campgrounds/:id', catchAsync(async (req, res) => {
const campground = await Campground.findById(req.params.id);
res.render('campgrounds/show', { campground });
}));
更漂亮/更漂亮 - 現在 output:
app.get(
'/campgrounds/:id',
catchAsync(async (req, res) => {
const campground = await Campground.findById(req.params.id);
res.render('campgrounds/show', { campground });
})
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.