Skip to content

Commit

Permalink
chore(lib): run format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Jun 17, 2020
1 parent b136281 commit b922775
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/decorators/api-header.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ export const ApiHeaders = (headers: ApiHeaderOptions[]): MethodDecorator => {
key?: string | symbol,
descriptor?: TypedPropertyDescriptor<any>
): any => {
headers.forEach(options => ApiHeader(options)(target, key, descriptor));
headers.forEach((options) => ApiHeader(options)(target, key, descriptor));
};
};
2 changes: 1 addition & 1 deletion lib/decorators/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createClassDecorator<T extends Array<any> = any>(
metakey: string,
metadata: T = [] as T
): ClassDecorator {
return target => {
return (target) => {
const prevValue = Reflect.getMetadata(metakey, target) || [];
Reflect.defineMetadata(metakey, [...prevValue, ...metadata], target);
return target;
Expand Down
2 changes: 1 addition & 1 deletion lib/document-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class DocumentBuilder {
}

public addCookieAuth(
cookieName: string = 'connect.sid',
cookieName = 'connect.sid',
options: SecuritySchemeObject = {
type: 'apiKey'
},
Expand Down
9 changes: 6 additions & 3 deletions lib/explorers/api-parameters.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ function removeBodyMetadataIfExplicitExists(
properties: ParamWithTypeMetadata[],
explicitParams: any[]
) {
const isBodyReflected = some(properties, p => p.in === 'body');
const isBodyDefinedExplicitly = some(explicitParams, p => p.in === 'body');
const isBodyReflected = some(properties, (p) => p.in === 'body');
const isBodyDefinedExplicitly = some(explicitParams, (p) => p.in === 'body');
if (isBodyReflected && isBodyDefinedExplicitly) {
return omitBy(properties, p => p.in === 'body') as ParamWithTypeMetadata[];
return omitBy(
properties,
(p) => p.in === 'body'
) as ParamWithTypeMetadata[];
}
return properties;
}
2 changes: 1 addition & 1 deletion lib/plugin/compiler-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ModelClassVisitor } from './visitors/model-class.visitor';
const modelClassVisitor = new ModelClassVisitor();
const controllerClassVisitor = new ControllerClassVisitor();
const isFilenameMatched = (patterns: string[], filename: string) =>
patterns.some(path => filename.includes(path));
patterns.some((path) => filename.includes(path));

export const before = (options?: Record<string, any>, program?: ts.Program) => {
options = mergePluginOptions(options);
Expand Down
2 changes: 1 addition & 1 deletion lib/services/mimetype-content-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class MimetypeContentWrapper {
obj: Record<string, any>
): Record<'content', ContentObject> {
const content = mimetype
.map(item => ({
.map((item) => ({
[item]: obj
}))
.reduce((a, b) => ({ ...a, ...b }), {});
Expand Down
2 changes: 1 addition & 1 deletion lib/services/parameters-metadata-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ParametersMetadataMapper {
prototype
);

return modelProperties.map(key =>
return modelProperties.map((key) =>
this.mergeImplicitWithExplicit(key, prototype, param)
);
});
Expand Down
8 changes: 4 additions & 4 deletions lib/swagger-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class SwaggerScanner {
Array.from(relatedModules.values())
.filter(isGlobal as any)
.map(({ routes: relatedModuleRoutes }) => relatedModuleRoutes)
.forEach(relatedModuleRoutes => {
.forEach((relatedModuleRoutes) => {
allRoutes = new Map([...allRoutes, ...relatedModuleRoutes]);
});
}
Expand Down Expand Up @@ -87,7 +87,7 @@ export class SwaggerScanner {
modulePath?: string,
globalPrefix?: string
): Array<Omit<OpenAPIObject, 'openapi' | 'info'> & Record<'root', any>> {
const denormalizedArray = [...routes.values()].map(ctrl =>
const denormalizedArray = [...routes.values()].map((ctrl) =>
this.explorer.exploreController(ctrl, modulePath, globalPrefix)
);
return flatten(denormalizedArray) as any;
Expand All @@ -101,12 +101,12 @@ export class SwaggerScanner {
return [...modulesContainer.values()];
}
return [...modulesContainer.values()].filter(({ metatype }) =>
include.some(item => item === metatype)
include.some((item) => item === metatype)
);
}

public addExtraModels(schemas: SchemaObject[], extraModels: Function[]) {
extraModels.forEach(item => {
extraModels.forEach((item) => {
this.schemaObjectFactory.exploreModelSchema(item, schemas);
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/swagger-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export class SwaggerTransformer {
public normalizePaths(
denormalizedDoc: (Partial<OpenAPIObject> & Record<'root', any>)[]
): Record<'paths', OpenAPIObject['paths']> {
const roots = filter(denormalizedDoc, r => r.root);
const roots = filter(denormalizedDoc, (r) => r.root);
const groupedByPath = groupBy(
roots,
({ root }: Record<'root', any>) => root.path
);
const paths = mapValues(groupedByPath, routes => {
const paths = mapValues(groupedByPath, (routes) => {
const keyByMethod = keyBy(
routes,
({ root }: Record<'root', any>) => root.method
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/get-schema-path.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getSchemaPath(model: string | Function): string {
}

export function refs(...models: Function[]) {
return models.map(item => ({
return models.map((item) => ({
$ref: getSchemaPath(item.name)
}));
}
2 changes: 1 addition & 1 deletion lib/utils/is-built-in-type.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { BUILT_IN_TYPES } from '../services/constants';
export function isBuiltInType(
type: Type<unknown> | Function | string
): boolean {
return isFunction(type) && BUILT_IN_TYPES.some(item => item === type);
return isFunction(type) && BUILT_IN_TYPES.some((item) => item === type);
}

0 comments on commit b922775

Please sign in to comment.