Skip to content

Commit c5206e2

Browse files
authored
(fix) remove options from svelteSortOrder if needed
If user uses prettier-plugin-svelte 1.x, then remove `options` from the sort order or else it will throw a config error (`options` was not present back then).
1 parent f0d8110 commit c5206e2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/language-server/src/plugins/svelte/SveltePlugin.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ export class SveltePlugin
8585
}) ||
8686
{}
8787
);
88+
// If user has prettier-plugin-svelte 1.x, then remove `options` from the sort
89+
// order or else it will throw a config error (`options` was not present back then).
90+
if (
91+
config?.svelteSortOrder &&
92+
getPackageInfo('prettier-plugin-svelte', filePath)?.version.major < 2
93+
) {
94+
config.svelteSortOrder = config.svelteSortOrder
95+
.replace('-options', '')
96+
.replace('options-', '');
97+
}
8898
// Take .prettierignore into account
8999
const fileInfo = await prettier.getFileInfo(filePath, {
90100
ignorePath: this.configManager.getPrettierConfig()?.ignorePath ?? '.prettierignore',

0 commit comments

Comments
 (0)