Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Migrate format tests to Scripts API #3133

Merged
merged 2 commits into from
May 6, 2023

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented May 6, 2023

Using the Scripts API, we have an easier way to execute formatting.

import { createFormatter } from '@volar/kit'; // 1.5.3
import { resolveConfig } from '@vue/language-service'; // 1.7 pre-release / 2.0

const volarConfigForVue = resolveConfig({ /* base setup from volar.config.js */});
const formatter = createFormatter(volarConfigForVue);
const result = await formatter.formatCode('<template>{{msg}}</template>', 'vue', { insertSpaces: false, tabSize: 4 });

console.log(result); // <template>{{ msg }}</template>

@johnsoncodehk johnsoncodehk merged commit b188686 into master May 6, 2023
@johnsoncodehk johnsoncodehk deleted the rules-api-for-format-tests branch May 6, 2023 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant