Skip to content

Commit fe4daee

Browse files
committed
Use standalone format function from Prettier
1 parent 2b2aa85 commit fe4daee

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

.changeset/frank-stamps-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codama/renderers-js': patch
3+
---
4+
5+
Use standalone format function from Prettier and remove opinionated defaults

src/utils/formatCode.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import { joinPath, mapRenderMapContentAsync, RenderMap } from '@codama/renderers-core';
2-
import { format, Plugin, resolveConfig } from 'prettier';
2+
import { Plugin, resolveConfig } from 'prettier';
33
import * as estreePlugin from 'prettier/plugins/estree';
44
import * as typeScriptPlugin from 'prettier/plugins/typescript';
5+
import { format } from 'prettier/standalone';
56

67
import { Fragment } from './fragment';
78
import { RenderOptions } from './options';
89

910
export type PrettierOptions = Parameters<typeof format>[1];
1011

1112
const DEFAULT_PRETTIER_OPTIONS: PrettierOptions = {
12-
arrowParens: 'always',
1313
parser: 'typescript',
1414
plugins: [estreePlugin as Plugin<unknown>, typeScriptPlugin],
15-
printWidth: 80,
16-
semi: true,
17-
singleQuote: true,
18-
tabWidth: 2,
19-
trailingComma: 'es5',
20-
useTabs: false,
2115
};
2216

2317
export async function formatCode(

src/utils/packageJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { CODAMA_ERROR__RENDERERS__MISSING_DEPENDENCY_VERSIONS, CodamaError, logW
22
import { fileExists, joinPath, readJson, RenderMap, writeFile } from '@codama/renderers-core';
33
import { lt as ltVersion, minVersion, subset } from 'semver';
44

5-
import { RenderOptions } from '.';
65
import { Fragment, mergeFragments } from './fragment';
76
import { getExternalDependencies } from './importMap';
7+
import { RenderOptions } from './options';
88

99
type DependencyVersions = Record<string, string>;
1010

0 commit comments

Comments
 (0)