From 0cc626667caf15aba4442d3df34d0e62cdfc8b72 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 27 Sep 2023 18:43:12 +0200 Subject: [PATCH] chore: cleaning unused variables --- .../commons/fill-components/fill-missing-response.ts | 1 - src/use-lunatic/reducer/reduce-on-init.tsx | 2 +- .../resolve-component-controls/resolve-simple-control.ts | 4 +++- src/use-lunatic/type-source.ts | 2 -- src/utils/get-component-value.ts | 1 - src/utils/vtl.ts | 6 ++++++ vite.config.ts | 3 --- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/use-lunatic/commons/fill-components/fill-missing-response.ts b/src/use-lunatic/commons/fill-components/fill-missing-response.ts index fcf25a5da..8c58bdd2b 100644 --- a/src/use-lunatic/commons/fill-components/fill-missing-response.ts +++ b/src/use-lunatic/commons/fill-components/fill-missing-response.ts @@ -1,5 +1,4 @@ import type { LunaticComponentDefinition, LunaticState } from '../../type'; -import missing from '../../../components/commons/components/missing'; import { isNumber } from '../../../utils/number'; export type FilledProps = { diff --git a/src/use-lunatic/reducer/reduce-on-init.tsx b/src/use-lunatic/reducer/reduce-on-init.tsx index c2b9ae676..9d048e008 100644 --- a/src/use-lunatic/reducer/reduce-on-init.tsx +++ b/src/use-lunatic/reducer/reduce-on-init.tsx @@ -66,7 +66,7 @@ function reduceOnInit(state: LunaticState, action: ActionInit) { const variables = LunaticVariablesStore.makeFromSource(source, data); const pages = checkLoops(createMapPages(source)); - const { maxPage, cleaning = {}, missingBlock = {}, resizing = {} } = source; + const { maxPage, cleaning = {}, missingBlock = {} } = source; const initialPager = getPagerFromPageTag(initialPage); const pager = { diff --git a/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.ts b/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.ts index a621852c8..d84440305 100644 --- a/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.ts +++ b/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.ts @@ -11,7 +11,9 @@ export function resolveSimpleControl( const { criticality, errorMessage, id, typeOfControl } = control; const value = control?.control?.value ?? 'true'; - const result = executeExpression(value, { iteration }); + const result = executeExpression(value, { + iteration: linksIterations ?? iteration, + }); try { /** diff --git a/src/use-lunatic/type-source.ts b/src/use-lunatic/type-source.ts index cfe1110bf..bfef3eb6d 100644 --- a/src/use-lunatic/type-source.ts +++ b/src/use-lunatic/type-source.ts @@ -1,5 +1,3 @@ -import type { LunaticComponentDefinition } from './type'; - /** * Types used for source data (lunatic models and data.json) */ diff --git a/src/utils/get-component-value.ts b/src/utils/get-component-value.ts index 8071bb3ab..716250fc2 100644 --- a/src/utils/get-component-value.ts +++ b/src/utils/get-component-value.ts @@ -1,4 +1,3 @@ -import type { ReactNode } from 'react'; import { hasResponse, hasResponses } from '../use-lunatic/commons/component'; /** diff --git a/src/utils/vtl.ts b/src/utils/vtl.ts index 56d03c03f..69ed67351 100644 --- a/src/utils/vtl.ts +++ b/src/utils/vtl.ts @@ -22,6 +22,9 @@ export function interpretVTL( return result as T; } +/** + * Extract variables used in a VTL expression + */ export function parseVTLVariables(expression: string): string[] { try { const chars = new antlr4.InputStream(expression); @@ -41,6 +44,9 @@ export function parseVTLVariables(expression: string): string[] { } } +/** + * Transform a value to make it compatible with VTL (for bindings) + */ export function getVTLCompatibleValue(value: unknown) { if (value === undefined) { return null; diff --git a/vite.config.ts b/vite.config.ts index 2ffbd529b..f36c0b1f3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,9 +4,6 @@ import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [react()], - build: { - ssr: false, - }, test: { environment: 'jsdom', include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],