/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
adev/shared-docs/pipeline/api-gen/rendering/transforms/format-code.mts
24 строки
783 B
Matthieu Riegler
docs(docs-infra): Improve formatting of functions (#61154)
16 май 2025, 16:58
16 май 2025, 16:58
ca700e1
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import parserTypescript from 'prettier/plugins/typescript'; import prettierPluginEstree from 'prettier/plugins/estree'; import prettier from 'prettier/standalone'; export async function formatJs(code: string): Promise<string> { return ( prettier .format(code, { parser: 'typescript', plugins: [parserTypescript, prettierPluginEstree], singleQuote: true, }) // Make sure to trim the formatted code as shiki will add a new line if there are some remaining trailing spaces .then((formattedCode) => formattedCode.trim()) ); }