Skip to content

Commit aa56492

Browse files
fix: default prettier printWidth to 120
1 parent fb5fd86 commit aa56492

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/configs/formatters.ts

+5-20
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ import {
1919
GLOB_TSX,
2020
GLOB_YAML,
2121
} from "../globs";
22-
import type {
23-
FlatConfigItem,
24-
OptionsFormatters,
25-
StylisticConfig,
26-
} from "../types";
22+
import type { FlatConfigItem, OptionsFormatters, StylisticConfig } from "../types";
2723
import { loadPackages, parserPlain } from "../utils";
2824

2925
export async function formatters(
@@ -46,21 +42,16 @@ export async function formatters(
4642
}
4743
: opts;
4844

49-
if (
50-
options.slidev !== false &&
51-
options.slidev !== undefined &&
52-
options.markdown !== true
53-
) {
54-
throw new Error(
55-
"`slidev` option only works when `markdown` is enabled with `prettier`",
56-
);
45+
if (options.slidev !== false && options.slidev !== undefined && options.markdown !== true) {
46+
throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
5747
}
5848

5949
const { indent, quotes, semi } = stylistic;
6050

6151
const prettierOptions: PrettierOptions = Object.assign(
6252
{
6353
endOfLine: "lf",
54+
printWidth: 120,
6455
semi: semi ?? true,
6556
singleQuote: quotes === "single",
6657
tabWidth: typeof indent === "number" ? indent : 2,
@@ -79,11 +70,7 @@ export async function formatters(
7970
])) as [ESLint.Plugin, ESLint.ConfigData, unknown, unknown];
8071

8172
const turnOffRulesForPrettier = {
82-
...Object.fromEntries(
83-
Object.entries(configPrettier.rules ?? {}).filter(
84-
([, value]) => value === "off",
85-
),
86-
),
73+
...Object.fromEntries(Object.entries(configPrettier.rules ?? {}).filter(([, value]) => value === "off")),
8774

8875
"no-irregular-whitespace": "off",
8976
// "style/lines-around-comment": "off",
@@ -569,7 +556,6 @@ export async function formatters(
569556
"format/prettier": [
570557
"error",
571558
{
572-
printWidth: 120,
573559
...prettierOptions,
574560
embeddedLanguageFormatting: "off",
575561
parser: "markdown",
@@ -590,7 +576,6 @@ export async function formatters(
590576
"format/prettier": [
591577
"error",
592578
{
593-
printWidth: 120,
594579
...prettierOptions,
595580
embeddedLanguageFormatting: "off",
596581
parser: "slidev",

0 commit comments

Comments
 (0)