[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:
@ -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) {
|
||||
|
||||
@ -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);
|
||||
},
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 (
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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]: {
|
||||
|
||||
Reference in New Issue
Block a user