Skip to content

Commit

Permalink
fix lint and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Oct 2, 2024
1 parent ea40933 commit ba50633
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/cli/api-importers/commons/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("../../../../../.prettierrc.json");
module.exports = require("../../../../.prettierrc.json");
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { RelativeFilePath } from "@fern-api/fs-utils";
import { TaskContext } from "@fern-api/task-context";

export declare namespace APIDefinitionImporter {

interface Return {
rootApiFile: RootApiFileSchema;
packageMarkerFile: PackageMarkerFileSchema;
Expand All @@ -12,9 +11,7 @@ export declare namespace APIDefinitionImporter {
}

export abstract class APIDefinitionImporter<T> {

public constructor (protected readonly context?: TaskContext) {}
public constructor(protected readonly context?: TaskContext) {}

public abstract import(input: T): Promise<APIDefinitionImporter.Return>;

}
}
42 changes: 30 additions & 12 deletions packages/cli/api-importers/commons/src/FernDefnitionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ export interface FernDefinitionBuilder {
* @param fileToImport the file to import
* @param alias import the file with this alias
*/
addImport({ file, fileToImport, alias }: { file: RelativeFilePath; fileToImport: RelativeFilePath; alias?: string; }): string | undefined;
addImport({
file,
fileToImport,
alias
}: {
file: RelativeFilePath;
fileToImport: RelativeFilePath;
alias?: string;
}): string | undefined;

addType(file: RelativeFilePath, { name, schema }: { name: string; schema: RawSchemas.TypeDeclarationSchema }): void;

Expand All @@ -58,7 +66,11 @@ export interface FernDefinitionBuilder {

addEndpoint(
file: RelativeFilePath,
{ name, schema, source }: { name: string; schema: RawSchemas.HttpEndpointSchema; source: RawSchemas.SourceSchema | undefined }
{
name,
schema,
source
}: { name: string; schema: RawSchemas.HttpEndpointSchema; source: RawSchemas.SourceSchema | undefined }
): void;

addWebhook(file: RelativeFilePath, { name, schema }: { name: string; schema: RawSchemas.WebhookSchema }): void;
Expand Down Expand Up @@ -102,8 +114,8 @@ export class FernDefinitionBuilderImpl implements FernDefinitionBuilder {
}
};
}
public setDisplayName({ displayName }: { displayName: string; }): void {

public setDisplayName({ displayName }: { displayName: string }): void {
this.rootApiFile["display-name"] = displayName;
}

Expand Down Expand Up @@ -222,7 +234,7 @@ export class FernDefinitionBuilderImpl implements FernDefinitionBuilder {
public addImport({
file,
fileToImport,
alias,
alias
}: {
file: RelativeFilePath;
fileToImport: RelativeFilePath;
Expand All @@ -231,12 +243,14 @@ export class FernDefinitionBuilderImpl implements FernDefinitionBuilder {
if (file === fileToImport) {
return undefined;
}
const importPrefix = alias ?? camelCase(
(dirname(fileToImport) + "/" + basename(fileToImport, extname(fileToImport))).replaceAll(
"__package__",
"root"
)
);
const importPrefix =
alias ??
camelCase(
(dirname(fileToImport) + "/" + basename(fileToImport, extname(fileToImport))).replaceAll(
"__package__",
"root"
)
);

if (file === RelativeFilePath.of(ROOT_API_FILENAME)) {
if (this.rootApiFile.imports == null) {
Expand Down Expand Up @@ -336,7 +350,11 @@ export class FernDefinitionBuilderImpl implements FernDefinitionBuilder {

public addEndpoint(
file: RelativeFilePath,
{ name, schema, source }: { name: string; schema: RawSchemas.HttpEndpointSchema; source: RawSchemas.SourceSchema | undefined }
{
name,
schema,
source
}: { name: string; schema: RawSchemas.HttpEndpointSchema; source: RawSchemas.SourceSchema | undefined }
): void {
const fernFile = this.getOrCreateFile(file);
if (fernFile.service == null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/api-importers/commons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { APIDefinitionImporter } from "./APIDefinitionImporter";
export { type FernDefinitionBuilder, FernDefinitionBuilderImpl, type FernDefinition } from "./FernDefnitionBuilder";
export { type FernDefinitionBuilder, FernDefinitionBuilderImpl, type FernDefinition } from "./FernDefnitionBuilder";
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe("ir", () => {
if (!workspace.didSucceed) {
throw new Error(`Failed to convert conjure fixture ${fixture.name}\n${JSON.stringify(workspace.failures)}`);
}
// eslint-disable-next-line jest/no-standalone-expect
expect(await workspace.workspace.toFernWorkspace({ context})).toMatchSnapshot();
},
90_000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function visitAllConjureDefinitionFiles(
absolutePathToConjureFolder: AbsoluteFilePath,
visitor: (filepath: RelativeFilePath, definitionFile: DefinitionFile) => void | Promise<void>
): Promise<void> {
for (const conjureFile of await listConjureFiles(absolutePathToConjureFolder, `{yml,yaml}`)) {
for (const conjureFile of await listConjureFiles(absolutePathToConjureFolder, "{yml,yaml}")) {
await visitor(conjureFile.relativeFilepath, conjureFile.fileContents);
}
}
Expand Down

0 comments on commit ba50633

Please sign in to comment.