Skip to content

Commit efa04fa

Browse files
committed
fix: specify full path to the files for eslint
1 parent 5517803 commit efa04fa

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/cli/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ yargs(hideBin(process.argv))
6666
switch (generateConfig.type) {
6767
case 'openapiClient':
6868
const document = await loadOpenApiDocument(generateConfig.document);
69-
const files = await postprocessFiles(
70-
(
69+
const files = await postprocessFiles({
70+
files: (
7171
await openapiToTypescriptClient({
7272
document,
7373
generateConfig
7474
})
7575
).files,
76-
generateConfig.postprocess
77-
);
76+
config: generateConfig.postprocess,
77+
outputDirPath: generateConfig.outputDirPath
78+
});
7879
const allDirectories = new Set<string>();
7980
for (const {filename} of files) {
8081
allDirectories.add(path.dirname(path.resolve(generateConfig.outputDirPath, filename)));
@@ -109,15 +110,16 @@ yargs(hideBin(process.argv))
109110
case 'openapiClient':
110111
if (
111112
!(await compareGenerationResult({
112-
files: await postprocessFiles(
113-
(
113+
files: await postprocessFiles({
114+
files: (
114115
await openapiToTypescriptClient({
115116
document: await loadOpenApiDocument(generateConfig.document),
116117
generateConfig
117118
})
118119
).files,
119-
generateConfig.postprocess
120-
),
120+
config: generateConfig.postprocess,
121+
outputDirPath: generateConfig.outputDirPath
122+
}),
121123
outputDirPath: generateConfig.outputDirPath,
122124
cleanupDirectories: getCleanupDirectories(generateConfig)
123125
}))

src/utils/postprocess-files.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
import path from 'path';
12
import type {ESLint as ESLintClass} from 'eslint';
23
import {
34
ClientGenerationResultFile,
45
CommonOpenApiClientGeneratorConfigPostprocess
56
} from '../schema-to-typescript/config';
67

7-
export async function postprocessFiles(
8-
files: ClientGenerationResultFile[],
9-
{eslint: enableEslint}: CommonOpenApiClientGeneratorConfigPostprocess = {}
10-
): Promise<ClientGenerationResultFile[]> {
8+
export async function postprocessFiles({
9+
files,
10+
config: {eslint: enableEslint} = {},
11+
outputDirPath
12+
}: {
13+
files: ClientGenerationResultFile[];
14+
config?: CommonOpenApiClientGeneratorConfigPostprocess;
15+
outputDirPath: string;
16+
}): Promise<ClientGenerationResultFile[]> {
1117
if (enableEslint) {
1218
// This is an optional dependency, so we require it here to avoid loading it when it's not needed.
1319
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -18,7 +24,9 @@ export async function postprocessFiles(
1824

1925
return Promise.all(
2026
files.map(async (file) => {
21-
const [result] = await eslint.lintText(file.data, {filePath: file.filename});
27+
const [result] = await eslint.lintText(file.data, {
28+
filePath: path.resolve(outputDirPath, file.filename)
29+
});
2230
return {
2331
...file,
2432
data: result.output ?? file.data

0 commit comments

Comments
 (0)