Skip to content

Commit

Permalink
chore(internal): Upgrade Prettier & replace import sort (#5526)
Browse files Browse the repository at this point in the history
Upgrade Prettier & replace import sort
  • Loading branch information
Swimburger authored Jan 5, 2025
1 parent a0d9c7d commit 73a374e
Show file tree
Hide file tree
Showing 1,582 changed files with 5,642 additions and 3,793 deletions.
6 changes: 5 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
"tabWidth": 2
}
}
]
],
"importOrder": ["^@fern-api(.*)$", "^@fern-fern(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
5 changes: 2 additions & 3 deletions generators/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"lint:eslint:fix": "yarn lint:eslint --fix",
"format": "prettier --write --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"",
"format:check": "prettier --check --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"",
"organize-imports": "organize-imports-cli tsconfig.json",
"depcheck": "depcheck"
},
"dependencies": {
Expand All @@ -45,8 +44,8 @@
"depcheck": "^1.4.7",
"eslint": "^9.16.0",
"vitest": "^2.1.8",
"organize-imports-cli": "^0.10.0",
"prettier": "^2.7.1",
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
"prettier": "^3.4.2",
"typescript": "5.7.2"
}
}
11 changes: 7 additions & 4 deletions generators/base/src/AbstractGeneratorAgent.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Logger } from "@fern-api/logger";
import { AbstractGeneratorContext, FernGeneratorExec } from "@fern-api/browser-compatible-base-generator";
import { GeneratorAgentClient } from "./GeneratorAgentClient";
import { FernGeneratorCli } from "@fern-fern/generator-cli-sdk";
import { readFile } from "fs/promises";
import yaml from "js-yaml";
import path from "path";

import { AbstractGeneratorContext, FernGeneratorExec } from "@fern-api/browser-compatible-base-generator";
import { Logger } from "@fern-api/logger";

import { FernGeneratorCli } from "@fern-fern/generator-cli-sdk";

import { GeneratorAgentClient } from "./GeneratorAgentClient";
import { ReferenceConfigBuilder } from "./reference";

const DOCKER_FEATURES_CONFIG_PATH = "/assets/features.yml";
Expand Down
3 changes: 2 additions & 1 deletion generators/base/src/AbstractGeneratorCli.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* eslint-disable no-console */
import { assertNever } from "@fern-api/core-utils";
import { readFile } from "fs/promises";

import {
AbstractGeneratorContext,
FernGeneratorExec,
GeneratorExecParsing,
GeneratorNotificationService
} from "@fern-api/browser-compatible-base-generator";
import { assertNever } from "@fern-api/core-utils";

export abstract class AbstractGeneratorCli<
CustomConfig,
Expand Down
7 changes: 4 additions & 3 deletions generators/base/src/GeneratorAgentClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { AbsoluteFilePath } from "@fern-api/fs-utils";
import { Logger } from "@fern-api/logger";
import { createLoggingExecutable, LoggingExecutable } from "@fern-api/logging-execa";
import { writeFile } from "fs/promises";
import tmp from "tmp-promise";

import { AbsoluteFilePath } from "@fern-api/fs-utils";
import { Logger } from "@fern-api/logger";
import { LoggingExecutable, createLoggingExecutable } from "@fern-api/logging-execa";

const GENERATOR_AGENT_NPM_PACKAGE = "@fern-api/generator-cli";

export class GeneratorAgentClient {
Expand Down
5 changes: 3 additions & 2 deletions generators/base/src/SourceFetcher.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AbsoluteFilePath, join, relative, RelativeFilePath } from "@fern-api/fs-utils";
import { loggingExeca } from "@fern-api/logging-execa";
import { createWriteStream } from "fs";
import { mkdir, readdir } from "fs/promises";
import { pipeline } from "stream";
import { promisify } from "util";

import { AbstractGeneratorContext } from "@fern-api/browser-compatible-base-generator";
import { AbsoluteFilePath, RelativeFilePath, join, relative } from "@fern-api/fs-utils";
import { loggingExeca } from "@fern-api/logging-execa";

const LOCAL_FILE_SCHEME = "file:///";
const PROTOBUF_ZIP_FILENAME = "proto.zip";
Expand Down
4 changes: 3 additions & 1 deletion generators/base/src/__test__/SourceFetcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { AbsoluteFilePath, getDirectoryContents, getDirectoryContentsForSnapshot } from "@fern-api/fs-utils";
import path from "path";

import { AbstractGeneratorContext } from "@fern-api/browser-compatible-base-generator";
import { AbsoluteFilePath, getDirectoryContents, getDirectoryContentsForSnapshot } from "@fern-api/fs-utils";

import { SourceFetcher } from "../SourceFetcher";

const AWS_BUCKET_NAME = "fdr-api-definition-source-test";
Expand Down
1 change: 1 addition & 0 deletions generators/base/src/project/AbstractProject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AbstractGeneratorContext } from "@fern-api/browser-compatible-base-generator";
import { AbsoluteFilePath } from "@fern-api/fs-utils";

import { File } from "./File";

export abstract class AbstractProject<GeneratorContext extends AbstractGeneratorContext> {
Expand Down
3 changes: 2 additions & 1 deletion generators/base/src/project/File.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AbsoluteFilePath, join, RelativeFilePath } from "@fern-api/fs-utils";
import { mkdir, writeFile } from "fs/promises";
import path from "path";

import { AbsoluteFilePath, RelativeFilePath, join } from "@fern-api/fs-utils";

export class File {
public filename: string;
public directory: RelativeFilePath;
Expand Down
3 changes: 2 additions & 1 deletion generators/base/src/readme/AbstractReadmeSnippetBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FernGeneratorExec } from "@fern-api/browser-compatible-base-generator";
import { camelCase } from "lodash-es";

import { FernGeneratorExec } from "@fern-api/browser-compatible-base-generator";

export abstract class AbstractReadmeSnippetBuilder {
private endpointSnippets: FernGeneratorExec.Endpoint[];

Expand Down
3 changes: 2 additions & 1 deletion generators/base/src/utils/parseGeneratorConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FernGeneratorExec, GeneratorExecParsing } from "@fern-api/browser-compatible-base-generator";
import { readFile } from "fs/promises";

import { FernGeneratorExec, GeneratorExecParsing } from "@fern-api/browser-compatible-base-generator";

export async function parseGeneratorConfig(pathToConfig: string): Promise<FernGeneratorExec.GeneratorConfig> {
const configStr = await readFile(pathToConfig);
// eslint-disable-next-line no-console
Expand Down
5 changes: 2 additions & 3 deletions generators/browser-compatible-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"lint:eslint:fix": "yarn lint:eslint --fix",
"format": "prettier --write --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"",
"format:check": "prettier --check --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"",
"organize-imports": "organize-imports-cli tsconfig.json",
"depcheck": "depcheck"
},
"dependencies": {
Expand All @@ -38,8 +37,8 @@
"depcheck": "^1.4.7",
"eslint": "^9.16.0",
"vitest": "^2.1.8",
"organize-imports-cli": "^0.10.0",
"prettier": "^2.7.1",
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
"prettier": "^3.4.2",
"typescript": "5.7.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CONSOLE_LOGGER, createLogger, Logger, LogLevel } from "@fern-api/logger";
import { CONSOLE_LOGGER, LogLevel, Logger, createLogger } from "@fern-api/logger";

import { FernGeneratorExec, GeneratorNotificationService } from "./GeneratorNotificationService";
import { getSdkVersion } from "./utils";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { assertNever } from "@fern-api/core-utils";
import { FernGeneratorExec } from "../GeneratorNotificationService";
import { FernIr } from "@fern-api/dynamic-ir-sdk";
import { HttpEndpointReferenceParser } from "@fern-api/fern-definition-schema";
import { TypeInstance } from "./TypeInstance";

import { FernGeneratorExec } from "../GeneratorNotificationService";
import { DiscriminatedUnionTypeInstance } from "./DiscriminatedUnionTypeInstance";
import { ErrorReporter, Severity } from "./ErrorReporter";
import { TypeInstance } from "./TypeInstance";

export abstract class AbstractDynamicSnippetsGeneratorContext {
public config: FernGeneratorExec.GeneratorConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export declare namespace ErrorReporter {

type PathItem = string | ArrayPathItem;

type Severity = typeof Severity[keyof typeof Severity];
type Severity = (typeof Severity)[keyof typeof Severity];

interface ArrayPathItem {
index: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FernIr } from "@fern-api/dynamic-ir-sdk";

import { AbstractDynamicSnippetsGeneratorContext } from "./AbstractDynamicSnippetsGeneratorContext";
import { ErrorReporter } from "./ErrorReporter";
import { FernIr } from "@fern-api/dynamic-ir-sdk";

export class Result {
public reporter: ErrorReporter | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const Scope = {
RequestBody: "requestBody"
} as const;

export type Scope = typeof Scope[keyof typeof Scope];
export type Scope = (typeof Scope)[keyof typeof Scope];
5 changes: 2 additions & 3 deletions generators/csharp/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"lint:eslint:fix": "yarn lint:eslint --fix",
"format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
"format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
"organize-imports": "organize-imports-cli tsconfig.json",
"depcheck": "depcheck"
},
"dependencies": {
Expand All @@ -41,8 +40,8 @@
"@types/node": "18.15.3",
"depcheck": "^1.4.7",
"eslint": "^9.16.0",
"organize-imports-cli": "^0.10.0",
"prettier": "^2.7.1",
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
"prettier": "^3.4.2",
"typescript": "5.7.2",
"vitest": "^2.0.5"
}
Expand Down
3 changes: 2 additions & 1 deletion generators/csharp/codegen/src/FileGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { File } from "@fern-api/base-generator";
import { RelativeFilePath } from "@fern-api/fs-utils";

import { AbstractCsharpGeneratorContext } from "./cli";
import { BaseCsharpCustomConfigSchema } from "./custom-config";
import { File } from "@fern-api/base-generator";

export abstract class FileGenerator<
GeneratedFile extends File,
Expand Down
6 changes: 4 additions & 2 deletions generators/csharp/codegen/src/TestFileGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { join, RelativeFilePath } from "@fern-api/fs-utils";
import { csharp, CSharpFile, dependencies, FileGenerator } from ".";
import { RelativeFilePath, join } from "@fern-api/fs-utils";

import { CSharpFile, FileGenerator, csharp, dependencies } from ".";
import { AbstractCsharpGeneratorContext } from "./cli";
import { BaseCsharpCustomConfigSchema } from "./custom-config";

export class TestFileGenerator extends FileGenerator<
CSharpFile,
BaseCsharpCustomConfigSchema,
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/Access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const Access = {
Internal: "internal"
} as const;

export type Access = typeof Access[keyof typeof Access];
export type Access = (typeof Access)[keyof typeof Access];
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/Annotation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AstNode } from "./core/AstNode";
import { ClassReference } from "./ClassReference";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";

export declare namespace Annotation {
Expand Down
8 changes: 4 additions & 4 deletions generators/csharp/codegen/src/ast/Class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { Annotation } from "./Annotation";
import { ClassInstantiation } from "./ClassInstantiation";
import { ClassReference } from "./ClassReference";
import { CodeBlock } from "./CodeBlock";
import { AstNode } from "./core/AstNode";
import { DocXmlWriter } from "./core/DocXmlWriter";
import { Writer } from "./core/Writer";
import { Field } from "./Field";
import { Interface } from "./Interface";
import { Method } from "./Method";
import { MethodInvocation } from "./MethodInvocation";
import { Parameter } from "./Parameter";
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { DocXmlWriter } from "./core/DocXmlWriter";
import { Writer } from "./core/Writer";

export declare namespace Class {
type ClassType = typeof Class.ClassType[keyof typeof Class.ClassType];
type ClassType = (typeof Class.ClassType)[keyof typeof Class.ClassType];
interface Args {
/* The name of the C# class */
name: string;
Expand Down
1 change: 1 addition & 0 deletions generators/csharp/codegen/src/ast/ClassInstantiation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Arguments, hasNamedArgument, isNamedArgument } from "@fern-api/base-generator";

import { ClassReference } from "./ClassReference";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
Expand Down
1 change: 1 addition & 0 deletions generators/csharp/codegen/src/ast/CodeBlock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CodeBlock as CommonCodeBlock } from "@fern-api/base-generator";

import { AstNode, Writer } from "../csharp";

export declare namespace CodeBlock {
Expand Down
5 changes: 3 additions & 2 deletions generators/csharp/codegen/src/ast/Dictionary.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { assertNever } from "@fern-api/core-utils";
import { UnnamedArgument } from "@fern-api/base-generator";
import { assertNever } from "@fern-api/core-utils";

import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
import { Type } from "./Type";

export declare namespace Dictionary {
interface Args {
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Access } from "./Access";
import { Annotation } from "./Annotation";
import { ClassReference } from "./ClassReference";
import { CodeBlock } from "./CodeBlock";
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { DocXmlWriter } from "./core/DocXmlWriter";
import { Writer } from "./core/Writer";
import { Type } from "./Type";

export declare namespace Field {
interface Args {
Expand Down
6 changes: 3 additions & 3 deletions generators/csharp/codegen/src/ast/Interface.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Writer } from "./core/Writer";
import { ClassReference } from "./ClassReference";
import { Access } from "./Access";
import { AstNode } from "./core/AstNode";
import { ClassReference } from "./ClassReference";
import { Field } from "./Field";
import { Method } from "./Method";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";

export declare namespace Interface {
interface Args {
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/List.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
import { Type } from "./Type";

export declare namespace List {
interface Args {
Expand Down
4 changes: 2 additions & 2 deletions generators/csharp/codegen/src/ast/Method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Access } from "./Access";
import { Annotation } from "./Annotation";
import { ClassReference } from "./ClassReference";
import { CodeBlock } from "./CodeBlock";
import { Parameter } from "./Parameter";
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { DocXmlWriter } from "./core/DocXmlWriter";
import { Writer } from "./core/Writer";
import { Parameter } from "./Parameter";
import { Type } from "./Type";

export enum MethodType {
INSTANCE,
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/Parameter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
import { Type } from "./Type";

export declare namespace Parameter {
interface Args {
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/ReadOnlymemory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
import { Type } from "./Type";

export declare namespace ReadOnlyMemory {
interface Args {
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/Set.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from "./Type";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
import { Type } from "./Type";

export declare namespace Set {
interface Args {
Expand Down
1 change: 1 addition & 0 deletions generators/csharp/codegen/src/ast/Ternary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Ternary as CommonTernary } from "@fern-api/base-generator";

import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";

Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/ast/TestClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Annotation } from "./Annotation";
import { Class } from "./Class";
import { ClassReference } from "./ClassReference";
import { CodeBlock } from "./CodeBlock";
import { Method } from "./Method";
import { AstNode } from "./core/AstNode";
import { Writer } from "./core/Writer";
import { Method } from "./Method";

export declare namespace TestClass {
interface Args {
Expand Down
Loading

0 comments on commit 73a374e

Please sign in to comment.