From e6384bb993fa6aad94d5df29bf1dad14858d6e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Colladon?= Date: Thu, 13 Jun 2024 12:34:51 +0200 Subject: [PATCH] refactor: use ES2023.Array features --- src/metadata/MetadataRepositoryImpl.ts | 2 +- src/service/inResourceHandler.ts | 6 +++--- src/service/objectTranslationHandler.ts | 6 +++--- tsconfig.json | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/metadata/MetadataRepositoryImpl.ts b/src/metadata/MetadataRepositoryImpl.ts index 9f090c95..a9242e07 100644 --- a/src/metadata/MetadataRepositoryImpl.ts +++ b/src/metadata/MetadataRepositoryImpl.ts @@ -79,7 +79,7 @@ export class MetadataRepositoryImpl implements MetadataRepository { protected searchByExtension(parts: string[]): Metadata | undefined { const extension = parse( - parts[parts.length - 1].replace(METAFILE_SUFFIX, '') + parts.at(-1)!.replace(METAFILE_SUFFIX, '') ).ext.replace(DOT, '') if (MetadataRepositoryImpl.UNSAFE_EXTENSION.has(extension)) { diff --git a/src/service/inResourceHandler.ts b/src/service/inResourceHandler.ts index 4e6cf04d..45476902 100644 --- a/src/service/inResourceHandler.ts +++ b/src/service/inResourceHandler.ts @@ -69,15 +69,15 @@ export default class ResourceHandler extends StandardHandler { } resourcePath.push(pathElement) } - const lastPathElement = resourcePath[resourcePath.length - 1] + const lastPathElement = resourcePath + .at(-1)! .replace(METAFILE_SUFFIX, '') .split(DOT) if (lastPathElement.length > 1) { lastPathElement.pop() } - resourcePath[resourcePath.length - 1] = lastPathElement.join(DOT) - return `${resourcePath.join(PATH_SEP)}` + return `${resourcePath.with(-1, lastPathElement.join(DOT)).join(PATH_SEP)}` } protected override _getMetaTypeFilePath() { diff --git a/src/service/objectTranslationHandler.ts b/src/service/objectTranslationHandler.ts index 05e7db8c..783d4f23 100644 --- a/src/service/objectTranslationHandler.ts +++ b/src/service/objectTranslationHandler.ts @@ -34,9 +34,9 @@ export default class ObjectTranslationHandler extends ResourceHandler { protected _getObjectTranslationPath() { // Return Object Translation Path for both objectTranslation and fieldTranslation // QUESTION: Why fieldTranslation element are not deployable when objectTranslation element is not in the deployed sources (even if objectTranslation file is empty) ? - return `${parse(this.line).dir}${PATH_SEP}${ - this.splittedLine[this.splittedLine.length - 2] - }.${OBJECT_TRANSLATION_META_XML_SUFFIX}` + return `${parse(this.line).dir}${PATH_SEP}${this.splittedLine.at( + -2 + )}.${OBJECT_TRANSLATION_META_XML_SUFFIX}` } protected override _delegateFileCopy() { diff --git a/tsconfig.json b/tsconfig.json index 38e38901..10b73e6d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,10 +24,11 @@ "strictNullChecks": true, "strictPropertyInitialization": true, "useUnknownInCatchVariables": true, - "skipLibCheck": true + "skipLibCheck": true, + "lib": ["ES2023", "ES2023.Array"], }, "include": [ "./src/**/*", "./src/**/*.json" - ] + ], }