The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
chore(twenty-server): remove eslint warn + add maxWarning 0 (#10103)
Antoine Moreauxde91a5e39e71
diff --git a/packages/twenty-server/project.json b/packages/twenty-server/project.jsonindex 1532eb1c848..58937ac29f3 100644--- a/packages/twenty-server/project.json+++ b/packages/twenty-server/project.json@@ -121,7 +121,8 @@},"lint": {"options": {- "lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"]+ "lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"],+ "maxWarnings": 0},"configurations": {"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },diff --git a/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts b/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.tsindex 9ee592ff2eb..2ba62c005e2 100644--- a/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts+++ b/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts@@ -49,6 +49,7 @@ export class DataSeedDemoWorkspaceService {await this.workspaceManagerService.initDemo(workspaceId);}} catch (error) {+ // eslint-disable-next-line no-consoleconsole.error(error);return;diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.tsindex 8b42abc8ca5..57a4a588227 100644--- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts+++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts@@ -2,6 +2,8 @@import { Injectable } from '@nestjs/common';import { Module } from '@nestjs/core/injector/module';+import { isDefined } from 'twenty-shared';+import { WorkspaceQueryHookInstance } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-hook/interfaces/workspace-query-hook.interface';import { WorkspaceResolverBuilderMethodNames } from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';@@ -48,9 +50,13 @@ export class WorkspaceQueryHookStorage {throw new Error(`Can't split workspace query hook key: ${key}`);}- // Retrive wildcard pre-hook instances- if (this.preHookInstances.has(`*.${methodName}`)) {- wildcardInstances = this.preHookInstances.get(`*.${methodName}`)!;+ // Retrieve wildcard pre-hook instances+ const wildcardPrehooksInstance = this.preHookInstances.get(+ `*.${methodName}`,+ );++ if (isDefined(wildcardPrehooksInstance)) {+ wildcardInstances = wildcardPrehooksInstance;}return [...wildcardInstances, ...(this.preHookInstances.get(key) ?? [])];@@ -80,9 +86,13 @@ export class WorkspaceQueryHookStorage {throw new Error(`Can't split workspace query hook key: ${key}`);}- // Retrive wildcard post-hook instances- if (this.postHookInstances.has(`*.${methodName}`)) {- wildcardInstances = this.postHookInstances.get(`*.${methodName}`)!;+ // Retrieve wildcard post-hook instances+ const wildcardPosthooksInstance = this.postHookInstances.get(+ `*.${methodName}`,+ );++ if (isDefined(wildcardPosthooksInstance)) {+ wildcardInstances = wildcardPosthooksInstance;}return [...wildcardInstances, ...(this.postHookInstances.get(key) ?? [])];diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts b/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.tsindex de13052f8f1..92d308e7182 100644--- a/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts+++ b/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts@@ -48,6 +48,7 @@ export class WorkspaceSchemaFactory {);if (isNewRelationEnabled) {+ // eslint-disable-next-line no-consoleconsole.log(chalk.yellow('🚧 New relation schema generation is enabled 🚧'),);@@ -84,6 +85,7 @@ export class WorkspaceSchemaFactory {(isNewRelationEnabled !== cachedIsNewRelationEnabled &&cachedIsNewRelationEnabled !== undefined)) {+ // eslint-disable-next-line no-consoleconsole.log(chalk.yellow('Recomputing due to new relation feature flag'),{diff --git a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.tsindex f177fb4533c..3e6c57fac86 100644--- a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts@@ -36,10 +36,7 @@ export class GoogleAPIsOauthExchangeCodeForTokenGuard extends AuthGuard();}- new GoogleAPIsOauthExchangeCodeForTokenStrategy(- this.environmentService,- {},- );+ new GoogleAPIsOauthExchangeCodeForTokenStrategy(this.environmentService);setRequestExtraParams(request, {transientToken: state.transientToken,diff --git a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.tsindex 70839c6f425..4eff559590e 100644--- a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts@@ -64,7 +64,7 @@ export class GoogleAPIsOauthRequestCodeGuard extends AuthGuard('google-apis') {);}- new GoogleAPIsOauthRequestCodeStrategy(this.environmentService, {});+ new GoogleAPIsOauthRequestCodeStrategy(this.environmentService);return (await super.canActivate(context)) as boolean;} catch (err) {diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.tsindex 741a05ef6c8..36351e2a49f 100644--- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts@@ -16,10 +16,7 @@ export class GoogleAPIsOauthCommonStrategy extends PassportStrategy(Strategy,'google-apis',) {- constructor(- environmentService: EnvironmentService,- scopeConfig: GoogleAPIScopeConfig,- ) {+ constructor(environmentService: EnvironmentService) {const scopes = getGoogleApisOauthScopes();super({diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.tsindex 244b1066d84..1b89939b621 100644--- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts@@ -12,11 +12,8 @@ export type GoogleAPIScopeConfig = {@Injectable()export class GoogleAPIsOauthExchangeCodeForTokenStrategy extends GoogleAPIsOauthCommonStrategy {- constructor(- environmentService: EnvironmentService,- scopeConfig: GoogleAPIScopeConfig,- ) {- super(environmentService, scopeConfig);+ constructor(environmentService: EnvironmentService) {+ super(environmentService);}async validate(diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.tsindex 6ce3c33c502..0eda93a5b49 100644--- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts@@ -10,11 +10,8 @@ export type GoogleAPIScopeConfig = {@Injectable()export class GoogleAPIsOauthRequestCodeStrategy extends GoogleAPIsOauthCommonStrategy {- constructor(- environmentService: EnvironmentService,- scopeConfig: GoogleAPIScopeConfig,- ) {- super(environmentService, scopeConfig);+ constructor(environmentService: EnvironmentService) {+ super(environmentService);}authenticate(req: any, options: any) {diff --git a/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts b/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.tsindex a897e86c928..472ef508ade 100644--- a/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts+++ b/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts@@ -1,3 +1,4 @@+/* eslint-disable */export const main = async (params: {a: string;b: number;diff --git a/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts b/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.tsindex 9c36df6700f..881b9f51a43 100644--- a/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts@@ -74,6 +74,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEntconst end = performance.now();+ // eslint-disable-next-line no-consoleconsole.log(`metadata query time: ${end - start} ms`);return result;diff --git a/packages/twenty-server/src/engine/strategies/aggregate-by-workspace-context-id.strategy.ts b/packages/twenty-server/src/engine/strategies/aggregate-by-workspace-context-id.strategy.tsindex 5ea58e84a5d..2a10a8a3feb 100644--- a/packages/twenty-server/src/engine/strategies/aggregate-by-workspace-context-id.strategy.ts+++ b/packages/twenty-server/src/engine/strategies/aggregate-by-workspace-context-id.strategy.ts@@ -7,6 +7,7 @@ import {import { Request } from 'express';import { jwtDecode } from 'jwt-decode';+import { isDefined } from 'twenty-shared';import { JwtPayload } from 'src/engine/core-modules/auth/types/auth-context.type';@@ -24,8 +25,10 @@ export class AggregateByWorkspaceContextIdStrategyreturn () => contextId;}- if (workspaces.has(jwtPayload.workspaceId)) {- workspaceSubTreeId = workspaces.get(jwtPayload.workspaceId)!;+ const subTreeId = workspaces.get(jwtPayload.workspaceId);++ if (isDefined(subTreeId)) {+ workspaceSubTreeId = subTreeId;} else {workspaceSubTreeId = ContextIdFactory.create();workspaces.set(jwtPayload.workspaceId, workspaceSubTreeId);diff --git a/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts b/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.tsindex 651a01ad793..e1d153f2f15 100644--- a/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts+++ b/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts@@ -1,7 +1,7 @@import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage';import { TypedReflect } from 'src/utils/typed-reflect';-export function WorkspaceCustomEntity(options = {}): ClassDecorator {+export function WorkspaceCustomEntity(): ClassDecorator {return (target) => {const gate = TypedReflect.getMetadata('workspace:gate-metadata-args',diff --git a/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts b/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.tsindex d73b61a36f6..53bc0609348 100644--- a/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts+++ b/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts@@ -1,3 +1,5 @@+import { isDefined } from 'twenty-shared';+type CacheKey = `${string}-${string}`;type AsyncFactoryCallback<T> = () => Promise<T | null>;@@ -12,13 +14,19 @@ export class CacheManager<T> {): Promise<T | null> {const [workspaceId] = cacheKey.split('-');- if (this.cache.has(cacheKey)) {- return this.cache.get(cacheKey)!;+ const cachedValue = this.cache.get(cacheKey);++ if (isDefined(cachedValue)) {+ return cachedValue;}for (const key of this.cache.keys()) {if (key.startsWith(`${workspaceId}-`)) {- await onDelete?.(this.cache.get(key)!);+ const cachedValue = this.cache.get(key);++ if (cachedValue) {+ await onDelete?.(cachedValue);+ }this.cache.delete(key);}}@@ -38,8 +46,10 @@ export class CacheManager<T> {cacheKey: CacheKey,onDelete?: (value: T) => Promise<void> | void,): Promise<void> {- if (this.cache.has(cacheKey)) {- await onDelete?.(this.cache.get(cacheKey)!);+ const cachedValue = this.cache.get(cacheKey);++ if (isDefined(cachedValue)) {+ await onDelete?.(cachedValue);this.cache.delete(cacheKey);}}diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.tsindex 5aa8a91e4ae..c3236113d34 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts@@ -89,6 +89,7 @@ export class WorkspaceMigrationRunnerService {await queryRunner.commitTransaction();} catch (error) {+ // eslint-disable-next-line no-consoleconsole.error('Error executing migration', error);await queryRunner.rollbackTransaction();throw error;diff --git a/packages/twenty-server/src/utils/generate-front-config.ts b/packages/twenty-server/src/utils/generate-front-config.tsindex be82e817b43..0b687720845 100644--- a/packages/twenty-server/src/utils/generate-front-config.ts+++ b/packages/twenty-server/src/utils/generate-front-config.ts@@ -23,6 +23,7 @@ export function generateFrontConfig(): void {const indexPath = path.join(distPath, 'index.html');if (!fs.existsSync(indexPath)) {+ // eslint-disable-next-line no-consoleconsole.log('Frontend build not found, assuming it is served independently',);diff --git a/packages/twenty-server/test/integration/graphql/codegen/index.ts b/packages/twenty-server/test/integration/graphql/codegen/index.tsindex 9f1937cae2b..b46ea9f8875 100644--- a/packages/twenty-server/test/integration/graphql/codegen/index.ts+++ b/packages/twenty-server/test/integration/graphql/codegen/index.ts@@ -58,6 +58,7 @@ const generateTestContent = (.map((f) => f.name);if (fieldNames.length === 0) {+ // eslint-disable-next-line no-consoleconsole.log(`Skipping ${queryName}: No usable fields found.`);return null;@@ -148,6 +149,7 @@ const generateTests = async (force = false) => {let totalCount = 0;if (!queryType?.fields) {+ // eslint-disable-next-line no-consoleconsole.log('No query fields found.');return;@@ -200,8 +202,10 @@ const generateTests = async (force = false) => {}}+ // eslint-disable-next-line no-consoleconsole.log(`Number of tests created: ${createdCount}/${totalCount}`);if (force) {+ // eslint-disable-next-line no-consoleconsole.log(`Number of tests updated: ${updatedCount}/${totalCount}`);}};