Skip to content

Commit a969726

Browse files
committed
feat: use a formatter (prettier) not a linter (eslint) on generated code
1 parent 18d35e5 commit a969726

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
],
2525
"dependencies": {
2626
"camelcase": "^7.0.0",
27-
"eslint": "^8.26.0",
2827
"json-schema-ref-parser": "^9.0.9",
28+
"prettier": "^2.7.1",
2929
"ts-morph": "^16.0.0",
3030
"type-fest": "^3.1.0",
3131
"word-wrap": "^1.2.3",

src/build.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { writeFile } from 'node:fs/promises';
12
import { join } from 'node:path';
2-
import { ESLint } from 'eslint';
33
import type { OpenAPIV3 } from 'openapi-types';
4+
import { format } from 'prettier';
45
import { IndentationText, Project, QuoteKind, ScriptTarget } from 'ts-morph';
56
import { processOpenApiDocument } from '../lib/process-document.js';
67

@@ -59,17 +60,12 @@ export async function build(
5960
await entryFile.save();
6061
await typesFile.save();
6162

62-
const eslint = new ESLint({
63-
cwd: process.cwd(),
64-
});
65-
66-
const results = await eslint
67-
.lintFiles([entryFile.getFilePath(), typesFile.getFilePath()])
68-
.catch((err) => {
69-
// eslint-disable-next-line no-console
70-
console.error(err);
71-
return [];
72-
});
73-
74-
await ESLint.outputFixes(results);
63+
await Promise.all(
64+
[entryFile, entryFile].map((file) =>
65+
writeFile(
66+
file.getFilePath(),
67+
format(entryFile.getText(), { parser: 'typescript' }),
68+
),
69+
),
70+
);
7571
}

0 commit comments

Comments
 (0)