Reputation: 1059
I have written a single line of code.
And after save prettier reformat the line into 2.
How to stop prettier from breaking lines into two?
Upvotes: 5
Views: 6993
Reputation: 29
you can skip formatting of single line using // prettier-ignore
if (diceGenerator !== 1) {
currentScore0El = Number(currentScore0El.textContent) + diceGenerator; // prettier-ignore
currentScore += diceGenerator;
}
or single code block (the code that before ;
)
export const FilterPersonZ: z.ZodType<_> = _FilterPersonZ
.extend({
pets: z.lazy(() => z.union([FilterPetZ.optional(), FilterPetZ.array()])),
job: z.lazy(() => z.union([FilterJobZ.optional(), FilterJobZ.array()])),
})
.transform(
s =>
({
id: s.id,
fullName: transform(s.fullName, ILike(`${s.fullName}%`)),
birthDate: s.birthDate,
pets: s.pets,
job: s.job,
} satisfies {[K in keyof Required<typeof s>]: (typeof s)[K]}),
);
export const FilterPersonZ: z.ZodType<_> = _FilterPersonZ
.extend({pets: z.lazy(() => z.union([FilterPetZ.optional(), FilterPetZ.array()])), job: z.lazy(() => z.union([FilterJobZ.optional(), FilterJobZ.array()]))})
.transform(s => ({
id: s.id,
fullName: transform(s.fullName, ILike(`${s.fullName}%`)),
birthDate: s.birthDate,
pets: s.pets,
job: s.job,
} satisfies {[K in keyof Required<typeof s>]: (typeof s)[K]})); // prettier-ignore
or
// prettier-ignore
export const FilterPersonZ: z.ZodType<_> = _FilterPersonZ
.extend({pets: z.lazy(() => z.union([FilterPetZ.optional(), FilterPetZ.array()])), job: z.lazy(() => z.union([FilterJobZ.optional(), FilterJobZ.array()]))})
.transform(s => ({
id: s.id,
fullName: transform(s.fullName, ILike(`${s.fullName}%`)),
birthDate: s.birthDate,
pets: s.pets,
job: s.job,
} satisfies {[K in keyof Required<typeof s>]: (typeof s)[K]}));
Upvotes: 0
Reputation: 1627
Add your prettier config in package.json so I did that and it works.
"prettier": {
"printWidth": 200
}
Upvotes: 1
Reputation: 4419
You need to increase the printWidth
in your .prettierrc
file:
The number is the number of characters before a wrap will be attempted, to stop lines from being wrapped at all set a high number like 1000
.
.prettierrc
{
"printWidth": 1000
}
From the prettier documentation
Print Width:
Specify the line length that the printer will wrap on.
Upvotes: 8