diff --git a/packages/protobuf/src/codegen-info.ts b/packages/protobuf/src/codegen-info.ts index e6314b865..1f325678d 100644 --- a/packages/protobuf/src/codegen-info.ts +++ b/packages/protobuf/src/codegen-info.ts @@ -47,11 +47,11 @@ interface CodegenInfo { | DescOneof | DescField | DescService - | DescMethod + | DescMethod, ) => string; readonly symbols: Record; readonly getUnwrappedFieldType: ( - field: DescField | DescExtension + field: DescField | DescExtension, ) => ScalarType | undefined; readonly wktSourceFiles: readonly string[]; /** @@ -60,7 +60,7 @@ interface CodegenInfo { readonly scalarDefaultValue: (type: ScalarType, longType: LongType) => any; // eslint-disable-line @typescript-eslint/no-explicit-any readonly scalarZeroValue: ( type: T, - longType: L + longType: L, ) => ScalarValue; /** * @deprecated please use reifyWkt from @bufbuild/protoplugin/ecmascript instead diff --git a/packages/protobuf/src/message.ts b/packages/protobuf/src/message.ts index f735e479d..d78c37a53 100644 --- a/packages/protobuf/src/message.ts +++ b/packages/protobuf/src/message.ts @@ -46,7 +46,7 @@ export class Message = AnyMessage> { return this.getType().runtime.util.equals( this.getType(), this as unknown as T, - other + other, ); } @@ -96,7 +96,7 @@ export class Message = AnyMessage> { throw new Error( `cannot decode ${this.getType().typeName} from JSON: ${ e instanceof Error ? e.message : String(e) - }` + }`, ); } return this.fromJson(json, options); diff --git a/packages/protoc-gen-es/src/util.ts b/packages/protoc-gen-es/src/util.ts index 08d4e0042..5a63d2045 100644 --- a/packages/protoc-gen-es/src/util.ts +++ b/packages/protoc-gen-es/src/util.ts @@ -27,7 +27,7 @@ import { localName } from "@bufbuild/protoplugin/ecmascript"; export function getFieldTypeInfo( field: DescField | DescExtension, - strict: boolean + strict: boolean, ): { typing: Printable; optional: boolean; @@ -89,7 +89,7 @@ export function getFieldTypeInfo( case "scalar": valueType = scalarTypeScriptType( field.mapValue.scalar, - LongType.BIGINT + LongType.BIGINT, ); break; case "message": @@ -130,7 +130,7 @@ export function getFieldDefaultValueExpression( enumAs: | "enum_value_as_is" | "enum_value_as_integer" - | "enum_value_as_cast_integer" = "enum_value_as_is" + | "enum_value_as_cast_integer" = "enum_value_as_is", ): Printable | undefined { if (field.repeated) { return undefined; @@ -145,11 +145,11 @@ export function getFieldDefaultValueExpression( switch (field.fieldKind) { case "enum": { const enumValue = field.enum.values.find( - (value) => value.number === defaultValue + (value) => value.number === defaultValue, ); if (enumValue === undefined) { throw new Error( - `invalid enum default value: ${String(defaultValue)} for ${enumValue}` + `invalid enum default value: ${String(defaultValue)} for ${enumValue}`, ); } return literalEnumValue(enumValue, enumAs); @@ -174,7 +174,7 @@ export function getFieldZeroValueExpression( enumAs: | "enum_value_as_is" | "enum_value_as_integer" - | "enum_value_as_cast_integer" = "enum_value_as_is" + | "enum_value_as_cast_integer" = "enum_value_as_is", ): Printable | undefined { if (field.repeated) { return "[]"; @@ -196,7 +196,7 @@ export function getFieldZeroValueExpression( case "scalar": { const defaultValue = codegenInfo.scalarZeroValue( field.scalar, - field.longType + field.longType, ); return literalScalarValue(defaultValue, field); } @@ -205,7 +205,7 @@ export function getFieldZeroValueExpression( function literalScalarValue( value: ScalarValue, - field: (DescField | DescExtension) & { fieldKind: "scalar" } + field: (DescField | DescExtension) & { fieldKind: "scalar" }, ): Printable { switch (field.scalar) { case ScalarType.DOUBLE: @@ -217,28 +217,28 @@ function literalScalarValue( case ScalarType.SINT32: if (typeof value != "number") { throw new Error( - `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}` + `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}`, ); } return value; case ScalarType.BOOL: if (typeof value != "boolean") { throw new Error( - `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}` + `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}`, ); } return value; case ScalarType.STRING: if (typeof value != "string") { throw new Error( - `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}` + `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}`, ); } return { kind: "es_string", value }; case ScalarType.BYTES: if (!(value instanceof Uint8Array)) { throw new Error( - `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}` + `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}`, ); } return value; @@ -249,7 +249,7 @@ function literalScalarValue( case ScalarType.FIXED64: if (typeof value != "bigint" && typeof value != "string") { throw new Error( - `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}` + `Unexpected value for ${ScalarType[field.scalar]} ${field.toString()}: ${String(value)}`, ); } return { @@ -266,7 +266,7 @@ function literalEnumValue( enumAs: | "enum_value_as_is" | "enum_value_as_integer" - | "enum_value_as_cast_integer" + | "enum_value_as_cast_integer", ): Printable { switch (enumAs) { case "enum_value_as_is": diff --git a/packages/protoplugin/src/ecmascript/parameter.ts b/packages/protoplugin/src/ecmascript/parameter.ts index 47b7955a5..979fbb592 100644 --- a/packages/protoplugin/src/ecmascript/parameter.ts +++ b/packages/protoplugin/src/ecmascript/parameter.ts @@ -30,7 +30,7 @@ export interface ParsedParameter { export function parseParameter( parameter: string | undefined, - parseExtraOption: ((key: string, value: string) => void) | undefined + parseExtraOption: ((key: string, value: string) => void) | undefined, ): ParsedParameter { let targets: Target[] = ["js", "dts"]; let tsNocheck = true; @@ -96,7 +96,7 @@ export function parseParameter( if (parts.length !== 2) { throw new PluginOptionError( raw, - "must be in the form of :" + "must be in the form of :", ); } const [pattern, target] = parts; @@ -184,7 +184,7 @@ export function parseParameter( } function splitParameter( - parameter: string | undefined + parameter: string | undefined, ): { key: string; value: string; raw: string }[] { if (parameter == undefined) { return []; diff --git a/packages/protoplugin/src/ecmascript/runtime-imports.ts b/packages/protoplugin/src/ecmascript/runtime-imports.ts index f330ddca9..43699a142 100644 --- a/packages/protoplugin/src/ecmascript/runtime-imports.ts +++ b/packages/protoplugin/src/ecmascript/runtime-imports.ts @@ -71,12 +71,12 @@ export function createRuntimeImports(bootstrapWkt: boolean): RuntimeImports { function infoToSymbol( name: keyof typeof codegenInfo.symbols, - bootstrapWkt: boolean + bootstrapWkt: boolean, ): ImportSymbol { const info = codegenInfo.symbols[name]; const symbol = createImportSymbol( name, - bootstrapWkt ? info.privateImportPath : info.publicImportPath + bootstrapWkt ? info.privateImportPath : info.publicImportPath, ); return info.typeOnly ? symbol.toTypeOnly() : symbol; } diff --git a/packages/protoplugin/src/ecmascript/schema.ts b/packages/protoplugin/src/ecmascript/schema.ts index d916247fb..ca2114e3a 100644 --- a/packages/protoplugin/src/ecmascript/schema.ts +++ b/packages/protoplugin/src/ecmascript/schema.ts @@ -95,7 +95,7 @@ export function createSchema( parameter: ParsedParameter, pluginName: string, pluginVersion: string, - featureSetDefaults: FeatureSetDefaults | undefined + featureSetDefaults: FeatureSetDefaults | undefined, ): SchemaController { const descriptorSet = createDescriptorSet(request.protoFile, { featureSetDefaults, @@ -103,13 +103,13 @@ export function createSchema( const filesToGenerate = findFilesToGenerate(descriptorSet, request); const runtime = createRuntimeImports(parameter.bootstrapWkt); const createTypeImport = ( - desc: DescMessage | DescEnum | DescExtension + desc: DescMessage | DescEnum | DescExtension, ): ImportSymbol => { const name = codegenInfo.localName(desc); const from = makeImportPath( desc.file, parameter.bootstrapWkt, - filesToGenerate + filesToGenerate, ); return createImportSymbol(name, from); }; @@ -119,7 +119,7 @@ export function createSchema( pluginName, pluginVersion, parameter.sanitizedParameter, - parameter.tsNocheck + parameter.tsNocheck, ); let target: Target | undefined; const generatedFiles: GeneratedFileController[] = []; @@ -133,7 +133,7 @@ export function createSchema( generateFile(name) { if (target === undefined) { throw new Error( - "prepareGenerate() must be called before generateFile()" + "prepareGenerate() must be called before generateFile()", ); } const genFile = createGeneratedFile( @@ -144,11 +144,11 @@ export function createSchema( rewriteImportPath( importPath, parameter.rewriteImports, - parameter.importExtension + parameter.importExtension, ), createTypeImport, runtime, - createPreamble + createPreamble, ); generatedFiles.push(genFile); return genFile; @@ -166,15 +166,17 @@ export function createSchema( function findFilesToGenerate( descriptorSet: DescriptorSet, - request: CodeGeneratorRequest + request: CodeGeneratorRequest, ) { const missing = request.fileToGenerate.filter((fileToGenerate) => - descriptorSet.files.every((file) => fileToGenerate !== file.name + ".proto") + descriptorSet.files.every( + (file) => fileToGenerate !== file.name + ".proto", + ), ); if (missing.length) { throw `files_to_generate missing in the request: ${missing.join(", ")}`; } return descriptorSet.files.filter((file) => - request.fileToGenerate.includes(file.name + ".proto") + request.fileToGenerate.includes(file.name + ".proto"), ); }