[QRQC_2] No explicit any in twenty-server (#12068)

# Introduction

Added a no-explicit-any rule to the twenty-server, not applicable to
tests and integration tests folder

Related to https://github.com/twentyhq/core-team-issues/issues/975
Discussed with Charles

## In case of conflicts
Until this is approved I won't rebased and handle conflict, just need to
drop two latest commits and re run the scripts etc

## Legacy
We decided not to handle the existing lint error occurrences and
programmatically ignored them through a disable next line rule comment

## Open question
We might wanna activate the
[no-explicit-any](https://typescript-eslint.io/rules/no-explicit-any/)
`ignoreRestArgs` for our use case ?
```
    ignoreRestArgs?: boolean;
```

---------

Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
Paul Rastoin
2025-05-15 16:26:38 +02:00
committed by GitHub
parent c95c4383b4
commit a8423e8503
213 changed files with 453 additions and 4 deletions

View File

@ -78,6 +78,7 @@ export class ConfigValueConverterService {
return appValue;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return transformer.toStorage(appValue as any, options);
} catch (error) {
if (error instanceof ConfigVariableException) {

View File

@ -5,9 +5,12 @@ import {
} from 'class-validator';
export const AssertOrWarn = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
condition: (object: any, value: any) => boolean,
validationOptions?: ValidationOptions,
) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function (object: any, propertyName: string) {
registerDecorator({
name: 'AssertOrWarn',
@ -19,6 +22,7 @@ export const AssertOrWarn = (
},
constraints: [condition],
validator: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
validate(value: any, args: ValidationArguments) {
return condition(args.object, value);
},

View File

@ -3,6 +3,7 @@ import { Transform } from 'class-transformer';
export const CastToLogLevelArray = () =>
Transform(({ value }: { value: string }) => toLogLevelArray(value));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const toLogLevelArray = (value: any) => {
if (typeof value === 'string') {
const rawLogLevels = value.split(',').map((level) => level.trim());

View File

@ -3,6 +3,7 @@ import { Transform } from 'class-transformer';
export const CastToPositiveNumber = () =>
Transform(({ value }: { value: string }) => toNumber(value));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const toNumber = (value: any) => {
if (typeof value === 'number') {
return value >= 0 ? value : undefined;

View File

@ -16,8 +16,10 @@ export const IsStrictlyLowerThan = (
constraints: [property],
options: validationOptions,
validator: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
validate(value: any, args: ValidationArguments) {
const [relatedPropertyName] = args.constraints;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const relatedValue = (args.object as any)[relatedPropertyName];
return (

View File

@ -51,15 +51,18 @@ export class ConfigStorageService implements ConfigStorageInterface {
];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private logAndRethrow(message: string, error: any): never {
this.logger.error(message, error);
throw error;
}
private async convertAndSecureValue<T extends keyof ConfigVariables>(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: any,
key: T,
isDecrypt = false,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any> {
try {
const convertedValue = isDecrypt

View File

@ -237,7 +237,9 @@ export class TwentyConfigService {
private maskSensitiveValue<T extends keyof ConfigVariables>(
key: T,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any {
if (!isString(value) || !(key in CONFIG_VARIABLES_MASKING_CONFIG)) {
return value;

View File

@ -27,6 +27,7 @@ export interface TypeTransformer<T> {
export const typeTransformers: Record<
ConfigVariableType,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TypeTransformer<any>
> = {
[ConfigVariableType.BOOLEAN]: {