diff --git a/docs/src/pages/reference/configuration/output.md b/docs/src/pages/reference/configuration/output.md index c4fa4a14e..a078d4b37 100644 --- a/docs/src/pages/reference/configuration/output.md +++ b/docs/src/pages/reference/configuration/output.md @@ -389,6 +389,16 @@ Default Value: `false`. Can be used to specify `tslint` ([TSLint is deprecated in favour of eslint + plugins](https://github.com/palantir/tslint#tslint)) as typescript linter instead of `eslint`. You need to have tslint in your dependencies. +### biome + +Type: `Boolean`. + +Default Value: `false`. + +You can apply `lint` and `format` of [`biome`](https://biomejs.dev/) to the generated file. You need to have `@biomejs/biome` in your dependencies. + +The automatically generated source code does not comply with some lint rules included in the default ruleset for `biome`, so please control them in the your `biome` configuration file. + ### headers Type: `Boolean`. diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 543285266..3e2f72f76 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -51,6 +51,7 @@ export type NormalizedOutputOptions = { clean: boolean | string[]; prettier: boolean; tslint: boolean; + biome: boolean; tsconfig?: Tsconfig; packageJson?: PackageJson; headers: boolean; @@ -171,6 +172,7 @@ export type OutputOptions = { clean?: boolean | string[]; prettier?: boolean; tslint?: boolean; + biome?: boolean; tsconfig?: string | Tsconfig; packageJson?: string; headers?: boolean; @@ -527,6 +529,7 @@ export interface GlobalOptions { clean?: boolean | string[]; prettier?: boolean; tslint?: boolean; + biome?: boolean; mock?: boolean | GlobalMockOptions; client?: OutputClient; mode?: OutputMode; diff --git a/packages/orval/src/bin/orval.ts b/packages/orval/src/bin/orval.ts index d4ac9fab1..35100c765 100644 --- a/packages/orval/src/bin/orval.ts +++ b/packages/orval/src/bin/orval.ts @@ -38,6 +38,7 @@ cli .option('--clean [path]', 'Clean output directory') .option('--prettier [path]', 'Prettier generated files') .option('--tslint [path]', 'tslint generated files') + .option('--biome [path]', 'biome generated files') .option('--tsconfig [path]', 'path to your tsconfig file') .action(async (paths, cmd) => { if (!cmd.config && isString(cmd.input) && isString(cmd.output)) { @@ -48,6 +49,7 @@ cli clean: cmd.clean, prettier: cmd.prettier, tslint: cmd.tslint, + biome: cmd.biome, mock: cmd.mock, client: cmd.client, mode: cmd.mode, @@ -81,6 +83,7 @@ cli clean: cmd.clean, prettier: cmd.prettier, tslint: cmd.tslint, + biome: cmd.biome, mock: cmd.mock, client: cmd.client, mode: cmd.mode, diff --git a/packages/orval/src/utils/options.ts b/packages/orval/src/utils/options.ts index b89a89ccb..81e5f5287 100644 --- a/packages/orval/src/utils/options.ts +++ b/packages/orval/src/utils/options.ts @@ -78,7 +78,7 @@ export const normalizeOptions = async ( workspace, ); - const { clean, prettier, client, mode, tslint } = globalOptions; + const { clean, prettier, client, mode, tslint, biome } = globalOptions; const tsconfig = await loadTsconfig( outputOptions.tsconfig || globalOptions.tsconfig, @@ -136,6 +136,7 @@ export const normalizeOptions = async ( clean: outputOptions.clean ?? clean ?? false, prettier: outputOptions.prettier ?? prettier ?? false, tslint: outputOptions.tslint ?? tslint ?? false, + biome: outputOptions.biome ?? biome ?? false, tsconfig, packageJson, headers: outputOptions.headers ?? false, diff --git a/packages/orval/src/write-specs.ts b/packages/orval/src/write-specs.ts index addd2fa29..a5c78e099 100644 --- a/packages/orval/src/write-specs.ts +++ b/packages/orval/src/write-specs.ts @@ -180,6 +180,19 @@ export const writeSpecs = async ( } } + if (output.biome) { + try { + await execa('biome', ['check', '--apply', ...paths]); + } catch (e: any) { + const message = + e.exitCode === 1 + ? e.stdout + e.stderr + : `⚠️ ${projectTitle ? `${projectTitle} - ` : ''}biome not found`; + + log(chalk.yellow(message)); + } + } + createSuccessMessage(projectTitle); };