fix(core): support prettier v3 when run nx format (#19207)
This commit is contained in:
parent
c05337481b
commit
b51bd04746
@ -12,6 +12,7 @@ import { calculateFileChanges, FileData } from '../../project-graph/file-utils';
|
|||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
|
|
||||||
import * as prettier from 'prettier';
|
import * as prettier from 'prettier';
|
||||||
|
import type { SupportInfo } from 'prettier';
|
||||||
import { sortObjectByKeys } from '../../utils/object-sort';
|
import { sortObjectByKeys } from '../../utils/object-sort';
|
||||||
import { readModulePackageJson } from '../../utils/package-json';
|
import { readModulePackageJson } from '../../utils/package-json';
|
||||||
import {
|
import {
|
||||||
@ -81,9 +82,11 @@ async function getPatterns(
|
|||||||
|
|
||||||
const p = parseFiles(args);
|
const p = parseFiles(args);
|
||||||
|
|
||||||
const supportedExtensions = prettier
|
// In prettier v3 the getSupportInfo result is a promise
|
||||||
.getSupportInfo()
|
const supportedExtensions = (
|
||||||
.languages.flatMap((language) => language.extensions)
|
await (prettier.getSupportInfo() as Promise<SupportInfo> | SupportInfo)
|
||||||
|
).languages
|
||||||
|
.flatMap((language) => language.extensions)
|
||||||
.filter((extension) => !!extension)
|
.filter((extension) => !!extension)
|
||||||
// Prettier supports ".swcrc" as a file instead of an extension
|
// Prettier supports ".swcrc" as a file instead of an extension
|
||||||
// So we add ".swcrc" as a supported extension manually
|
// So we add ".swcrc" as a supported extension manually
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user