feat: better server lint (#2850)
* feat: add stylistic eslint plugin * feat: add missing line return * feat: secure line-break style * feat: disallow break before else * feat: line between class members * feat: better new line lint rule
This commit is contained in:
@ -129,6 +129,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
||||
if (position > acc) {
|
||||
return position;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, -1);
|
||||
|
||||
|
||||
@ -16,11 +16,13 @@ export class BeforeCreateOneField<T extends CreateFieldInput>
|
||||
context: any,
|
||||
): Promise<CreateOneInputType<T>> {
|
||||
const workspaceId = context?.req?.user?.workspace?.id;
|
||||
|
||||
if (!workspaceId) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
instance.input.workspaceId = workspaceId;
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ describe('generateTargetColumnMap', () => {
|
||||
false,
|
||||
'name',
|
||||
);
|
||||
|
||||
expect(textMap).toEqual({ value: 'name' });
|
||||
|
||||
const linkMap = generateTargetColumnMap(
|
||||
@ -17,6 +18,7 @@ describe('generateTargetColumnMap', () => {
|
||||
false,
|
||||
'website',
|
||||
);
|
||||
|
||||
expect(linkMap).toEqual({ label: 'websiteLabel', url: 'websiteUrl' });
|
||||
|
||||
const currencyMap = generateTargetColumnMap(
|
||||
@ -24,6 +26,7 @@ describe('generateTargetColumnMap', () => {
|
||||
true,
|
||||
'price',
|
||||
);
|
||||
|
||||
expect(currencyMap).toEqual({
|
||||
amountMicros: '_priceAmountMicros',
|
||||
currencyCode: '_priceCurrencyCode',
|
||||
|
||||
@ -40,6 +40,7 @@ describe('serializeDefaultValue', () => {
|
||||
|
||||
it('should handle Date static default value', () => {
|
||||
const date = new Date('2023-01-01');
|
||||
|
||||
expect(serializeDefaultValue(date)).toBe(`'${date.toISOString()}'`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -36,6 +36,7 @@ export class BeforeCreateOneObject<T extends CreateObjectInput>
|
||||
);
|
||||
}
|
||||
instance.input.workspaceId = workspaceId;
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,6 +197,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
if (fieldMetadata.type === FieldMetadataType.RELATION) {
|
||||
acc[fieldMetadata.objectMetadataId] = fieldMetadata;
|
||||
}
|
||||
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
@ -282,6 +283,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
("objectMetadataId", "type", "name")
|
||||
VALUES ('${createdObjectMetadata.id}', 'table', 'All ${createdObjectMetadata.namePlural}') RETURNING *`,
|
||||
);
|
||||
|
||||
createdObjectMetadata.fields.map(async (field, index) => {
|
||||
if (field.name === 'id') {
|
||||
return;
|
||||
|
||||
@ -22,6 +22,7 @@ export class BeforeCreateOneRelation<T extends CreateRelationInput>
|
||||
}
|
||||
|
||||
instance.input.workspaceId = workspaceId;
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +97,7 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
||||
|
||||
const objectMetadataMap = objectMetadataEntries.reduce((acc, curr) => {
|
||||
acc[curr.id] = curr;
|
||||
|
||||
return acc;
|
||||
}, {} as { [key: string]: ObjectMetadataEntity });
|
||||
|
||||
@ -169,6 +170,7 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
||||
if (fieldMetadata.type === FieldMetadataType.RELATION) {
|
||||
acc[fieldMetadata.objectMetadataId] = fieldMetadata;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
@ -94,11 +94,13 @@ export class WorkspaceMigrationFactory {
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
): WorkspaceMigrationColumnAction[];
|
||||
|
||||
createColumnActions(
|
||||
action: WorkspaceMigrationColumnActionType.ALTER,
|
||||
previousFieldMetadata: FieldMetadataInterface,
|
||||
nextFieldMetadata: FieldMetadataInterface,
|
||||
): WorkspaceMigrationColumnAction[];
|
||||
|
||||
createColumnActions(
|
||||
action:
|
||||
| WorkspaceMigrationColumnActionType.CREATE
|
||||
|
||||
@ -31,6 +31,7 @@ export class WorkspaceMigrationService {
|
||||
const insertedStandardMigrationsMapByName =
|
||||
insertedStandardMigrations.reduce((acc, migration) => {
|
||||
acc[migration.name] = migration;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user