chore: format all frontend files (#430)

This commit is contained in:
tecvan
2025-07-31 23:15:48 +08:00
committed by GitHub
parent 8b078ff013
commit 6995cec404
8787 changed files with 11975 additions and 10924 deletions

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function filterKeys(obj: Record<string, any>, keys: string[]) {
const newObj: Record<string, any> = {};
for (const key of keys) {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable */
import * as t from '../src/proto';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable */
import * as t from '../src/thrift';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable */
import * as t from '../src/unify/index';
@@ -182,7 +182,7 @@ const document = t.parse(
'index.proto': indexContent,
'base.proto': baseContent,
'extra.proto': extraContent,
}
},
);
const statement = document.statements[0] as t.InterfaceWithFields;
console.log(statement);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/proto';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as path from 'path';
import * as t from '../src/proto';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/proto';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/proto';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/thrift';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/thrift';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/thrift';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as path from 'path';
import * as t from '../src/thrift';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src/thrift';
describe('ferry-parser', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src';
import { filterKeys } from './common';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src';
import { filterKeys } from './common';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src';
import { filterKeys } from './common';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as path from 'path';
import * as t from '../src/unify';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src';
import { filterKeys } from './common';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as t from '../src';
import { filterKeys } from './common';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const POSITIONS = [
'query',
'body',

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
POSITIONS,
SERIALIZERS,

View File

@@ -13,5 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './unify';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint no-param-reassign: ["error", { "props": false }] */
import * as path from 'path';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type FieldExtensionConfig,
type ServiceExtensionConfig,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint no-param-reassign: ["error", { "props": false }] */
import * as path from 'path';
@@ -155,7 +155,9 @@ function reviseFieldComments(struct: InterfaceWithFields) {
const { fields } = struct;
/* istanbul ignore next */
if (fields.length < 2) {return;}
if (fields.length < 2) {
return;
}
for (let i = fields.length - 1; i > 0; i--) {
const currentField = fields[i];
@@ -183,7 +185,9 @@ function reviseEnumMemberComments(enm: EnumDefinition) {
const { members } = enm;
/* istanbul ignore next */
if (members.length < 2) {return;}
if (members.length < 2) {
return;
}
for (let i = 0; i < members.length - 1; i++) {
const currentMember = members[i];
@@ -203,7 +207,9 @@ function reviseEnumMemberComments(enm: EnumDefinition) {
function reviseFunctionComments(service: ServiceDefinition) {
const { functions } = service;
if (functions.length < 2) {return;}
if (functions.length < 2) {
return;
}
for (let i = 0; i < functions.length - 1; i++) {
const currentFunction = functions[i];

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type FieldExtensionConfig,
type ServiceExtensionConfig,

View File

@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as path from 'path';
import * as fs from 'fs';
import { logAndThrowError , mergeObject, getPosixPath } from '../utils';
import { logAndThrowError, mergeObject, getPosixPath } from '../utils';
import { parseThriftContent } from './thrift';
import { parseProtoContent } from './proto';
import { type UnifyDocument } from './type';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint import/prefer-default-export: off */
import * as path from 'path';
import * as fs from 'fs';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint no-param-reassign: ["error", { "props": false }], import/prefer-default-export: off */
import * as path from 'path';
import * as fs from 'fs';
@@ -317,13 +317,15 @@ function createAddNamespaceReferValue(
const identifierValue = (fieldType as Identifier).value;
if (!identifierValue.includes('.')) {
(fieldType as Identifier).namespaceValue =
`${namespace}.${identifierValue}`;
(
fieldType as Identifier
).namespaceValue = `${namespace}.${identifierValue}`;
} else {
const parts = identifierValue.split('.');
if (parts.length === 2 && enumNames.includes(parts[0])) {
(fieldType as Identifier).namespaceValue =
`${namespace}.${identifierValue}`;
(
fieldType as Identifier
).namespaceValue = `${namespace}.${identifierValue}`;
} else {
for (const regExp of regExpNamespaceMap.keys()) {
if (regExp.test(identifierValue)) {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type FieldExtensionConfig,
type ServiceExtensionConfig,

View File

@@ -13,8 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { SyntaxType, type ContainerType, type MapType, type FieldType } from './type';
import {
SyntaxType,
type ContainerType,
type MapType,
type FieldType,
} from './type';
export function convertIntToString(fType: FieldType): FieldType {
const fieldType = { ...fType };

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { logger } from '@coze-arch/rush-logger';
export const logAndThrowError = (logMessage: string, errorMessage?: string) => {
@@ -27,7 +27,9 @@ export function mergeObject(
...sources: { [key: string]: any }[]
): { [key: string]: any } {
const newObj = { ...target };
if (!sources) {return newObj;}
if (!sources) {
return newObj;
}
for (const source of sources) {
for (const key of Object.keys(source)) {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -36,3 +36,4 @@
"vitest": "~3.0.5"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import { genClient } from '@coze-arch/idl2ts-generator';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ora from 'ora';
import { Command } from 'commander';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import { type ApiConfig } from './types';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IPlugin, type Program, after } from '@coze-arch/idl2ts-plugin';
import {
type IParseEntryCtx,

View File

@@ -13,5 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { PatchPlugin } from './forward';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type Program, on } from '@coze-arch/idl2ts-plugin';
import {
type IParseEntryCtx,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IPlugin, type Program, after } from '@coze-arch/idl2ts-plugin';
import { type IParseEntryCtx } from '@coze-arch/idl2ts-helper';
import { HOOK } from '@coze-arch/idl2ts-generator';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import { type Program, after } from '@coze-arch/idl2ts-plugin';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs';
import { format } from 'prettier';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import { type IPlugin, type Program, after } from '@coze-arch/idl2ts-plugin';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import dayjs from 'dayjs';
import { faker } from '@faker-js/faker';
import { type IPlugin, type Program, before } from '@coze-arch/idl2ts-plugin';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IPlugin } from '@coze-arch/idl2ts-generator';
export interface ApiConfig {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import { type ApiConfig } from './types';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -45,3 +45,4 @@
"vitest": "~3.0.5"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { SchemaObject, JSONSchemaType } from 'ajv';
import { type Ctxs } from '@coze-arch/idl2ts-plugin';
import {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import fs from 'fs-extra';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IGenOptions } from './types';
import { ClientGenerator } from './core';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import fs from 'fs-extra';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type Program, after, type IPlugin } from '@coze-arch/idl2ts-plugin';
import { type IParseEntryCtx, isPbFile } from '@coze-arch/idl2ts-helper';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { isAbsolute } from 'path';
import { type Program, after, type IPlugin } from '@coze-arch/idl2ts-plugin';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type Program, after, before } from '@coze-arch/idl2ts-plugin';
import { isStructDefinition } from '@coze-arch/idl2ts-helper';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type Program, after } from '@coze-arch/idl2ts-plugin';
import {
isStructDefinition,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './adapter-plugin';
export * from './client-plugin';
export * from './meta-plugin';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IPlugin, type Program, on } from '@coze-arch/idl2ts-plugin';
import {
type Identifier,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { faker } from '@faker-js/faker';
import {
type IPlugin,
@@ -196,7 +196,9 @@ export class MockTransformerPlugin implements IPlugin {
const { name, returnType, fields } = f;
const reqType = fields[0].fieldType as any;
const resType = this.processReqResPramsType(returnType, ctx.ast);
return `${name.value}:{req:${parseId(reqType.value)},res:${parseId(resType)}}`;
return `${name.value}:{req:${parseId(reqType.value)},res:${parseId(
resType,
)}}`;
})}}`,
) as t.ExpressionStatement;
return variableDeclaration;
@@ -260,8 +262,8 @@ export class MockTransformerPlugin implements IPlugin {
const key = t.isStringLiteral(i.key)
? i.key.value
: t.isIdentifier(i.key)
? i.key.name
: '';
? i.key.name
: '';
fieldNames.delete(key);
}
newPros.push(i);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EOL } from 'os';
import { type IPlugin, type Program, after } from '@coze-arch/idl2ts-plugin';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type IPlugin,
type Program,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import { EOL } from 'os';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
import { SyntaxType } from '@coze-arch/idl-parser';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IPlugin } from '@coze-arch/idl2ts-plugin';
import { type IParseResultItem } from '@coze-arch/idl2ts-helper';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -33,3 +33,4 @@
"vitest": "~3.0.5"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const ReservedKeyWord = [
'class',
'const',

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type t from '@babel/types';
import {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import prettier, { type Options } from 'prettier';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './parser';
export * from './types';
export * from './ctx';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as path from 'path';
import { parse, type UnifyDocument } from '@coze-arch/idl-parser';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type UnifyStatement,
SyntaxType,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import fs from 'fs';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type Ctxs, type IPlugin, Program, on, before, after } from '../src';
interface Ctx {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export enum Phases {
BEFORE = 'BEFORE',
ON = 'ON',

View File

@@ -13,6 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './hooks';
export * from './program';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { joinPhases, Phases } from './hooks';
type IHookHandler<T> = (args: T) => T;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { IdlConfig } from './utils';
class ConfigCenter {
@@ -30,7 +30,9 @@ export const configCenter = new ConfigCenter();
export function registerConfig(service: string, config: IdlConfig): void {
if (configCenter.getConfig(service)) {
console.warn(`${service} api config has already been set,make sure they are the same`);
console.warn(
`${service} api config has already been set,make sure they are the same`,
);
}
configCenter.register(service, config);
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type IOptions, normalizeRequest } from './utils';
import type { IMeta, CustomAPIMeta } from './types';
@@ -40,7 +40,12 @@ export interface CancelAbleApi<T, K, O = unknown, B extends boolean = false>
* @returns
*/
// eslint-disable-next-line max-params
export function createAPI<T extends {}, K, O = unknown, B extends boolean = false>(
export function createAPI<
T extends {},
K,
O = unknown,
B extends boolean = false,
>(
meta: IMeta,
cancelable?: B,
useCustom = false,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './create-api';
export * from './config-center';
export { type IMeta } from './types';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface IMeta {
reqType: string;
resType: string;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import qs from 'qs';
import type { IMeta } from './types';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({