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:
Jérémy M
2023-12-06 12:19:00 +01:00
committed by GitHub
parent e388d90976
commit 9df83c9a5a
75 changed files with 318 additions and 21 deletions

View File

@ -18,14 +18,17 @@ export const demoObjectsPrefillData = async (
id: object.id,
fields: object.fields.reduce((acc, field) => {
acc[field.name] = field.id;
return acc;
}, {}),
};
return acc;
}, {});
// TODO: udnerstand why only with this createQueryRunner transaction below works
const queryRunner = workspaceDataSource.createQueryRunner();
await queryRunner.connect();
workspaceDataSource.transaction(async (entityManager: EntityManager) => {

View File

@ -5,6 +5,7 @@ const tableName = 'opportunity';
const getRandomProbability = () => {
const firstDigit = Math.floor(Math.random() * 9) + 1;
return firstDigit / 10;
};
@ -13,6 +14,7 @@ const getRandomPipelineStepId = (pipelineStepIds: { id: string }[]) =>
const generateRandomAmountMicros = () => {
const firstDigit = Math.floor(Math.random() * 9) + 1;
return firstDigit * 10000000000;
};

View File

@ -35,6 +35,7 @@ export const viewPrefillData = async (
const viewIdMap = createdViews.raw.reduce((acc, view) => {
acc[view.name] = view.id;
return acc;
}, {});

View File

@ -16,9 +16,11 @@ export const standardObjectsPrefillData = async (
id: object.id,
fields: object.fields.reduce((acc, field) => {
acc[field.name] = field.id;
return acc;
}, {}),
};
return acc;
}, {});

View File

@ -35,6 +35,7 @@ export const viewPrefillData = async (
const viewIdMap = createdViews.raw.reduce((acc, view) => {
acc[view.name] = view.id;
return acc;
}, {});

View File

@ -12,6 +12,7 @@ export class MetadataParser {
if (objectMetadata) {
const fields = Object.values(fieldMetadata);
return {
...objectMetadata,
workspaceId,

View File

@ -33,9 +33,11 @@ export const mapObjectMetadataByUniqueIdentifier = (
...curr,
fields: curr.fields.reduce((acc, curr) => {
acc[curr.name] = curr;
return acc;
}, {}),
};
return acc;
}, {});
};

View File

@ -182,6 +182,7 @@ export class WorkspaceManagerService {
const createdObjectMetadataByNameSingular = createdObjectMetadata.reduce(
(acc, curr) => {
acc[curr.nameSingular] = curr;
return acc;
},
{},
@ -326,6 +327,7 @@ export class WorkspaceManagerService {
if (value === null || typeof value !== 'object') {
return [key, value];
}
return [key, filterIgnoredProperties(value, fieldPropertiesToIgnore)];
}),
);
@ -346,6 +348,7 @@ export class WorkspaceManagerService {
// We only handle CHANGE here as REMOVE and CREATE are handled earlier.
if (diff.type === 'CHANGE') {
const property = diff.path[0];
objectsToUpdate[objectInDB.id] = {
...objectsToUpdate[objectInDB.id],
[property]: diff.value,
@ -357,12 +360,14 @@ export class WorkspaceManagerService {
if (diff.type === 'CREATE') {
const fieldName = diff.path[0];
const fieldMetadata = standardObjectFields[fieldName];
fieldsToCreate.push(fieldMetadata);
}
if (diff.type === 'CHANGE') {
const fieldName = diff.path[0];
const property = diff.path[diff.path.length - 1];
const fieldMetadata = objectInDBFields[fieldName];
fieldsToUpdate[fieldMetadata.id] = {
...fieldsToUpdate[fieldMetadata.id],
[property]: diff.value,
@ -371,6 +376,7 @@ export class WorkspaceManagerService {
if (diff.type === 'REMOVE') {
const fieldName = diff.path[0];
const fieldMetadata = objectInDBFields[fieldName];
fieldsToDelete.push(fieldMetadata);
}
}
@ -429,6 +435,7 @@ export class WorkspaceManagerService {
await this.workspaceDataSourceService.connectToWorkspaceDataSource(
workspaceId,
);
await workspaceDataSource.query(
`comment on schema ${schemaName} is e'@graphql({"max_rows": 60})'`,
);
@ -460,6 +467,7 @@ export class WorkspaceManagerService {
createdObjectMetadata,
);
}
/**
*
* We are prefilling a few demo objects with data to make it easier for the user to get started.