diff --git a/apps/chrome-devtools/src/app-devtools/theming-panel/color.helpers.ts b/apps/chrome-devtools/src/app-devtools/theming-panel/color.helpers.ts index b4302f2bf6..61445ea171 100644 --- a/apps/chrome-devtools/src/app-devtools/theming-panel/color.helpers.ts +++ b/apps/chrome-devtools/src/app-devtools/theming-panel/color.helpers.ts @@ -26,7 +26,7 @@ export enum PaletteVariant { */ export const DEFAULT_PALETTE_VARIANT: PaletteVariant = PaletteVariant.V500; -const SATURATION_VALUES: Record = { +const SATURATION_VALUES = { 50: 0.91, 100: 0.98, 200: 0.96, @@ -41,9 +41,9 @@ const SATURATION_VALUES: Record = { A200: 1, A400: 1, A700: 1 -}; +} as const satisfies Record; -const LIGHTNESS_VALUES: Record = { +const LIGHTNESS_VALUES = { 50: 0.12, 100: 0.3, 200: 0.5, @@ -58,7 +58,7 @@ const LIGHTNESS_VALUES: Record = { A200: 0.64, A400: 0.49, A700: 0.44 -}; +} as const satisfies Record; /** * Returns palette colors from one color diff --git a/apps/chrome-devtools/src/services/state.service.ts b/apps/chrome-devtools/src/services/state.service.ts index 3f6429c675..23849bf726 100644 --- a/apps/chrome-devtools/src/services/state.service.ts +++ b/apps/chrome-devtools/src/services/state.service.ts @@ -207,11 +207,11 @@ export class StateService { ...(override ? undefined : state.stylingVariables), ...changes.stylingVariables }).filter((entry): entry is [string, string] => entry[1] !== null)); - const stateOverrides: StateOverride = { + const stateOverrides = { configurations: Object.keys(configurationOverrides).length > 0 ? configurationOverrides : undefined, localizations: Object.keys(localizationOverrides || {}).length > 0 ? localizationOverrides : undefined, stylingVariables: Object.keys(stylingOverrides).length > 0 ? stylingOverrides : undefined - }; + } as const satisfies StateOverride; return { ...state, ...stateOverrides diff --git a/apps/showcase/e2e-playwright/sanity/lighthouse-sanity.e2e.ts b/apps/showcase/e2e-playwright/sanity/lighthouse-sanity.e2e.ts index 909fab48eb..fe2dfc806d 100644 --- a/apps/showcase/e2e-playwright/sanity/lighthouse-sanity.e2e.ts +++ b/apps/showcase/e2e-playwright/sanity/lighthouse-sanity.e2e.ts @@ -14,7 +14,7 @@ import { } from '../../src/app/app.fixture'; const baseUrl = process.env.PLAYWRIGHT_TARGET_URL || 'http://localhost:4200/'; -const lighthouseConfig: playwrightLighthouseConfig = { +const lighthouseConfig = { thresholds: { // Disable performance measurement because it is too unreliable in the current setup performance: 0, @@ -32,7 +32,7 @@ const lighthouseConfig: playwrightLighthouseConfig = { directory: 'playwright-reports/lighthouse' }, port: 9222 -}; +} as const satisfies playwrightLighthouseConfig; const performAudit = async (name: string, page: Page | string, testInfo: TestInfo) => { const { playAudit } = await import('playwright-lighthouse'); diff --git a/apps/showcase/src/app/app.module.ts b/apps/showcase/src/app/app.module.ts index 33e24e41c4..f4c1f04c93 100644 --- a/apps/showcase/src/app/app.module.ts +++ b/apps/showcase/src/app/app.module.ts @@ -91,14 +91,14 @@ import { AppComponent, } from './app.component'; -const runtimeChecks: Partial = { +const runtimeChecks = { strictActionImmutability: false, strictActionSerializability: false, strictActionTypeUniqueness: !isDevMode(), strictActionWithinNgZone: !isDevMode(), strictStateImmutability: !isDevMode(), strictStateSerializability: false -}; +} as const satisfies Partial; registerLocaleData(localeEN, 'en-GB'); registerLocaleData(localeFR, 'fr-FR'); diff --git a/apps/showcase/src/app/configuration/configuration.component.ts b/apps/showcase/src/app/configuration/configuration.component.ts index 08629b722f..19e8d1af8a 100644 --- a/apps/showcase/src/app/configuration/configuration.component.ts +++ b/apps/showcase/src/app/configuration/configuration.component.ts @@ -33,7 +33,7 @@ import { ConfigurationPresConfig, } from '../../components/showcase/configuration/configuration-pres.config'; -const CONFIG_OVERRIDE: ConfigurationPresConfig = { +const CONFIG_OVERRIDE = { inXDays: 30, destinations: [ { cityName: 'Manchester', available: true }, @@ -41,7 +41,7 @@ const CONFIG_OVERRIDE: ConfigurationPresConfig = { { cityName: 'Dallas', available: true } ], shouldProposeRoundTrip: true -}; +} as const satisfies ConfigurationPresConfig; @O3rComponent({ componentType: 'Page' }) @Component({ diff --git a/apps/showcase/src/app/rules-engine/rules-engine.component.ts b/apps/showcase/src/app/rules-engine/rules-engine.component.ts index 3bb45a4fcb..e78adb6692 100644 --- a/apps/showcase/src/app/rules-engine/rules-engine.component.ts +++ b/apps/showcase/src/app/rules-engine/rules-engine.component.ts @@ -53,13 +53,11 @@ import { import { CurrentTimeFactsService, dateInNextMinutes, - Operator, Rule, RulesEngineDevtoolsModule, RulesEngineRunnerModule, RulesEngineRunnerService, Ruleset, - UnaryOperator, } from '@o3r/rules-engine'; import { firstValueFrom, @@ -137,8 +135,8 @@ export class RulesEngineComponent implements AfterViewInit { inject(AssetRulesEngineActionHandler), inject(LocalizationRulesEngineActionHandler) ); - this.rulesEngineService.engine.upsertOperators([duringSummer] as UnaryOperator[]); - this.rulesEngineService.engine.upsertOperators([dateInNextMinutes] as Operator[]); + this.rulesEngineService.engine.upsertOperators([duringSummer]); + this.rulesEngineService.engine.upsertOperators([dateInNextMinutes]); inject(TripFactsService).register(); const currentTimeFactsService = inject(CurrentTimeFactsService); currentTimeFactsService.register(); diff --git a/apps/showcase/src/components/showcase/configuration/configuration-pres.config.ts b/apps/showcase/src/components/showcase/configuration/configuration-pres.config.ts index 6b24cd05be..3c8f0fca94 100644 --- a/apps/showcase/src/components/showcase/configuration/configuration-pres.config.ts +++ b/apps/showcase/src/components/showcase/configuration/configuration-pres.config.ts @@ -45,7 +45,7 @@ export interface ConfigurationPresConfig extends Configuration { shouldProposeRoundTrip: boolean; } -export const CONFIGURATION_PRES_DEFAULT_CONFIG: ConfigurationPresConfig = { +export const CONFIGURATION_PRES_DEFAULT_CONFIG: Readonly = { inXDays: 7, destinations: [ { cityName: 'London', available: true }, @@ -53,6 +53,6 @@ export const CONFIGURATION_PRES_DEFAULT_CONFIG: ConfigurationPresConfig = { { cityName: 'New-York', available: false } ], shouldProposeRoundTrip: false -}; +} as const; export const CONFIGURATION_PRES_CONFIG_ID = computeItemIdentifier('ConfigurationPresConfig', 'showcase'); diff --git a/apps/showcase/src/components/showcase/localization/localization-pres.translation.ts b/apps/showcase/src/components/showcase/localization/localization-pres.translation.ts index 82d13183c1..5605c6721f 100644 --- a/apps/showcase/src/components/showcase/localization/localization-pres.translation.ts +++ b/apps/showcase/src/components/showcase/localization/localization-pres.translation.ts @@ -33,7 +33,7 @@ export interface LocalizationPresTranslation extends Translation { cityName: string; } -export const translations: LocalizationPresTranslation = { +export const translations: Readonly = { welcome: 'o3r-localization-pres.welcome', welcomeWithCityName: 'o3r-localization-pres.welcomeWithCityName', question: 'o3r-localization-pres.question', @@ -41,4 +41,4 @@ export const translations: LocalizationPresTranslation = { departureLabel: 'o3r-localization-pres.departureLabel', cityName: 'o3r-localization-pres.cityName', destinationPlaceholder: 'o3r-localization-pres.destinationPlaceholder' -}; +} as const; diff --git a/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.config.ts b/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.config.ts index 015dfc1abf..0c67f2aeec 100644 --- a/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.config.ts +++ b/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.config.ts @@ -34,7 +34,7 @@ export interface RulesEnginePresConfig extends Configuration { shouldProposeRoundTrip: boolean; } -export const RULES_ENGINE_PRES_DEFAULT_CONFIG: RulesEnginePresConfig = { +export const RULES_ENGINE_PRES_DEFAULT_CONFIG: Readonly = { inXDays: 7, destinations: [ { cityCode: 'LON', available: true }, @@ -42,6 +42,6 @@ export const RULES_ENGINE_PRES_DEFAULT_CONFIG: RulesEnginePresConfig = { { cityCode: 'NYC', available: false } ], shouldProposeRoundTrip: false -}; +} as const; export const RULES_ENGINE_PRES_CONFIG_ID = computeItemIdentifier('RulesEnginePresConfig', 'showcase'); diff --git a/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.translation.ts b/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.translation.ts index 2c1f5d3cb2..63bb93155f 100644 --- a/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.translation.ts +++ b/apps/showcase/src/components/showcase/rules-engine/rules-engine-pres.translation.ts @@ -36,7 +36,7 @@ export interface RulesEnginePresTranslation extends Translation { */ returnLabel: string; } -export const translations: RulesEnginePresTranslation = { +export const translations: Readonly = { welcome: 'o3r-rules-engine-pres.welcome', welcomeWithCityName: 'o3r-rules-engine-pres.welcomeWithCityName', question: 'o3r-rules-engine-pres.question', @@ -45,4 +45,4 @@ export const translations: RulesEnginePresTranslation = { cityName: 'o3r-rules-engine-pres.cityName', returnLabel: 'o3r-rules-engine-pres.returnLabel', destinationPlaceholder: 'o3r-rules-engine-pres.destinationPlaceholder' -}; +} as const; diff --git a/apps/showcase/src/components/showcase/sdk/sdk-pres.component.ts b/apps/showcase/src/components/showcase/sdk/sdk-pres.component.ts index 371a218314..8fae59452c 100644 --- a/apps/showcase/src/components/showcase/sdk/sdk-pres.component.ts +++ b/apps/showcase/src/components/showcase/sdk/sdk-pres.component.ts @@ -162,14 +162,14 @@ export class SdkPresComponent { * Call the API to create a new pet */ public async create() { - const pet: Pet = { + const pet = { id: this.getNextId(), name: this.petName(), category: { name: 'otter' }, tags: [{ name: 'otter' }], status: 'available', photoUrls: this.petName() ? [this.petImage()] : [] - }; + } as const satisfies Pet; this.isLoading.set(true); await this.petStoreApi.addPet({ @@ -179,7 +179,7 @@ export class SdkPresComponent { const filePath = `${this.baseUrl}${pet.photoUrls[0]}`; const blob = await (await fetch(filePath)).blob(); await this.petStoreApi.uploadFile({ - petId: pet.id!, + petId: pet.id, body: new File([blob], filePath, { type: blob.type }) }); } diff --git a/packages/@ama-sdk/client-angular/src/api-angular-client.ts b/packages/@ama-sdk/client-angular/src/api-angular-client.ts index e9dc846498..f3589f6152 100644 --- a/packages/@ama-sdk/client-angular/src/api-angular-client.ts +++ b/packages/@ama-sdk/client-angular/src/api-angular-client.ts @@ -41,13 +41,13 @@ export interface BaseApiAngularClientOptions extends BaseApiClientOptions { export interface BaseApiAngularClientConstructor extends PartialExcept { } -const DEFAULT_OPTIONS: Omit = { +const DEFAULT_OPTIONS = { replyPlugins: [new ReviverReply(), new ExceptionReply()], angularPlugins: [], requestPlugins: [], enableTokenization: false, disableFallback: false -}; +} as const satisfies Omit; /** Client to process the call to the API using Angular API */ export class ApiAngularClient implements ApiClient { diff --git a/packages/@ama-sdk/client-beacon/src/api-beacon-client.ts b/packages/@ama-sdk/client-beacon/src/api-beacon-client.ts index b81c94b1ea..316c84cf7d 100644 --- a/packages/@ama-sdk/client-beacon/src/api-beacon-client.ts +++ b/packages/@ama-sdk/client-beacon/src/api-beacon-client.ts @@ -25,11 +25,11 @@ export interface BaseApiBeaconClientOptions extends BaseApiClientOptions { export interface BaseApiBeaconClientConstructor extends PartialExcept, 'basePath'> { } -const DEFAULT_OPTIONS: Omit = { +const DEFAULT_OPTIONS = { replyPlugins: [] as never[], requestPlugins: [], enableTokenization: false -}; +} as const satisfies Omit; /** * Determine if the given value is a promise diff --git a/packages/@ama-sdk/client-fetch/src/api-fetch-client.ts b/packages/@ama-sdk/client-fetch/src/api-fetch-client.ts index cd460527e0..3b80d4f7ba 100644 --- a/packages/@ama-sdk/client-fetch/src/api-fetch-client.ts +++ b/packages/@ama-sdk/client-fetch/src/api-fetch-client.ts @@ -38,13 +38,13 @@ export interface BaseApiFetchClientOptions extends BaseApiClientOptions { export interface BaseApiFetchClientConstructor extends PartialExcept { } -const DEFAULT_OPTIONS: Omit = { +const DEFAULT_OPTIONS = { replyPlugins: [new ReviverReply(), new ExceptionReply()], fetchPlugins: [], requestPlugins: [], enableTokenization: false, disableFallback: false -}; +} as const satisfies Omit; /** Client to process the call to the API using Fetch API */ export class ApiFetchClient implements ApiClient { diff --git a/packages/@ama-sdk/client-fetch/src/plugins/perf-metric/perf-metric.fetch.ts b/packages/@ama-sdk/client-fetch/src/plugins/perf-metric/perf-metric.fetch.ts index 44b362e2d1..e201a219e1 100644 --- a/packages/@ama-sdk/client-fetch/src/plugins/perf-metric/perf-metric.fetch.ts +++ b/packages/@ama-sdk/client-fetch/src/plugins/perf-metric/perf-metric.fetch.ts @@ -148,12 +148,12 @@ export class PerformanceMetricPlugin implements FetchPlugin { const markId = v4(); const perfMark = this.performance?.mark(this.getPerformanceTag('start', markId)) || undefined; const startTime = perfMark?.startTime ?? this.getTime(); - const mark: Mark = { + const mark = { markId, url, requestOptions, startTime - }; + } as const satisfies Mark; this.openMarks[markId] = mark; if (this.onMarkOpen) { void this.onMarkOpen(mark); diff --git a/packages/@ama-sdk/core/src/plugins/raw-response-info/raw-response-info.reply.ts b/packages/@ama-sdk/core/src/plugins/raw-response-info/raw-response-info.reply.ts index 9c2dd560be..5e2132a4de 100644 --- a/packages/@ama-sdk/core/src/plugins/raw-response-info/raw-response-info.reply.ts +++ b/packages/@ama-sdk/core/src/plugins/raw-response-info/raw-response-info.reply.ts @@ -51,13 +51,13 @@ export class RawResponseInfoReply implem return data; } - const responseInfo: RawResponseReply = { + const responseInfo = { responseInfo: { ...context.response, apiType: context.apiType, apiName: context.apiName } - }; + } as const satisfies RawResponseReply; return data ? Object.assign(data, responseInfo) : responseInfo as V & RawResponseReply; } diff --git a/packages/@ama-sdk/core/src/plugins/reviver/reviver.reply.ts b/packages/@ama-sdk/core/src/plugins/reviver/reviver.reply.ts index e0c87d389f..75d1fc0f2a 100644 --- a/packages/@ama-sdk/core/src/plugins/reviver/reviver.reply.ts +++ b/packages/@ama-sdk/core/src/plugins/reviver/reviver.reply.ts @@ -18,10 +18,10 @@ export class ReviverReply implements ReplyPlugin(context: ReplyPluginContext): PluginRunner { - const options: ReviverOptions = { + const options = { logger: context.logger, ...this.options - }; + } as const satisfies ReviverOptions; return { transform: (data?: V) => { diff --git a/packages/@ama-sdk/core/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.ts b/packages/@ama-sdk/core/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.ts index 75dd008ddb..7313fd7b4c 100644 --- a/packages/@ama-sdk/core/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.ts +++ b/packages/@ama-sdk/core/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.ts @@ -24,10 +24,10 @@ export interface SimpleApiKeyAuthenticationRequestOptions { /** * Default values of optional parameters */ -const DEFAULT_OPTION: SimpleApiKeyAuthenticationRequestOptions = { +const DEFAULT_OPTION = { apiKeyHeader: 'x-api-key', contextHeader: 'ama-ctx' -}; +} as const satisfies SimpleApiKeyAuthenticationRequestOptions; /** * Plugin to handle the Simple API key authentication with Apigee. diff --git a/packages/@ama-sdk/core/src/utils/generic-api.ts b/packages/@ama-sdk/core/src/utils/generic-api.ts index 711fdf8762..74a7148d3f 100644 --- a/packages/@ama-sdk/core/src/utils/generic-api.ts +++ b/packages/@ama-sdk/core/src/utils/generic-api.ts @@ -47,16 +47,16 @@ export class GenericApi implements Api { */ public async request(requestOptions: GenericRequestOptions): Promise { const metadataHeaderAccept = requestOptions.metadata?.headerAccept || 'application/json'; - const headers: { [key: string]: string | undefined } = { + const headers = { 'Content-Type': requestOptions.metadata?.headerContentType || 'application/json', ...(metadataHeaderAccept ? { Accept: metadataHeaderAccept } : {}) - }; + } as const satisfies RequestOptionsParameters['headers']; - const requestParameters: RequestOptionsParameters = { + const requestParameters = { api: this, headers, ...requestOptions - }; + } as const satisfies RequestOptionsParameters; const options = await this.client.getRequestOptions(requestParameters); const url = this.client.prepareUrl(options.basePath, options.queryParams); diff --git a/packages/@ama-sdk/schematics/schematics/code-generator/code-generator.ts b/packages/@ama-sdk/schematics/schematics/code-generator/code-generator.ts index 8e03eba312..6de758b8f4 100644 --- a/packages/@ama-sdk/schematics/schematics/code-generator/code-generator.ts +++ b/packages/@ama-sdk/schematics/schematics/code-generator/code-generator.ts @@ -49,7 +49,7 @@ export abstract class CodeGenerator { */ private getTaskConfiguration(options: Partial): TaskConfigurationGenerator { const name = this.generatorName; - const opts: T = { ...this.getDefaultOptions(), ...options }; + const opts = { ...this.getDefaultOptions(), ...options } as const satisfies T; return new (class implements TaskConfigurationGenerator { public toConfiguration(): TaskConfiguration { return { diff --git a/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts b/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts index 54f97be7cc..dd8d359171 100644 --- a/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts +++ b/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts @@ -96,11 +96,11 @@ export class OpenApiCliGenerator extends CodeGenerator { if (!generatorOptions) { return Promise.reject(new Error('Missing options to run open api generator')); } - const spawnOptions: SpawnOptions = { + const spawnOptions = { stdio: 'inherit', shell: true, cwd: rootDirectory - }; + } as const satisfies SpawnOptions; if (generatorOptions.generatorVersion) { await this.runInstallOpenApiGenerator(generatorOptions.generatorVersion, spawnOptions); } diff --git a/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts b/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts index 6071b6909d..d308a68da9 100644 --- a/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts +++ b/packages/@ama-sdk/schematics/schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts @@ -62,7 +62,7 @@ export type OpenApiCliOptions = CodegenTaskOptions & { /** * Default options to run our custom typescript generator */ -export const defaultTypescriptGeneratorOptions: OpenApiCliOptions = { +export const defaultTypescriptGeneratorOptions: Readonly = { generatorVersion: '', generatorName: 'typescriptFetch', generatorCustomPath: path.join(__dirname, '..', '..', 'typescript', 'core', 'openapi-codegen-typescript', 'target', 'typescriptFetch-openapi-generator.jar'), @@ -72,4 +72,4 @@ export const defaultTypescriptGeneratorOptions: OpenApiCliOptions = { globalProperty: '', generatorKey: '', openapiNormalizer: '' -}; +} as const; diff --git a/packages/@ama-sdk/schematics/schematics/code-generator/swagger-java-generator/swagger-java.generator.ts b/packages/@ama-sdk/schematics/schematics/code-generator/swagger-java-generator/swagger-java.generator.ts index c34320c1d7..1cd79455e8 100644 --- a/packages/@ama-sdk/schematics/schematics/code-generator/swagger-java-generator/swagger-java.generator.ts +++ b/packages/@ama-sdk/schematics/schematics/code-generator/swagger-java-generator/swagger-java.generator.ts @@ -28,11 +28,11 @@ export class SwaggerJavaGenerator extends CodeGenerator = { apiTests: true, targetFolder: './', cliFilename: 'swagger-codegen-cli.jar', @@ -41,4 +41,4 @@ export const defaultOptions: JavaGeneratorTaskOptions = { specPath: 'swagger-spec.yaml', outputPath: '.', specConfigPath: '' -}; +} as const; diff --git a/packages/@ama-sdk/schematics/schematics/migrate/index.ts b/packages/@ama-sdk/schematics/schematics/migrate/index.ts index 625a0bf0e8..10badd22db 100644 --- a/packages/@ama-sdk/schematics/schematics/migrate/index.ts +++ b/packages/@ama-sdk/schematics/schematics/migrate/index.ts @@ -32,7 +32,7 @@ import { MigrateSchematicsSchemaOptions, } from './schema'; -const tsMigrationMap: MigrationRulesMap = { +const tsMigrationMap = { '~10.3.2': updateOpenApiVersionInProject(), '11.0.*': [ updateRegenScript @@ -40,7 +40,7 @@ const tsMigrationMap: MigrationRulesMap = { '11.4.0-alpha.0': [ updateV114 ] -}; +} as const satisfies MigrationRulesMap; /** * Facilitate the migration of a version to another by the run of migration rules diff --git a/packages/@o3r/analytics/plugins/webpack/build-metrics/build-stats.plugin.ts b/packages/@o3r/analytics/plugins/webpack/build-metrics/build-stats.plugin.ts index 85d6fc29ea..225fb3b074 100644 --- a/packages/@o3r/analytics/plugins/webpack/build-metrics/build-stats.plugin.ts +++ b/packages/@o3r/analytics/plugins/webpack/build-metrics/build-stats.plugin.ts @@ -30,12 +30,12 @@ export interface BuildStatsPluginOptions { sessionId: string; } -const defaultOptions: BuildStatsPluginOptions = { +const defaultOptions = { threshold: 50, appName: 'Test', reporters: [console], sessionId: randomUUID() -}; +} as const satisfies BuildStatsPluginOptions; const PLUGIN_NAME = 'OtterBuildStatsPlugin'; @@ -109,7 +109,7 @@ export class BuildStatsPlugin implements WebpackPluginInstance { if (stats.compilation.endTime === undefined || stats.compilation.startTime === undefined) { return; } - const buildData: ReportData = { + const buildData = { compileTime: stats.compilation.endTime - stats.compilation.startTime, buildType: compiler.modifiedFiles?.size ? 'watch' : 'full', loadersAndCompilation: this.timingData, @@ -123,7 +123,7 @@ export class BuildStatsPlugin implements WebpackPluginInstance { hostName: os.hostname(), appName: this.options.appName, sessionId: this.options.sessionId - }; + } as const satisfies ReportData; this.reportData(buildData); }); } @@ -174,7 +174,7 @@ export class BuildStatsPlugin implements WebpackPluginInstance { private filterTimingsForThreshold(): { [key: string]: number } { const filtered: { [key: string]: number } = {}; - const limit = this.options.threshold ?? defaultOptions.threshold!; + const limit = this.options.threshold ?? defaultOptions.threshold; for (const key of Object.keys(this.pluginDurations)) { if (this.pluginDurations[key] > limit) { filtered[key] = this.pluginDurations[key]; diff --git a/packages/@o3r/analytics/src/services/event-track/event-track.service.ts b/packages/@o3r/analytics/src/services/event-track/event-track.service.ts index 83796d1ac5..6ffb069658 100644 --- a/packages/@o3r/analytics/src/services/event-track/event-track.service.ts +++ b/packages/@o3r/analytics/src/services/event-track/event-track.service.ts @@ -44,12 +44,12 @@ import { } from './event-track.configuration'; /** The initial value of the performance measurements */ -export const performanceMarksInitialState: PerfEventPayload = { +export const performanceMarksInitialState: Readonly = { page: '', perceived: {}, serverCalls: [], customMarks: [] -}; +} as const; /** * Service to expose the tracked events as streams. Also provide a way to activate/deactivate the tracking @@ -262,7 +262,7 @@ export class EventTrackService { */ public async addCustomMark(label: string) { const timing = await this.getTiming(); - const customMark: CustomEventMarks = { label, timing }; + const customMark = { label, timing } as const satisfies CustomEventMarks; const perf = { ...this.performancePayload, customMarks: this.performancePayload.customMarks.concat(customMark) }; this.performancePayload = perf; } @@ -312,7 +312,7 @@ export class EventTrackService { return -1; } const startTime = Math.round(window.performance.now()); - const customMark: CustomEventMarks = { label, timing: { startTime } }; + const customMark = { label, timing: { startTime } } as const satisfies CustomEventMarks; const perf = { ...this.performancePayload, customMarks: this.performancePayload.customMarks.concat(customMark) }; this.performancePayload = perf; return this.performancePayload.customMarks.length - 1; diff --git a/packages/@o3r/analytics/src/stores/event-track/event-track.sync.ts b/packages/@o3r/analytics/src/stores/event-track/event-track.sync.ts index 4a1fd0b479..bb05ab5ebc 100644 --- a/packages/@o3r/analytics/src/stores/event-track/event-track.sync.ts +++ b/packages/@o3r/analytics/src/stores/event-track/event-track.sync.ts @@ -8,8 +8,8 @@ import { EventTrackState, } from './event-track.state'; -export const eventTrackStorageSync: Serializer = { +export const eventTrackStorageSync: Readonly> = { deserialize: (rawObject: any) => { return rawObject ? rawObject as EventTrackState : eventTrackInitialState; } -}; +} as const; diff --git a/packages/@o3r/application/src/devkit/application-devtools.token.ts b/packages/@o3r/application/src/devkit/application-devtools.token.ts index 5e4bd7150e..e38dbbe25e 100644 --- a/packages/@o3r/application/src/devkit/application-devtools.token.ts +++ b/packages/@o3r/application/src/devkit/application-devtools.token.ts @@ -5,8 +5,8 @@ import { ApplicationDevtoolsServiceOptions, } from './application-devkit.interface'; -export const OTTER_APPLICATION_DEVTOOLS_DEFAULT_OPTIONS: ApplicationDevtoolsServiceOptions = { +export const OTTER_APPLICATION_DEVTOOLS_DEFAULT_OPTIONS: Readonly = { isActivatedOnBootstrap: false -}; +} as const; -export const OTTER_APPLICATION_DEVTOOLS_OPTIONS: InjectionToken = new InjectionToken('Otter Application Devtools options'); +export const OTTER_APPLICATION_DEVTOOLS_OPTIONS = new InjectionToken('Otter Application Devtools options'); diff --git a/packages/@o3r/components/builders/component-extractor/helpers/component/component.extractor.ts b/packages/@o3r/components/builders/component-extractor/helpers/component/component.extractor.ts index ec7139852c..9b5b1209a6 100644 --- a/packages/@o3r/components/builders/component-extractor/helpers/component/component.extractor.ts +++ b/packages/@o3r/components/builders/component-extractor/helpers/component/component.extractor.ts @@ -276,10 +276,10 @@ export class ComponentExtractor { } else { this.logger.warn(message); } - const configWithoutIncompatibleProperties: ComponentConfigOutput = { + const configWithoutIncompatibleProperties = { ...config, properties: propertiesWithDefaultValue - }; + } as const satisfies ComponentConfigOutput; return acc.concat(configWithoutIncompatibleProperties); } diff --git a/packages/@o3r/components/builders/metadata-check/helpers/config-metadata-comparison.helper.ts b/packages/@o3r/components/builders/metadata-check/helpers/config-metadata-comparison.helper.ts index c524e46415..d7f251f1e5 100644 --- a/packages/@o3r/components/builders/metadata-check/helpers/config-metadata-comparison.helper.ts +++ b/packages/@o3r/components/builders/metadata-check/helpers/config-metadata-comparison.helper.ts @@ -52,9 +52,9 @@ const isMigrationConfigurationDataMatch = (config: ComponentConfigOutput, migrat /** * Comparator used to compare one version of config metadata with another */ -export const configMetadataComparator: MetadataComparator = { +export const configMetadataComparator: Readonly> = { getArray: getConfigurationArray, getIdentifier: getConfigurationPropertyName, isRelevantContentType, isMigrationDataMatch: isMigrationConfigurationDataMatch -}; +} as const; diff --git a/packages/@o3r/components/schematics/ng-add/index.ts b/packages/@o3r/components/schematics/ng-add/index.ts index 715c2bd372..7919d537f8 100644 --- a/packages/@o3r/components/schematics/ng-add/index.ts +++ b/packages/@o3r/components/schematics/ng-add/index.ts @@ -66,14 +66,14 @@ function ngAddFn(options: NgAddSchematicsSchema): Rule { }; return acc; }, getPackageInstallConfig(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion)); - const devDependencies: Record = { + const devDependencies = { chokidar: { inManifest: [{ range: packageJson.peerDependencies.chokidar, types: [NodeDependencyType.Dev] }] } - }; + } as const satisfies Record; const rule = chain([ removePackages(['@otter/components']), setupDependencies({ diff --git a/packages/@o3r/components/src/devkit/components-devtools.token.ts b/packages/@o3r/components/src/devkit/components-devtools.token.ts index e32af65dfb..7050f5ad05 100644 --- a/packages/@o3r/components/src/devkit/components-devtools.token.ts +++ b/packages/@o3r/components/src/devkit/components-devtools.token.ts @@ -5,8 +5,8 @@ import { ComponentsDevtoolsServiceOptions, } from './components-devkit.interface'; -export const OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS: ComponentsDevtoolsServiceOptions = { +export const OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS: Readonly = { isActivatedOnBootstrap: false -}; +} as const; -export const OTTER_COMPONENTS_DEVTOOLS_OPTIONS: InjectionToken = new InjectionToken('Otter Components Devtools options'); +export const OTTER_COMPONENTS_DEVTOOLS_OPTIONS = new InjectionToken('Otter Components Devtools options'); diff --git a/packages/@o3r/components/src/stores/placeholder-request/placeholder-request.sync.ts b/packages/@o3r/components/src/stores/placeholder-request/placeholder-request.sync.ts index 744ca59de7..9061481340 100644 --- a/packages/@o3r/components/src/stores/placeholder-request/placeholder-request.sync.ts +++ b/packages/@o3r/components/src/stores/placeholder-request/placeholder-request.sync.ts @@ -24,7 +24,7 @@ export const placeholderRequestStorageDeserializer = (rawObject: any) => { return storeObject; }; -export const placeholderRequestStorageSync: Serializer = { +export const placeholderRequestStorageSync: Readonly> = { serialize: placeholderRequestStorageSerializer, deserialize: placeholderRequestStorageDeserializer -}; +} as const; diff --git a/packages/@o3r/components/src/stores/placeholder-template/placeholder-template.sync.ts b/packages/@o3r/components/src/stores/placeholder-template/placeholder-template.sync.ts index 38df7bf8fe..6d8cbf68df 100644 --- a/packages/@o3r/components/src/stores/placeholder-template/placeholder-template.sync.ts +++ b/packages/@o3r/components/src/stores/placeholder-template/placeholder-template.sync.ts @@ -21,6 +21,6 @@ export const placeholderTemplateStorageDeserializer = (rawObject: any) => { return storeObject; }; -export const placeholderTemplateStorageSync: Serializer = { +export const placeholderTemplateStorageSync: Readonly> = { deserialize: placeholderTemplateStorageDeserializer -}; +} as const; diff --git a/packages/@o3r/configuration/src/devkit/configuration-devtools.token.ts b/packages/@o3r/configuration/src/devkit/configuration-devtools.token.ts index a3ffc14c79..dcf99bbbeb 100644 --- a/packages/@o3r/configuration/src/devkit/configuration-devtools.token.ts +++ b/packages/@o3r/configuration/src/devkit/configuration-devtools.token.ts @@ -5,11 +5,11 @@ import { ConfigurationDevtoolsServiceOptions, } from './configuration-devtools.interface'; -export const OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS: ConfigurationDevtoolsServiceOptions = { +export const OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS: Readonly = { defaultLibraryName: '@o3r/components', defaultJsonFilename: 'partial-static-config.json', isActivatedOnBootstrap: false, isActivatedOnBootstrapWhenCMSContext: true -}; +} as const; export const OTTER_CONFIGURATION_DEVTOOLS_OPTIONS = new InjectionToken('Otter Configuration Devtools options'); diff --git a/packages/@o3r/core/builders/app-version/index.ts b/packages/@o3r/core/builders/app-version/index.ts index 80fa7debdb..d4540ebce0 100644 --- a/packages/@o3r/core/builders/app-version/index.ts +++ b/packages/@o3r/core/builders/app-version/index.ts @@ -13,15 +13,15 @@ import { export * from './schema'; -const PACKAGE_JSON_NOT_FOUND: BuilderOutput = { +const PACKAGE_JSON_NOT_FOUND = { error: 'package.json not found', success: false -}; +} as const satisfies BuilderOutput; -const PACKAGE_JSON_INCORRECT: BuilderOutput = { +const PACKAGE_JSON_INCORRECT = { error: 'package.json incorrect', success: false -}; +} as const satisfies BuilderOutput; /** Maximum number of steps */ const STEP_NUMBER = 2; diff --git a/packages/@o3r/core/schematics/ng-add/index.ts b/packages/@o3r/core/schematics/ng-add/index.ts index 3b3008977b..2891a5a084 100644 --- a/packages/@o3r/core/schematics/ng-add/index.ts +++ b/packages/@o3r/core/schematics/ng-add/index.ts @@ -85,7 +85,7 @@ function ngAddFn(options: NgAddSchematicsSchema): Rule { async (t, c) => { const { preset, externalPresets, ...forwardOptions } = options; const presetRunner = await presets[preset]({ projectName: forwardOptions.projectName, forwardOptions }); - const externalPresetRunner = externalPresets ? await getExternalPreset(externalPresets, t, c)?.({ projectName: forwardOptions.projectName, forwardOptions }) : undefined; + const externalPresetRunner = externalPresets ? await getExternalPreset(externalPresets, t, c)({ projectName: forwardOptions.projectName, forwardOptions }) : undefined; const modules = [...new Set([...(presetRunner.modules || []), ...(externalPresetRunner?.modules || [])])]; if (modules.length > 0) { c.logger.info(`The following modules will be installed: ${modules.join(', ')}`); diff --git a/packages/@o3r/core/schematics/page/index.ts b/packages/@o3r/core/schematics/page/index.ts index 9d1808a9f9..0410a96c1f 100644 --- a/packages/@o3r/core/schematics/page/index.ts +++ b/packages/@o3r/core/schematics/page/index.ts @@ -229,11 +229,11 @@ function ngGeneratePageFn(options: NgGeneratePageSchematicsSchema): Rule { */ const updateAppRoutingModule: Rule = (tree: Tree, context: SchematicContext) => { const indexFilePath = path.posix.join(strings.dasherize(options.scope), strings.dasherize(options.name), 'index'); - const route: Route = { + const route = { path: strings.dasherize(options.name), import: `./${indexFilePath.replace(/[/\\]/g, '/')}`, module: `${pageName}${options.standalone ? 'Component' : 'Module'}` - }; + } as const satisfies Route; if (options.appRoutingModulePath) { return insertRoute(tree, context, options.appRoutingModulePath, route, options.standalone); } diff --git a/packages/@o3r/core/schematics/store/entity-async/index.ts b/packages/@o3r/core/schematics/store/entity-async/index.ts index 0ff5ffdd4b..9566747342 100644 --- a/packages/@o3r/core/schematics/store/entity-async/index.ts +++ b/packages/@o3r/core/schematics/store/entity-async/index.ts @@ -46,7 +46,7 @@ function ngGenerateEntityAsyncStoreFn(options: NgGenerateEntityAsyncStoreSchemat options.modelIdPropName = options.modelIdPropName?.trim(); // Add extra formatted properties - const formattedProperties: ExtraFormattedProperties = { + const formattedProperties = { isAsync: true, isEntity: true, storeName: strings.classify(options.storeName), @@ -59,7 +59,7 @@ function ngGenerateEntityAsyncStoreFn(options: NgGenerateEntityAsyncStoreSchemat modelIdPropName: options.modelIdPropName || 'id', reviverModelName: `revive${options.modelName}`, fileName: strings.dasherize(options.storeName) - }; + } as const satisfies ExtraFormattedProperties; let currentStoreIndex = ''; const barrelPath = path.join(destination, options.storeName, 'index.ts'); if (tree.exists(barrelPath)) { diff --git a/packages/@o3r/core/schematics/store/entity-sync/index.ts b/packages/@o3r/core/schematics/store/entity-sync/index.ts index 357e71bfdc..3542bb68bf 100644 --- a/packages/@o3r/core/schematics/store/entity-sync/index.ts +++ b/packages/@o3r/core/schematics/store/entity-sync/index.ts @@ -45,7 +45,7 @@ function ngGenerateEntitySyncStoreFn(options: NgGenerateEntitySyncStoreSchematic options.modelIdPropName = options.modelIdPropName?.trim(); // Add extra formatted properties - const formattedProperties: ExtraFormattedProperties = { + const formattedProperties = { isAsync: false, isEntity: true, storeName: strings.classify(options.storeName), @@ -58,7 +58,7 @@ function ngGenerateEntitySyncStoreFn(options: NgGenerateEntitySyncStoreSchematic modelIdPropName: options.modelIdPropName || 'id', reviverModelName: `revive${options.modelName}`, fileName: strings.dasherize(options.storeName) - }; + } as const satisfies ExtraFormattedProperties; let currentStoreIndex = ''; const barrelPath = path.join(destination, options.storeName, 'index.ts'); if (tree.exists(barrelPath)) { diff --git a/packages/@o3r/core/schematics/store/simple-async/index.ts b/packages/@o3r/core/schematics/store/simple-async/index.ts index a8d4a6654b..5843d1d7bb 100644 --- a/packages/@o3r/core/schematics/store/simple-async/index.ts +++ b/packages/@o3r/core/schematics/store/simple-async/index.ts @@ -44,7 +44,7 @@ function ngGenerateSimpleAsyncStoreFn(options: NgGenerateSimpleAsyncStoreSchemat options.modelName = options.modelName?.trim(); // Add extra formatted properties - const formattedProperties: Partial = { + const formattedProperties = { isAsync: true, isEntity: false, storeName: strings.classify(options.storeName), @@ -55,7 +55,7 @@ function ngGenerateSimpleAsyncStoreFn(options: NgGenerateSimpleAsyncStoreSchemat payloadModelName: options.sdkPackage ? options.modelName : strings.classify(options.storeName), reviverModelName: `revive${options.modelName}`, fileName: strings.dasherize(options.storeName) - }; + } as const satisfies Partial; let currentStoreIndex = ''; const barrelPath = path.join(destination, options.storeName, 'index.ts'); if (tree.exists(barrelPath)) { diff --git a/packages/@o3r/core/schematics/store/simple-sync/index.ts b/packages/@o3r/core/schematics/store/simple-sync/index.ts index 09cedc23eb..77cac77461 100644 --- a/packages/@o3r/core/schematics/store/simple-sync/index.ts +++ b/packages/@o3r/core/schematics/store/simple-sync/index.ts @@ -42,14 +42,14 @@ function ngGenerateSimpleSyncStoreFn(options: NgGenerateSimpleSyncStoreSchematic options.storeName = options.storeName?.trim(); // Add extra formatted properties - const formattedProperties: Partial = { + const formattedProperties = { isAsync: false, isEntity: false, storeName: strings.classify(options.storeName), cStoreName: strings.camelize(options.storeName), scuStoreName: strings.underscore(options.storeName).toUpperCase(), fileName: strings.dasherize(options.storeName) - }; + } as const satisfies Partial; let currentStoreIndex = ''; const barrelPath = path.join(destination, options.storeName, 'index.ts'); if (tree.exists(barrelPath)) { diff --git a/packages/@o3r/core/src/core/application/build-properties.ts b/packages/@o3r/core/src/core/application/build-properties.ts index 3b30eabdda..c2e5506886 100644 --- a/packages/@o3r/core/src/core/application/build-properties.ts +++ b/packages/@o3r/core/src/core/application/build-properties.ts @@ -58,7 +58,7 @@ export interface BuildTimeProperties { /** * Library build time default properties */ -export const DEFAULT_BUILD_PROPERTIES: BuildTimeProperties = { +export const DEFAULT_BUILD_PROPERTIES: Readonly = { DEBUG_MODE: true, APP_BASE_HREF: '.', APP_VERSION: '0.0.0', @@ -69,4 +69,4 @@ export const DEFAULT_BUILD_PROPERTIES: BuildTimeProperties = { ENVIRONMENT: 'dev', LOCALIZATION_BUNDLES_OUTPUT: 'localizations/', USE_MOCKS: false -}; +} as const; diff --git a/packages/@o3r/create/src/index.ts b/packages/@o3r/create/src/index.ts index 5bad1121cb..f0c014c4d2 100644 --- a/packages/@o3r/create/src/index.ts +++ b/packages/@o3r/create/src/index.ts @@ -197,11 +197,11 @@ const createNgProject = () => { const prepareWorkspace = (relativeDirectory = '.', projectPackageManager = 'npm') => { const cwd = resolve(process.cwd(), relativeDirectory); - const spawnSyncOpts: SpawnSyncOptionsWithBufferEncoding = { + const spawnSyncOpts = { stdio: 'inherit', shell: true, cwd - }; + } as const satisfies SpawnSyncOptionsWithBufferEncoding; const runner = process.platform === 'win32' ? `${projectPackageManager}.cmd` : projectPackageManager; const mandatoryDependencies = [ '@angular-devkit/schematics', diff --git a/packages/@o3r/design/builders/generate-css/index.ts b/packages/@o3r/design/builders/generate-css/index.ts index 3e90d13c48..b62d638474 100644 --- a/packages/@o3r/design/builders/generate-css/index.ts +++ b/packages/@o3r/design/builders/generate-css/index.ts @@ -83,7 +83,7 @@ export default createBuilder(createBuilderWithMetri logger.info(`Updated ${file} with Design Token content.`); return res; }; - const renderDesignTokenOptionsCss: DesignTokenRendererOptions = { + const renderDesignTokenOptionsCss = { writeFile: writeFileWithLogger, determineFileToUpdate, tokenDefinitionRenderer: getCssTokenDefinitionRenderer({ @@ -100,9 +100,9 @@ export default createBuilder(createBuilderWithMetri logger }), logger - }; + } as const satisfies DesignTokenRendererOptions; - const renderDesignTokenOptionsSass: DesignTokenRendererOptions = { + const renderDesignTokenOptionsSass = { writeFile: writeFileWithLogger, determineFileToUpdate, tokenDefinitionRenderer: getSassTokenDefinitionRenderer({ @@ -110,14 +110,14 @@ export default createBuilder(createBuilderWithMetri logger }), logger - }; + } as const satisfies DesignTokenRendererOptions; - const renderDesignTokenOptionsMetadata: DesignTokenRendererOptions = { + const renderDesignTokenOptionsMetadata = { determineFileToUpdate: () => resolve(context.workspaceRoot, options.metadataOutput!), styleContentUpdater: getMetadataStyleContentUpdater(), tokenDefinitionRenderer: getMetadataTokenDefinitionRenderer({ tokenVariableNameRenderer, ignorePrivateVariable: options.metadataIgnorePrivate }), logger - }; + } as const satisfies DesignTokenRendererOptions; const execute = async (renderDesignTokenOptions: DesignTokenRendererOptions): Promise => { let template: DesignTokenGroupTemplate | undefined; diff --git a/packages/@o3r/design/schematics/generate-css/index.ts b/packages/@o3r/design/schematics/generate-css/index.ts index c2fc97582b..d045cf951c 100644 --- a/packages/@o3r/design/schematics/generate-css/index.ts +++ b/packages/@o3r/design/schematics/generate-css/index.ts @@ -35,13 +35,13 @@ function generateCssFn(options: GenerateCssSchematicsSchema): Rule { return options.defaultStyleFile; }; - const renderDesignTokenOptions: DesignTokenRendererOptions = { + const renderDesignTokenOptions = { readFile, writeFile, existsFile, determineFileToUpdate, logger: context.logger - }; + } as const satisfies DesignTokenRendererOptions; const { globInTree } = await import('@o3r/schematics'); diff --git a/packages/@o3r/design/schematics/ng-add/register-generate-css/register-task.ts b/packages/@o3r/design/schematics/ng-add/register-generate-css/register-task.ts index 981e1f4030..aa4bd6f361 100644 --- a/packages/@o3r/design/schematics/ng-add/register-generate-css/register-task.ts +++ b/packages/@o3r/design/schematics/ng-add/register-generate-css/register-task.ts @@ -29,7 +29,7 @@ export const registerGenerateCssBuilder = (projectName?: string, taskName = 'gen const workspaceRootPath = workspaceProject?.root || '.'; const srcBasePath = workspaceProject?.sourceRoot || posix.join(workspaceRootPath, 'src'); const themeFile = posix.join(srcBasePath, 'style', 'theme.scss'); - const taskOptions: GenerateStyleSchematicsSchema = { + const taskOptions = { language: 'css', defaultStyleFile: themeFile, templateFile: posix.join(workspaceRootPath, 'design-token.template.json'), @@ -37,7 +37,7 @@ export const registerGenerateCssBuilder = (projectName?: string, taskName = 'gen posix.join(srcBasePath, 'style', '*.json'), posix.join(srcBasePath, '**', '*.theme.json') ] - }; + } as const satisfies GenerateStyleSchematicsSchema; const taskParameters = { builder: '@o3r/design:generate-css', options: taskOptions, diff --git a/packages/@o3r/design/src/core/design-token/parsers/design-token.parser.ts b/packages/@o3r/design/src/core/design-token/parsers/design-token.parser.ts index 640a45cc78..e4774864ef 100644 --- a/packages/@o3r/design/src/core/design-token/parsers/design-token.parser.ts +++ b/packages/@o3r/design/src/core/design-token/parsers/design-token.parser.ts @@ -182,7 +182,7 @@ const walkThroughDesignTokenNodes = ( const parentNames = ancestors.map(({ name }) => name); const tokenReferenceName = getTokenReferenceName(nodeName, parentNames); - const tokenVariable: DesignTokenVariableStructure = { + const tokenVariable = { context, extensions: getExtensions([...ancestors, { name: nodeName, tokenNode: node }], context), node, @@ -213,7 +213,7 @@ const walkThroughDesignTokenNodes = ( getKey: function (keyRenderer) { return keyRenderer ? keyRenderer(this) : sanitizeKeyName(this.tokenReferenceName); } - }; + } as const satisfies DesignTokenVariableStructure; mem.set(tokenReferenceName, tokenVariable); } else if (!isDesignTokenGroup(node)) { @@ -254,9 +254,9 @@ interface ParseDesignTokenFileOptions { */ export const parseDesignTokenFile = async (specificationFilePath: string, options?: ParseDesignTokenFileOptions) => { const readFile = options?.readFile || (async (filePath: string) => (await import('node:fs/promises')).readFile(filePath, { encoding: 'utf8' })); - const context: DesignTokenContext = { + const context = { basePath: dirname(specificationFilePath), ...options?.specificationContext - }; + } as const satisfies DesignTokenContext; return parseDesignToken({ document: JSON.parse(await readFile(specificationFilePath)), context }); }; diff --git a/packages/@o3r/dev-tools/src/cli/aql-artifact-cleaner.ts b/packages/@o3r/dev-tools/src/cli/aql-artifact-cleaner.ts index 688dbb8f33..6a1447ee4b 100644 --- a/packages/@o3r/dev-tools/src/cli/aql-artifact-cleaner.ts +++ b/packages/@o3r/dev-tools/src/cli/aql-artifact-cleaner.ts @@ -80,7 +80,7 @@ const isDownloadedTimeValueDefined = !!programOptions.lastDownloadedTimeValue; const downloadedTimeValue: number = programOptions.lastDownloadedTimeValue; const property: string = programOptions.property; const propertyValue: string = programOptions.propertyValue; -const options: Options = { +const options = { headers: authHeader, uri: url, body: `items.find( @@ -99,7 +99,7 @@ const options: Options = { .include("name","repo","path","created","size") .sort({"$desc" : ["created"]}).offset(${offset}) .limit(10000)` -}; +} as const satisfies Options; logger.debug(`AQL search executed : ${options.body}`); logger.info(`Url called : ${url}`); diff --git a/packages/@o3r/dynamic-content/schematics/ng-update/v10-0/index.ts b/packages/@o3r/dynamic-content/schematics/ng-update/v10-0/index.ts index 109f44eaac..4ddd470281 100644 --- a/packages/@o3r/dynamic-content/schematics/ng-update/v10-0/index.ts +++ b/packages/@o3r/dynamic-content/schematics/ng-update/v10-0/index.ts @@ -10,14 +10,14 @@ import { updatePipes, } from '@o3r/schematics'; -const pipeReplacementInfo: PipeReplacementInfo = { +const pipeReplacementInfo = { dynamicContent: { new: { name: 'o3rDynamicContent' }, import: 'DynamicContentModule' } -}; +} as const satisfies PipeReplacementInfo; /** * Update of Otter library V10.0 diff --git a/packages/@o3r/dynamic-content/src/services/request-parameters/request-parameters.config.ts b/packages/@o3r/dynamic-content/src/services/request-parameters/request-parameters.config.ts index 3d319ac6de..e62b4e012c 100644 --- a/packages/@o3r/dynamic-content/src/services/request-parameters/request-parameters.config.ts +++ b/packages/@o3r/dynamic-content/src/services/request-parameters/request-parameters.config.ts @@ -39,9 +39,9 @@ export interface RequestParametersConfig { postParamsValue: string; } -export const defaultRequestParametersConfig: RequestParametersConfig = { +export const defaultRequestParametersConfig: Readonly = { storage: (typeof window === 'undefined') ? undefined : window.sessionStorage, strategy: StorageStrategy.Rehydrate, queryParamsValue: (typeof document !== 'undefined' && document.body?.dataset?.query) || '{}', postParamsValue: (typeof document !== 'undefined' && document.body?.dataset?.post) || '{}' -}; +} as const; diff --git a/packages/@o3r/extractors/src/core/comparator/package-managers-extractors/yarn2-file-extractor.helper.ts b/packages/@o3r/extractors/src/core/comparator/package-managers-extractors/yarn2-file-extractor.helper.ts index 874cbecf7d..945b8ae174 100644 --- a/packages/@o3r/extractors/src/core/comparator/package-managers-extractors/yarn2-file-extractor.helper.ts +++ b/packages/@o3r/extractors/src/core/comparator/package-managers-extractors/yarn2-file-extractor.helper.ts @@ -159,8 +159,8 @@ async function fetchPackage(project: Project, descriptor: Descriptor): Promise new fetcher()) ); - const fetchOptions: FetchOptions = { project, cache, checksums: project.storedChecksums, report, fetcher: multiFetcher }; - const resolveOptions: ResolveOptions = { project, report, resolver: multiResolver, fetchOptions }; + const fetchOptions = { project, cache, checksums: project.storedChecksums, report, fetcher: multiFetcher } as const satisfies FetchOptions; + const resolveOptions = { project, report, resolver: multiResolver, fetchOptions } as const satisfies ResolveOptions; const normalizedDescriptor = project.configuration.normalizeDependency(descriptor); const candidate = await multiResolver.getCandidates(normalizedDescriptor, {}, resolveOptions); @@ -173,7 +173,7 @@ async function fetchPackage(project: Project, descriptor: Descriptor): Promise = { +export const localizationMetadataComparator: Readonly> = { getArray: getLocalizationArray, getIdentifier: getLocalizationName, isRelevantContentType, isMigrationDataMatch: isMigrationLocalizationDataMatch -}; +} as const; diff --git a/packages/@o3r/localization/src/core/localization.configuration.ts b/packages/@o3r/localization/src/core/localization.configuration.ts index 3475419cd6..6ec7e5fecd 100644 --- a/packages/@o3r/localization/src/core/localization.configuration.ts +++ b/packages/@o3r/localization/src/core/localization.configuration.ts @@ -51,7 +51,7 @@ export interface LocalizationConfiguration { /** * Default configuration for LocalizationModule */ -export const DEFAULT_LOCALIZATION_CONFIGURATION: LocalizationConfiguration = { +export const DEFAULT_LOCALIZATION_CONFIGURATION: Readonly = { supportedLocales: [], endPointUrl: '', useDynamicContent: false, @@ -61,4 +61,4 @@ export const DEFAULT_LOCALIZATION_CONFIGURATION: LocalizationConfiguration = { debugMode: false, enableTranslationDeactivation: false, mergeWithLocalTranslations: false -}; +} as const; diff --git a/packages/@o3r/localization/src/core/translate-messageformat-lazy.compiler.ts b/packages/@o3r/localization/src/core/translate-messageformat-lazy.compiler.ts index 34ed731a9e..31545300e7 100644 --- a/packages/@o3r/localization/src/core/translate-messageformat-lazy.compiler.ts +++ b/packages/@o3r/localization/src/core/translate-messageformat-lazy.compiler.ts @@ -32,10 +32,10 @@ export interface LazyMessageFormatConfig extends Options { /** * Message format configuration default value */ -export const lazyMessageDefaultConfig: LazyMessageFormatConfig = { +export const lazyMessageDefaultConfig: Readonly = { enableCache: true, ignoreTag: true -}; +} as const; /** Message Format configuration Token */ export const MESSAGE_FORMAT_CONFIG = new InjectionToken('Message Format configuration'); diff --git a/packages/@o3r/localization/src/devkit/localization-devtools.token.ts b/packages/@o3r/localization/src/devkit/localization-devtools.token.ts index c9a93f9188..50f258976f 100644 --- a/packages/@o3r/localization/src/devkit/localization-devtools.token.ts +++ b/packages/@o3r/localization/src/devkit/localization-devtools.token.ts @@ -5,10 +5,10 @@ import { LocalizationDevtoolsServiceOptions, } from './localization-devkit.interface'; -export const OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS: LocalizationDevtoolsServiceOptions = { +export const OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS: Readonly = { isActivatedOnBootstrap: false, isActivatedOnBootstrapWhenCMSContext: true, metadataFilePath: './metadata/localisation.metadata.json' -}; +} as const; -export const OTTER_LOCALIZATION_DEVTOOLS_OPTIONS: InjectionToken = new InjectionToken('Otter Localization Devtools options'); +export const OTTER_LOCALIZATION_DEVTOOLS_OPTIONS = new InjectionToken('Otter Localization Devtools options'); diff --git a/packages/@o3r/localization/src/tools/localization.provider.ts b/packages/@o3r/localization/src/tools/localization.provider.ts index 3d837d7538..47ed867408 100644 --- a/packages/@o3r/localization/src/tools/localization.provider.ts +++ b/packages/@o3r/localization/src/tools/localization.provider.ts @@ -35,8 +35,8 @@ export function createTranslateLoader(localizationConfiguration: LocalizationCon /** * TranslateLoader provider, using framework's TranslationsLoader class */ -export const translateLoaderProvider: FactoryProvider = { +export const translateLoaderProvider: Readonly = { provide: TranslateLoader, useFactory: createTranslateLoader, deps: [LOCALIZATION_CONFIGURATION_TOKEN, [new Optional(), LoggerService], [new Optional(), DynamicContentService]] -}; +} as const; diff --git a/packages/@o3r/logger/src/services/logger/logger.noop.ts b/packages/@o3r/logger/src/services/logger/logger.noop.ts index ef18ec814d..7d8662286c 100644 --- a/packages/@o3r/logger/src/services/logger/logger.noop.ts +++ b/packages/@o3r/logger/src/services/logger/logger.noop.ts @@ -12,7 +12,7 @@ import type { * Console logger used to display the logs in the browser console * Should be used in development mode. */ -export const noopLogger: LoggerClient = { +export const noopLogger: Readonly = { identify: () => {}, event: () => {}, getSessionURL: () => undefined, @@ -24,4 +24,4 @@ export const noopLogger: LoggerClient = { info: console.info, log: console.log, createMetaReducer: (): MetaReducer => (reducer: ActionReducer): ActionReducer => reducer -}; +} as const; diff --git a/packages/@o3r/rules-engine/builders/rules-engine-extractor/helpers/rules-engine.extractor.ts b/packages/@o3r/rules-engine/builders/rules-engine-extractor/helpers/rules-engine.extractor.ts index 079353a94a..a0343e5f53 100644 --- a/packages/@o3r/rules-engine/builders/rules-engine-extractor/helpers/rules-engine.extractor.ts +++ b/packages/@o3r/rules-engine/builders/rules-engine-extractor/helpers/rules-engine.extractor.ts @@ -52,7 +52,7 @@ export class RulesEngineExtractor { /** Interface of an action definition */ public static readonly OPERATOR_ACTIONS_INTERFACE = 'RulesEngineAction'; /** Reserved fact names that will be filtered out of metadata */ - public static readonly RESERVED_FACT_NAMES: readonly string[] = ['portalFacts']; + public static readonly RESERVED_FACT_NAMES = ['portalFacts']; /** TSConfig to parse the code */ private readonly tsconfig: any; @@ -83,11 +83,11 @@ export class RulesEngineExtractor { : []; internalLibFiles.push(sourceFile); const program = tjs.getProgramFromFiles(internalLibFiles, this.tsconfig.compilerOptions, this.basePath); - const settings: tjs.PartialArgs = { + const settings = { required: true, aliasRef: this.tsconfig.compilerOptions?.paths, ignoreErrors: true - }; + } as const satisfies tjs.PartialArgs; const schema = tjs.generateSchema(program, type, settings); if (schema?.definitions?.['utils.Date']) { schema.definitions['utils.Date'] = { type: 'string', format: 'date' }; diff --git a/packages/@o3r/rules-engine/src/devkit/rules-engine-devtools.token.ts b/packages/@o3r/rules-engine/src/devkit/rules-engine-devtools.token.ts index 58955cf297..6d6bc2082b 100644 --- a/packages/@o3r/rules-engine/src/devkit/rules-engine-devtools.token.ts +++ b/packages/@o3r/rules-engine/src/devkit/rules-engine-devtools.token.ts @@ -5,8 +5,8 @@ import { RulesEngineDevtoolsServiceOptions, } from './rules-engine-devkit.interface'; -export const OTTER_RULES_ENGINE_DEVTOOLS_DEFAULT_OPTIONS: RulesEngineDevtoolsServiceOptions = { +export const OTTER_RULES_ENGINE_DEVTOOLS_DEFAULT_OPTIONS: Readonly = { isActivatedOnBootstrap: false -}; +} as const; -export const OTTER_RULES_ENGINE_DEVTOOLS_OPTIONS: InjectionToken = new InjectionToken('Otter RulesEngine Devtools options'); +export const OTTER_RULES_ENGINE_DEVTOOLS_OPTIONS = new InjectionToken('Otter RulesEngine Devtools options'); diff --git a/packages/@o3r/rules-engine/src/engine/engine.ts b/packages/@o3r/rules-engine/src/engine/engine.ts index b8f3730ac9..452565d4d3 100644 --- a/packages/@o3r/rules-engine/src/engine/engine.ts +++ b/packages/@o3r/rules-engine/src/engine/engine.ts @@ -207,7 +207,7 @@ export class RulesEngine { * Update or insert operator in rules engine * @param operators operator list to add / update */ - public upsertOperators(operators: (Operator | UnaryOperator)[]) { + public upsertOperators(operators: (Operator | UnaryOperator)[]) { this.operators = operators.reduce((acc, operator) => { acc[operator.name] = operator; return acc; diff --git a/packages/@o3r/rules-engine/src/services/rules-engine.token.ts b/packages/@o3r/rules-engine/src/services/rules-engine.token.ts index fe8b567c5c..2788aea3e3 100644 --- a/packages/@o3r/rules-engine/src/services/rules-engine.token.ts +++ b/packages/@o3r/rules-engine/src/services/rules-engine.token.ts @@ -16,7 +16,7 @@ export interface RulesEngineServiceOptions { } /** Default Rules engine options */ -export const DEFAULT_RULES_ENGINE_OPTIONS: RulesEngineServiceOptions = { +export const DEFAULT_RULES_ENGINE_OPTIONS: Readonly = { dryRun: false, debug: false -}; +} as const; diff --git a/packages/@o3r/schematics/src/rule-factories/eslint-fix/index.ts b/packages/@o3r/schematics/src/rule-factories/eslint-fix/index.ts index a4351dde87..fb0d600390 100644 --- a/packages/@o3r/schematics/src/rule-factories/eslint-fix/index.ts +++ b/packages/@o3r/schematics/src/rule-factories/eslint-fix/index.ts @@ -34,11 +34,11 @@ export function applyEsLintFix(_prootPath = '/', extension: string[] = ['ts'], o return noop(); } - const linterOptions: LinterOptions = { + const linterOptions = { continueOnError: true, hideWarnings: true, ...options - }; + } as const satisfies LinterOptions; return (tree: Tree, context: SchematicContext) => { const filesToBeLint = tree.actions diff --git a/packages/@o3r/schematics/src/utility/generation.ts b/packages/@o3r/schematics/src/utility/generation.ts index 4a4c71dfd4..1049846eb3 100644 --- a/packages/@o3r/schematics/src/utility/generation.ts +++ b/packages/@o3r/schematics/src/utility/generation.ts @@ -25,7 +25,7 @@ export type GeneratedItemType = '@o3r/testing:playwright-sanity'; /** List of Otter items types */ -export const OTTER_ITEM_TYPES: GeneratedItemType[] = [ +export const OTTER_ITEM_TYPES = [ '@o3r/core:component', '@o3r/core:page', '@o3r/core:service', @@ -33,7 +33,7 @@ export const OTTER_ITEM_TYPES: GeneratedItemType[] = [ '@o3r/core:schematics-update', '@o3r/testing:playwright-scenario', '@o3r/testing:playwright-sanity' -]; +] as const satisfies GeneratedItemType[]; /** List of the default destination paths for each generated entity */ export const TYPES_DEFAULT_FOLDER: { [key in GeneratedItemType]: { app?: string; lib?: string } } = { diff --git a/packages/@o3r/schematics/src/utility/logo.ts b/packages/@o3r/schematics/src/utility/logo.ts index 73ee8bf760..d0aa836a50 100644 --- a/packages/@o3r/schematics/src/utility/logo.ts +++ b/packages/@o3r/schematics/src/utility/logo.ts @@ -35,9 +35,9 @@ const logoSmall = ` * @param size Size of the logo to generate */ export const getLogo = (size: 'medium' | 'small' = 'medium') => { - const logos: Record = { + const logos = { medium: logoMedium, small: logoSmall - }; + } as const satisfies Record; return logos[size]; }; diff --git a/packages/@o3r/schematics/src/utility/monorepo.ts b/packages/@o3r/schematics/src/utility/monorepo.ts index 21a00ffda3..d38495760a 100644 --- a/packages/@o3r/schematics/src/utility/monorepo.ts +++ b/packages/@o3r/schematics/src/utility/monorepo.ts @@ -65,16 +65,16 @@ export const LIBRARIES_FOLDER_NAME = 'libs'; export const APPLICATIONS_FOLDER_NAME = 'apps'; /** Default directories for generated apps/libs inside a monorepo */ -export const DEFAULT_ROOT_FOLDERS: WorkspaceLayout = { +export const DEFAULT_ROOT_FOLDERS = { libsDir: LIBRARIES_FOLDER_NAME, appsDir: APPLICATIONS_FOLDER_NAME -}; +} as const satisfies WorkspaceLayout; /** Root folders map for apps/libs inside a monorepo */ -export const BASE_ROOT_FOLDERS_MAP: Record = { +export const BASE_ROOT_FOLDERS_MAP = { library: 'libsDir', application: 'appsDir' -}; +} as const satisfies Record; /** * Retrieve the project base root generation folder, based on the given projectType. diff --git a/packages/@o3r/schematics/src/utility/package-manager-runner.ts b/packages/@o3r/schematics/src/utility/package-manager-runner.ts index 5d8d3ca4c9..be8d3010a2 100644 --- a/packages/@o3r/schematics/src/utility/package-manager-runner.ts +++ b/packages/@o3r/schematics/src/utility/package-manager-runner.ts @@ -20,10 +20,10 @@ export type SupportedPackageManagerRunners = `${SupportedPackageManagers} run` | /** Support NPM package managers */ export type SupportedPackageManagerExecutors = `${SupportedPackageManagers} exec` | 'yarn' | 'npx'; -const PACKAGE_MANAGER_WORKSPACE_MAPPING: Record = { +const PACKAGE_MANAGER_WORKSPACE_MAPPING = { npm: '--workspace', yarn: 'workspace' -}; +} as const satisfies Record; /** Option to determine Package Manager */ export interface PackageManagerOptions { diff --git a/packages/@o3r/schematics/src/utility/wrapper.ts b/packages/@o3r/schematics/src/utility/wrapper.ts index a0f6ed4aee..2256c52fa0 100644 --- a/packages/@o3r/schematics/src/utility/wrapper.ts +++ b/packages/@o3r/schematics/src/utility/wrapper.ts @@ -85,7 +85,7 @@ export const createSchematicWithMetricsIfInstalled: SchematicWrapper = (schemati ) { context.logger.debug('`@o3r/telemetry` is not available.\nAsking to add the dependency\n' + e.toString()); - const question: Question = { + const question = { type: 'confirm', name: 'isReplyPositive', message: ` @@ -94,7 +94,7 @@ It will help us to improve our tools. For more details and instructions on how to change these settings, see https://github.com/AmadeusITGroup/otter/blob/main/docs/telemetry/PRIVACY_NOTICE.md. `, default: false - }; + } as const satisfies Question; const { isReplyPositive } = await prompt([question]); shouldInstallTelemetry = isReplyPositive; } diff --git a/packages/@o3r/styling/builders/metadata-check/helpers/styling-metadata-comparison.helper.ts b/packages/@o3r/styling/builders/metadata-check/helpers/styling-metadata-comparison.helper.ts index 3c3aad93c7..bcfb93732b 100644 --- a/packages/@o3r/styling/builders/metadata-check/helpers/styling-metadata-comparison.helper.ts +++ b/packages/@o3r/styling/builders/metadata-check/helpers/styling-metadata-comparison.helper.ts @@ -29,9 +29,9 @@ const isMigrationCssVariableDataMatch = (cssVariable: CssVariable, migrationData /** * Comparator used to compare one version of styling metadata with another */ -export const stylingMetadataComparator: MetadataComparator = { +export const stylingMetadataComparator: Readonly> = { getArray: getCssVariablesArray, getIdentifier: getCssVariableName, isRelevantContentType, isMigrationDataMatch: isMigrationCssVariableDataMatch -}; +} as const; diff --git a/packages/@o3r/styling/builders/style-extractor/index.ts b/packages/@o3r/styling/builders/style-extractor/index.ts index 722d411905..c20c805a8e 100644 --- a/packages/@o3r/styling/builders/style-extractor/index.ts +++ b/packages/@o3r/styling/builders/style-extractor/index.ts @@ -52,7 +52,7 @@ export default createBuilder(createBuilderWithMetricsIfInstalled context.logger.debug(`${span ? `${span.url?.toString() || ''}:${span.start.line}:${span.start.column}: ` : ''}${message}`), warn: (message, { deprecation, span, stack }) => { let log: string = deprecation ? `Deprecated function used${EOL}` : ''; @@ -62,7 +62,7 @@ export default createBuilder(createBuilderWithMetricsIfInstalled = { isActivatedOnBootstrap: false, stylingMetadataPath: './metadata/styling.metadata.json' -}; +} as const; /** * Token for styling devtools */ -export const OTTER_STYLING_DEVTOOLS_OPTIONS: InjectionToken = new InjectionToken('Otter Styling Devtools options'); +export const OTTER_STYLING_DEVTOOLS_OPTIONS = new InjectionToken('Otter Styling Devtools options'); diff --git a/packages/@o3r/telemetry/src/builders/index.ts b/packages/@o3r/telemetry/src/builders/index.ts index 38e17d12a8..3897460c4b 100644 --- a/packages/@o3r/telemetry/src/builders/index.ts +++ b/packages/@o3r/telemetry/src/builders/index.ts @@ -50,7 +50,7 @@ export const createBuilderWithMetrics: BuilderWrapper = (builderFn, sendData = d const builderName = context.builder.name as string; context.logger.info(`${builderName} run in ${duration}ms`); const environment = await getEnvironmentInfo(); - const data: BuilderMetricData = { + const data = { environment, duration, builder: { @@ -68,7 +68,7 @@ export const createBuilderWithMetrics: BuilderWrapper = (builderFn, sendData = d ) }, error - }; + } as const satisfies BuilderMetricData; context.logger.debug(JSON.stringify(data, null, 2)); const packageJsonPath = path.join(context.currentDirectory, 'package.json'); const packageJson = existsSync(packageJsonPath) ? JSON.parse(readFileSync(packageJsonPath, 'utf8')) : {}; diff --git a/packages/@o3r/telemetry/src/cli/index.ts b/packages/@o3r/telemetry/src/cli/index.ts index 45bdbf7e49..621e855881 100644 --- a/packages/@o3r/telemetry/src/cli/index.ts +++ b/packages/@o3r/telemetry/src/cli/index.ts @@ -66,7 +66,7 @@ export const createCliWithMetrics: CliWrapper = (cliFn, cliName, options) => asy logger.info(`${cliName} run in ${duration}ms`); const environment = await getEnvironmentInfo(); const argv = minimist(process.argv.slice(2), { ...options?.minimistOptions, alias: { o3rMetrics: ['o3r-metrics'] } }); - const data: CliMetricData = { + const data = { environment, duration, cli: { @@ -74,7 +74,7 @@ export const createCliWithMetrics: CliWrapper = (cliFn, cliName, options) => asy options: options?.preParsedOptions ?? argv }, error - }; + } as const satisfies CliMetricData; logger.debug(JSON.stringify(data, null, 2)); const packageJsonPath = path.join(process.cwd(), 'package.json'); const packageJson = existsSync(packageJsonPath) ? JSON.parse(readFileSync(packageJsonPath, 'utf8')) : {}; diff --git a/packages/@o3r/telemetry/src/schematics/index.ts b/packages/@o3r/telemetry/src/schematics/index.ts index 7f37d519a1..717b205027 100644 --- a/packages/@o3r/telemetry/src/schematics/index.ts +++ b/packages/@o3r/telemetry/src/schematics/index.ts @@ -53,12 +53,12 @@ export const createSchematicWithMetrics: SchematicWrapper = (schematicFn, sendDa options, interactive: context.interactive }; - const data: SchematicMetricData = { + const data = { environment, schematic, duration, error - }; + } as const satisfies SchematicMetricData; context.logger.debug(JSON.stringify(data, null, 2)); const packageJson = (tree.exists('/package.json') ? tree.readJson('/package.json') : {}) as JsonObject; const shouldSendData = !!( diff --git a/packages/@o3r/test-helpers/src/prepare-test-env.ts b/packages/@o3r/test-helpers/src/prepare-test-env.ts index a7fc73332b..751fe6e62a 100644 --- a/packages/@o3r/test-helpers/src/prepare-test-env.ts +++ b/packages/@o3r/test-helpers/src/prepare-test-env.ts @@ -73,11 +73,11 @@ export async function prepareTestEnv(folderName: string, options?: PrepareTestEn JSON.parse(readFileSync(path.join(rootFolderPath, 'packages', '@o3r', 'core', 'package.json')).toString()); const yarnVersion: string = yarnVersionParam || getYarnVersionFromRoot(rootFolderPath); - const execAppOptions: ExecSyncOptions = { + const execAppOptions = { cwd: workspacePath, stdio: 'inherit', env: { ...process.env, NODE_OPTIONS: '', CI: 'true' } - }; + } as const satisfies ExecSyncOptions; const packageManagerConfig = { yarnVersion, diff --git a/packages/@o3r/test-helpers/src/test-environments/create-test-environment-blank.ts b/packages/@o3r/test-helpers/src/test-environments/create-test-environment-blank.ts index 8edda92399..7db610f7b9 100644 --- a/packages/@o3r/test-helpers/src/test-environments/create-test-environment-blank.ts +++ b/packages/@o3r/test-helpers/src/test-environments/create-test-environment-blank.ts @@ -34,7 +34,7 @@ export interface CreateTestEnvironmentBlankOptions extends CreateWithLockOptions * @param inputOptions */ export async function createTestEnvironmentBlank(inputOptions: Partial) { - const options: CreateTestEnvironmentBlankOptions = { + const options = { appDirectory: 'test-app', cwd: process.cwd(), globalFolderPath: process.cwd(), @@ -42,14 +42,14 @@ export async function createTestEnvironmentBlank(inputOptions: Partial { const appFolderPath = path.join(options.cwd, options.appDirectory); - const execAppOptions: ExecSyncOptions = { + const execAppOptions = { cwd: appFolderPath, stdio: 'inherit', env: { ...process.env, NODE_OPTIONS: '', CI: 'true' } - }; + } as const satisfies ExecSyncOptions; // Prepare folder if (existsSync(appFolderPath)) { diff --git a/packages/@o3r/test-helpers/src/test-environments/create-test-environment-otter-project.ts b/packages/@o3r/test-helpers/src/test-environments/create-test-environment-otter-project.ts index 75199a439c..a4298c8f51 100644 --- a/packages/@o3r/test-helpers/src/test-environments/create-test-environment-otter-project.ts +++ b/packages/@o3r/test-helpers/src/test-environments/create-test-environment-otter-project.ts @@ -56,7 +56,7 @@ const o3rVersion = '~999'; * @param inputOptions */ export async function createTestEnvironmentOtterProjectWithAppAndLib(inputOptions: Partial) { - const options: CreateTestEnvironmentOtterProjectWithAppAndLibOptions = { + const options = { appName: 'test-app', libName: 'test-lib', appDirectory: 'test-app', @@ -67,15 +67,15 @@ export async function createTestEnvironmentOtterProjectWithAppAndLib(inputOption lockTimeout: 10 * 60 * 1000, replaceExisting: true, ...inputOptions - }; + } as const satisfies CreateTestEnvironmentOtterProjectWithAppAndLibOptions; await createWithLock(() => { const appFolderPath = path.join(options.cwd, options.appDirectory); - const execAppOptions: ExecSyncOptions = { + const execAppOptions = { cwd: appFolderPath, stdio: 'inherit', env: { ...process.env, NODE_OPTIONS: '', CI: 'true' } - }; + } as const satisfies ExecSyncOptions; // Prepare folder if (existsSync(appFolderPath)) { diff --git a/packages/@o3r/test-helpers/src/utilities/git.ts b/packages/@o3r/test-helpers/src/utilities/git.ts index 1a72009e45..7266555e6b 100644 --- a/packages/@o3r/test-helpers/src/utilities/git.ts +++ b/packages/@o3r/test-helpers/src/utilities/git.ts @@ -31,7 +31,7 @@ const cleanList = (list: string[]) => [...new Set(list.filter((file) => !!file). * @param baseBranch */ export function getGitDiff(workingDirectory?: string, baseBranch = 'after-init') { - const execOptions: ExecFileSyncOptionsWithStringEncoding = { stdio: ['pipe', 'pipe', 'ignore'], encoding: 'utf8', cwd: workingDirectory }; + const execOptions = { stdio: ['pipe', 'pipe', 'ignore'], encoding: 'utf8', cwd: workingDirectory } as const satisfies ExecFileSyncOptionsWithStringEncoding; const untrackedFiles = execFileSync('git', ['ls-files', '--others', '--exclude-standard'], execOptions).split('\n'); const trackedFiles = execFileSync('git', ['diff', '--name-status', baseBranch], execOptions).split('\n'); const indexedFiles = execFileSync('git', ['diff', '--cached', '--name-status', baseBranch], execOptions).split('\n'); diff --git a/packages/@o3r/test-helpers/src/utilities/package-manager.ts b/packages/@o3r/test-helpers/src/utilities/package-manager.ts index 04e9d58c84..321472e30f 100644 --- a/packages/@o3r/test-helpers/src/utilities/package-manager.ts +++ b/packages/@o3r/test-helpers/src/utilities/package-manager.ts @@ -38,7 +38,7 @@ type Command = | 'workspaceExec' | 'workspaceRun'; -const PACKAGE_MANAGERS_CMD: { [packageManager in SupportedPackageManagers]: { [command in Command]: string[] } } = { +const PACKAGE_MANAGERS_CMD = { npm: { add: ['npm', 'install'], ci: ['npm', 'ci'], @@ -65,7 +65,7 @@ const PACKAGE_MANAGERS_CMD: { [packageManager in SupportedPackageManagers]: { [c workspaceExec: ['yarn', 'workspace'], workspaceRun: ['yarn', 'workspace'] } -}; +} as const satisfies Record>; type CommandArguments = { /** Script to run or execute */ diff --git a/packages/@o3r/testing/schematics/add-functions-to-fixture/models.ts b/packages/@o3r/testing/schematics/add-functions-to-fixture/models.ts index aad7ac4176..1eacdda177 100644 --- a/packages/@o3r/testing/schematics/add-functions-to-fixture/models.ts +++ b/packages/@o3r/testing/schematics/add-functions-to-fixture/models.ts @@ -13,7 +13,7 @@ export type MethodType = /** * Return type associated to the MethodType */ -export const returnType: Record = { +export const returnType = { clickOnButton: 'Promise', getText: 'Promise', getInputValue: 'Promise', @@ -21,12 +21,12 @@ export const returnType: Record = { getTextInList: 'Promise', clickButtonInList: 'Promise', getNumberOfItems: 'Promise' -}; +} as const satisfies Record; /** * Description associated to the MethodType */ -export const description: Record = { +export const description = { clickOnButton: ` /** * Click on the button @@ -68,4 +68,4 @@ export const description: Record = { * * @returns number of items */` -}; +} as const satisfies Record; diff --git a/packages/@o3r/testing/schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts b/packages/@o3r/testing/schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts index 333a7b1a76..d64a2e6a91 100644 --- a/packages/@o3r/testing/schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts +++ b/packages/@o3r/testing/schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts @@ -3,7 +3,7 @@ import type { } from '@o3r/schematics'; /** Map to be used to double check that localization mocks from o3r testing package are well imported from the /localization subentry */ -export const mapImportLocalizationMocks: ImportsMapping = { +export const mapImportLocalizationMocks = { '@o3r/testing': { TranslatePipeMock: { newPackage: '@o3r/testing/localization' @@ -18,4 +18,4 @@ export const mapImportLocalizationMocks: ImportsMapping = { newPackage: '@o3r/testing/localization' } } -}; +} as const satisfies ImportsMapping; diff --git a/packages/@o3r/testing/src/core/playwright/angular-materials/autocomplete-material.ts b/packages/@o3r/testing/src/core/playwright/angular-materials/autocomplete-material.ts index 1df0a55667..8d7efe0d27 100644 --- a/packages/@o3r/testing/src/core/playwright/angular-materials/autocomplete-material.ts +++ b/packages/@o3r/testing/src/core/playwright/angular-materials/autocomplete-material.ts @@ -31,7 +31,7 @@ export class MatAutocomplete extends O3rElement implements MatAutocompleteProfil throw new Error(`MatAutocomplete selectByValue works only for filtered autocomplete. Found multiple values: ${options.join(', ')}`); } if (matOptionsCount === 1) { - const selectedOption: PlaywrightSourceElement = { element: matOptions.nth(0), page: this.sourceElement.page }; + const selectedOption = { element: matOptions.nth(0), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement; await new O3rElement(selectedOption).click(); return this.sourceElement.element.press('Tab'); } diff --git a/packages/@o3r/testing/src/core/playwright/angular-materials/select-material.ts b/packages/@o3r/testing/src/core/playwright/angular-materials/select-material.ts index b127846109..58398f0b73 100644 --- a/packages/@o3r/testing/src/core/playwright/angular-materials/select-material.ts +++ b/packages/@o3r/testing/src/core/playwright/angular-materials/select-material.ts @@ -20,7 +20,7 @@ export class MatSelect extends O3rElement implements MatSelectProfile { const options = this.sourceElement.page.locator('mat-option'); await options.first().waitFor({ state: 'attached', timeout }); if ((await options.count()) >= index + 1) { - const selectedOption: PlaywrightSourceElement = { element: options.nth(index), page: this.sourceElement.page }; + const selectedOption = { element: options.nth(index), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement; const option = new O3rElement(selectedOption); return option.click(); } else { @@ -35,7 +35,7 @@ export class MatSelect extends O3rElement implements MatSelectProfile { await options.first().waitFor({ state: 'attached', timeout }); const optionsCount = await options.count(); for (let i = 0; i < optionsCount; i++) { - const selectedOption: PlaywrightSourceElement = { element: options.nth(i), page: this.sourceElement.page }; + const selectedOption = { element: options.nth(i), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement; const option = new O3rElement(selectedOption); if (await option.getAttribute('ng-reflect-value') === value) { return option.click(); @@ -51,7 +51,7 @@ export class MatSelect extends O3rElement implements MatSelectProfile { await options.first().waitFor({ state: 'attached', timeout }); const optionsCount = await options.count(); for (let i = 0; i < optionsCount; i++) { - const selectedOption: PlaywrightSourceElement = { element: options.nth(i), page: this.sourceElement.page }; + const selectedOption = { element: options.nth(i), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement; const option = new O3rElement(selectedOption); if (await option.getText() === label) { return option.click(); diff --git a/packages/@o3r/testing/src/core/playwright/component-fixture.ts b/packages/@o3r/testing/src/core/playwright/component-fixture.ts index e9be15ffc6..2f67f0e021 100644 --- a/packages/@o3r/testing/src/core/playwright/component-fixture.ts +++ b/packages/@o3r/testing/src/core/playwright/component-fixture.ts @@ -160,7 +160,7 @@ export class O3rComponentFixture implements C public query(selector: string, returnType: O3rElementConstructor | undefined): Promise { const elements = this.rootElement.sourceElement.element.locator(selector); const element = elements.first(); - const selectedElement: PlaywrightSourceElement = { element: element, page: this.rootElement.sourceElement.page }; + const selectedElement = { element: element, page: this.rootElement.sourceElement.page } as const satisfies PlaywrightSourceElement; return Promise.resolve(new (returnType || O3rElement)(selectedElement)); } @@ -170,7 +170,7 @@ export class O3rComponentFixture implements C public queryNth(selector: string, index: number, returnType: O3rElementConstructor | undefined): Promise { const elements = this.rootElement.sourceElement.element.locator(selector); const element = elements.nth(index); - const selectedElement: PlaywrightSourceElement = { element: element, page: this.rootElement.sourceElement.page }; + const selectedElement = { element: element, page: this.rootElement.sourceElement.page } as const satisfies PlaywrightSourceElement; return Promise.resolve(new (returnType || O3rElement)(selectedElement)); } diff --git a/packages/@o3r/testing/src/kassette/update-dates-in-mocks.ts b/packages/@o3r/testing/src/kassette/update-dates-in-mocks.ts index 72198cac2c..585a9c2981 100644 --- a/packages/@o3r/testing/src/kassette/update-dates-in-mocks.ts +++ b/packages/@o3r/testing/src/kassette/update-dates-in-mocks.ts @@ -43,7 +43,7 @@ export interface UpdateDatesInMocksOptions { */ export async function updateDatesInMocks(mock: IMock, inputOptions: Partial = {}) { const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length; - const options: UpdateDatesInMocksOptions = { + const options = { mode: 'day-offset', extractor: /\b(\d{4}-\d{2}-\d{2})[^"]*/g, converter: { @@ -56,7 +56,7 @@ export async function updateDatesInMocks(mock: IMock, inputOptions: Partial = { +const defaultLocalizationConfiguration = { supportedLocales: ['en'], language: 'en', endPointUrl: '', fallbackLanguage: 'en' -}; +} as const satisfies Partial; @Pipe({ name: 'translate' }) export class TranslatePipeMock implements PipeTransform { diff --git a/packages/@o3r/testing/src/visual-test/visual-test.ts b/packages/@o3r/testing/src/visual-test/visual-test.ts index cd468b2cfb..a0f527eec6 100644 --- a/packages/@o3r/testing/src/visual-test/visual-test.ts +++ b/packages/@o3r/testing/src/visual-test/visual-test.ts @@ -25,13 +25,13 @@ export interface VisualTestMessage { } /** Error messages in case of visual testing failure */ -export const visualTestMessages: VisualTestMessage = { +export const visualTestMessages: Readonly = { imagesSize: 'Image sizes do not match for:', diffMessage: 'Diff between images is greater than threshold for:', baseImgNotFound: 'Base screenshot file not found:', success: 'Visual test successful', generateMode: 'Run in generate screenshot mode' -}; +} as const; /** * Object returned by a visual test operation diff --git a/packages/@o3r/third-party/src/bridge/ab-testing/ab-testing-bridge.ts b/packages/@o3r/third-party/src/bridge/ab-testing/ab-testing-bridge.ts index 38e07ba5c2..269e88142e 100644 --- a/packages/@o3r/third-party/src/bridge/ab-testing/ab-testing-bridge.ts +++ b/packages/@o3r/third-party/src/bridge/ab-testing/ab-testing-bridge.ts @@ -45,11 +45,11 @@ export interface AbTestBridgeConfig { /** * Default options that will represent the interface */ -const defaultOptions: AbTestBridgeConfig = { +const defaultOptions = { bridgeName: 'abTestBridge', readyEventName: 'ab-test-ready', logger: console -}; +} as const satisfies AbTestBridgeConfig; /** * Bridge between the application and a third party A/B testing provider. diff --git a/packages/@o3r/third-party/src/bridge/iframe/helpers.ts b/packages/@o3r/third-party/src/bridge/iframe/helpers.ts index c1dbad5ea5..715295edd9 100644 --- a/packages/@o3r/third-party/src/bridge/iframe/helpers.ts +++ b/packages/@o3r/third-party/src/bridge/iframe/helpers.ts @@ -6,11 +6,11 @@ import { /** * Default options for an IFrameBridge */ -export const IFRAME_BRIDGE_DEFAULT_OPTIONS: IFrameBridgeOptions = { +export const IFRAME_BRIDGE_DEFAULT_OPTIONS: Readonly = { handshakeTries: 10, handshakeTimeout: 200, messageWithResponseTimeout: 1000 -}; +} as const; /** * Verifies if a message respects the format expected by an IFrameBridge diff --git a/packages/@o3r/workspace/schematics/application/index.ts b/packages/@o3r/workspace/schematics/application/index.ts index 1b2bc8d9e9..198f2d3639 100644 --- a/packages/@o3r/workspace/schematics/application/index.ts +++ b/packages/@o3r/workspace/schematics/application/index.ts @@ -95,7 +95,7 @@ function generateApplicationFn(options: NgGenerateApplicationSchema): Rule { }; const angularOptions = getOptions(angularAppSchema); - const dependencies: Record = { + const dependencies = { '@o3r/core': { inManifest: [ { @@ -105,7 +105,7 @@ function generateApplicationFn(options: NgGenerateApplicationSchema): Rule { ], ngAddOptions: { exactO3rVersion: options.exactO3rVersion } } - }; + } as const satisfies Record; return chain([ externalSchematic>('@schematics/angular', 'application', { diff --git a/packages/@o3r/workspace/schematics/library/index.ts b/packages/@o3r/workspace/schematics/library/index.ts index 0c7b42b6c9..1d8935c9f0 100644 --- a/packages/@o3r/workspace/schematics/library/index.ts +++ b/packages/@o3r/workspace/schematics/library/index.ts @@ -56,7 +56,7 @@ function generateModuleFn(options: NgGenerateModuleSchema): Rule { const targetPath = path.posix.resolve('/', options.path || defaultRoot, cleanName); const extendedOptions = { ...options, targetPath, name: cleanName, packageJsonName: packageJsonName }; - const dependencies: Record = { + const dependencies = { '@o3r/core': { inManifest: [ { @@ -66,7 +66,7 @@ function generateModuleFn(options: NgGenerateModuleSchema): Rule { ], ngAddOptions: { exactO3rVersion: options.exactO3rVersion } } - }; + } as const satisfies Record; return chain([ isNx ? nxGenerateModule(extendedOptions) : ngGenerateModule(extendedOptions), diff --git a/packages/@o3r/workspace/schematics/library/rules/rules.nx.ts b/packages/@o3r/workspace/schematics/library/rules/rules.nx.ts index d3a2e37f48..7675ea7368 100644 --- a/packages/@o3r/workspace/schematics/library/rules/rules.nx.ts +++ b/packages/@o3r/workspace/schematics/library/rules/rules.nx.ts @@ -137,12 +137,12 @@ export function nxGenerateModule(options: NgGenerateModuleSchema & { packageJson const nxCliUpdate: Rule = (tree, context) => { const mem: Record = savePreCommandContent(tree); - const config: Record = { + const config = { name: options.name, importPath: options.packageJsonName, buildable: true, publishable: true - }; + } as const; return chain([ (t, c) => externalSchematic('@nx/angular', 'library', config)(t, c), restoreFiles(mem), diff --git a/packages/@o3r/workspace/schematics/sdk/rules/rules.ng.ts b/packages/@o3r/workspace/schematics/sdk/rules/rules.ng.ts index 53fed84663..df338c91ed 100644 --- a/packages/@o3r/workspace/schematics/sdk/rules/rules.ng.ts +++ b/packages/@o3r/workspace/schematics/sdk/rules/rules.ng.ts @@ -17,7 +17,7 @@ import type { * @param projectName Name of the project */ export function ngRegisterProjectTasks(_options: NgGenerateSdkSchema, targetPath: string, projectName: string): Rule { - const project: WorkspaceProject = { + const project = { projectType: 'library', root: targetPath, sourceRoot: path.posix.join(targetPath, 'src'), @@ -42,7 +42,7 @@ export function ngRegisterProjectTasks(_options: NgGenerateSdkSchema, targetPath } } } - }; + } as const satisfies WorkspaceProject; return (tree, context) => { const angularJson = getWorkspaceConfig(tree);