diff --git a/eslint.config.js b/eslint.config.js index c19b64f7141035cfe8840be0ce721943f091d49d..2710f3765b09bd7fb096a1e12cf5757854c6c662 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -27,16 +27,19 @@ export default [ }, }, rules: { - "import/order": ["warn", { - alphabetize: { - order: "asc", - caseInsensitive: true, - }, + "import/order": [ + "warn", + { + alphabetize: { + order: "asc", + caseInsensitive: true, + }, - "newlines-between": "always", - }], + "newlines-between": "always", + }, + ], - "import/no-unresolved": "off", + "import/no-unresolved": "off", }, settings: { svelte: { diff --git a/src/lib/calculations.ts b/src/lib/calculations.ts index acf5a1c2c9d83698676eb79390b0af80d964db93..6f0b25defb707ea82604cef4101783703a6606ad 100644 --- a/src/lib/calculations.ts +++ b/src/lib/calculations.ts @@ -87,8 +87,8 @@ export function requestBudgetCalculation( ): RequestedCalculations { const budgetCalculationNames = variableName === requestedCalculations.budgetVariableName - ? requestedCalculations.budgetCalculationNames ?? - new Set<CalculationName>() + ? (requestedCalculations.budgetCalculationNames ?? + new Set<CalculationName>()) : new Set<CalculationName>() if (!budgetCalculationNames.has(calculationName)) { requestedCalculations = { diff --git a/src/lib/components/ModificationsPanel.svelte b/src/lib/components/ModificationsPanel.svelte index 54d0724872e0a16c884f63ef13babb1d924f327d..aa31ad69980f0e40e79b653a28b05519f884e0a9 100644 --- a/src/lib/components/ModificationsPanel.svelte +++ b/src/lib/components/ModificationsPanel.svelte @@ -150,8 +150,8 @@ $decompositionByName = buildDecompositionByNameFromCore( $billName === undefined ? decompositionCoreByName - : decompositionCoreByNameByReformName[$billName] ?? - decompositionCoreByName, + : (decompositionCoreByNameByReformName[$billName] ?? + decompositionCoreByName), ) as DecompositionByName $evaluationByNameArray = new Array($testCases.length).fill({}) $inputInstantsByVariableNameArray = diff --git a/src/lib/components/ReformsChanges.svelte b/src/lib/components/ReformsChanges.svelte index dd8d05a13be3dc26b4a9c5412c111a21e6a7cf08..d82fdead18ab8c5f99a12cadf684dde209a6764e 100644 --- a/src/lib/components/ReformsChanges.svelte +++ b/src/lib/components/ReformsChanges.svelte @@ -257,7 +257,7 @@ variableName === "undefined" || variable === undefined ? "Sans dispositif direct" - : variable.short_label ?? variable.label} : + : (variable.short_label ?? variable.label)} : </span> {#each parameters as parameter} {@const variableForParameter = @@ -385,7 +385,7 @@ variableName === "undefined" || variable === undefined ? "Sans dispositif direct" - : variable.short_label ?? variable.label} : + : (variable.short_label ?? variable.label)} : </span> {#each parameters as parameter} {@const variableForParameter = diff --git a/src/lib/components/WaterfallPlainView.svelte b/src/lib/components/WaterfallPlainView.svelte index 0e5e791234ec8a76e33c2310feeb3862ca36d08c..b7f1e16b02b586aa693a1c41cbe36d970061e7f6 100644 --- a/src/lib/components/WaterfallPlainView.svelte +++ b/src/lib/components/WaterfallPlainView.svelte @@ -27,8 +27,8 @@ $: decompositionByName = buildDecompositionByNameFromCore( $billName === undefined ? decompositionCoreByName - : decompositionCoreByNameByReformName[$billName] ?? - decompositionCoreByName, + : (decompositionCoreByNameByReformName[$billName] ?? + decompositionCoreByName), ) as DecompositionByName // Note: A reform variable is always more complete than a variable before reform. diff --git a/src/lib/components/budget/BudgetDetailView.svelte b/src/lib/components/budget/BudgetDetailView.svelte index 6c774e9a8d348550476cd515fb5945ca46891da2..ce895cf739331da7884f6b5c41ea4abdd242ca43 100644 --- a/src/lib/components/budget/BudgetDetailView.svelte +++ b/src/lib/components/budget/BudgetDetailView.svelte @@ -616,7 +616,7 @@ }: BudgetQuantileByCalculationName) { const baseVariableName = budgetVariable.type === "allegement" - ? budgetVariable.allegementBaseVariableName ?? budgetVariable.name + ? (budgetVariable.allegementBaseVariableName ?? budgetVariable.name) : budgetVariable.name const baseVariableType = budgetVariable.type === "allegement" diff --git a/src/lib/components/budget/BudgetLayout.svelte b/src/lib/components/budget/BudgetLayout.svelte index 2f3737596b6f73dcd937aecab453bf455de4fd02..3588844093dc55b885133a76a27cc846204f3aef 100644 --- a/src/lib/components/budget/BudgetLayout.svelte +++ b/src/lib/components/budget/BudgetLayout.svelte @@ -76,11 +76,7 @@ {/if} </h3> <div class:blur class:pointer-events-none={blur}> - <BudgetDetailView - {displayMode} - {budgetSimulation} - {budgetVariable} - > + <BudgetDetailView {displayMode} {budgetSimulation} {budgetVariable}> <span slot="title"> {#if budgetVariable.type === "prestation" || budgetVariable.type === "prelevement"} {#if budgetVariable.type === "prestation"} @@ -478,11 +474,7 @@ {/if} </span> </BudgetDetailView> - <GagnantsPerdantsView - {displayMode} - {budgetSimulation} - {budgetVariable} - /> + <GagnantsPerdantsView {displayMode} {budgetSimulation} {budgetVariable} /> </div> {/if} {/if} diff --git a/src/lib/components/parameters/ParameterView.svelte b/src/lib/components/parameters/ParameterView.svelte index 9baf94468a054380cdd8b3395fac369c894df11a..a267b2a1e100ba734b39d8aaa3256afd4d9329ff 100644 --- a/src/lib/components/parameters/ParameterView.svelte +++ b/src/lib/components/parameters/ParameterView.svelte @@ -208,7 +208,7 @@ >{getUnitByName(valueAtInstant.unit ?? parameter.unit) ?.ratio && typeof valueAtInstant.value === "number" ? parseFloat((valueAtInstant.value * 100).toFixed(8)) // trick to round value * 100 - : valueAtInstant.value ?? ""}</td + : (valueAtInstant.value ?? "")}</td > <td class="border p-1 text-center" >{getUnitShortLabel( diff --git a/src/lib/components/parameters/ValueAtInstantEdit.svelte b/src/lib/components/parameters/ValueAtInstantEdit.svelte index 699dd0b14b1d11a8d7a4731cc2b468725e3f4d37..6dc25d1028e75cc6598d4a74c5f815bcdc4f7669 100644 --- a/src/lib/components/parameters/ValueAtInstantEdit.svelte +++ b/src/lib/components/parameters/ValueAtInstantEdit.svelte @@ -103,10 +103,10 @@ return ( (valueAtInstant === "expected" ? null - : asMaybeNumberValue(valueAtInstant).value ?? null) !== + : (asMaybeNumberValue(valueAtInstant).value ?? null)) !== (oldValueAtInstant === "expected" ? null - : asMaybeNumberValue(oldValueAtInstant).value ?? null) + : (asMaybeNumberValue(oldValueAtInstant).value ?? null)) ) default: console.error(`TODO: Handle parameter of type ${parameter.type}.`) @@ -140,11 +140,11 @@ on:change={changeValue} value={valueAtInstant === "expected" ? null - : (errors.unit === undefined && + : ((errors.unit === undefined && getUnitAtDate(valueAtInstant?.unit, date)?.ratio && typeof valueAtInstant.value === "number" ? parseFloat((asNumberValue(valueAtInstant).value * 100).toFixed(8)) // trick to round value * 100 - : asMaybeNumberValue(valueAtInstant).value) ?? null} + : asMaybeNumberValue(valueAtInstant).value) ?? null)} /> {#if showErrors && errors.value !== undefined} <p>{errors.value}</p> diff --git a/src/lib/components/test_cases/TestCaseCompareView.svelte b/src/lib/components/test_cases/TestCaseCompareView.svelte index 16222703b6b9c72b7aa6397f5ce96b56e8d6f156..862d6fc35b6e6bda506d1dbc3a5b19b5c787c3b7 100644 --- a/src/lib/components/test_cases/TestCaseCompareView.svelte +++ b/src/lib/components/test_cases/TestCaseCompareView.svelte @@ -260,17 +260,19 @@ amendment: Object.keys($parametricReform).length === 0 ? undefined - : $evaluationByNameArray[situationsToCompareIndex[0]][ - displayMode.parametersVariableName - ]?.calculationEvaluationByName["amendment"] - ?.deltaAtVectorIndex ?? 0, + : ($evaluationByNameArray[ + situationsToCompareIndex[0] + ][displayMode.parametersVariableName] + ?.calculationEvaluationByName["amendment"] + ?.deltaAtVectorIndex ?? 0), bill: $billName === undefined ? undefined - : $evaluationByNameArray[situationsToCompareIndex[0]][ - displayMode.parametersVariableName - ]?.calculationEvaluationByName["bill"] - ?.deltaAtVectorIndex ?? 0, + : ($evaluationByNameArray[ + situationsToCompareIndex[0] + ][displayMode.parametersVariableName] + ?.calculationEvaluationByName["bill"] + ?.deltaAtVectorIndex ?? 0), law: $evaluationByNameArray[situationsToCompareIndex[0]][ displayMode.parametersVariableName @@ -279,26 +281,29 @@ revaluation: $revaluationName === undefined ? undefined - : $evaluationByNameArray[situationsToCompareIndex[0]][ - displayMode.parametersVariableName - ]?.calculationEvaluationByName["revaluation"] - ?.deltaAtVectorIndex ?? 0, + : ($evaluationByNameArray[ + situationsToCompareIndex[0] + ][displayMode.parametersVariableName] + ?.calculationEvaluationByName["revaluation"] + ?.deltaAtVectorIndex ?? 0), }} valueByCalculationName1={{ amendment: Object.keys($parametricReform).length === 0 ? undefined - : $evaluationByNameArray[situationsToCompareIndex[1]][ - displayMode.parametersVariableName - ]?.calculationEvaluationByName["amendment"] - ?.deltaAtVectorIndex ?? 0, + : ($evaluationByNameArray[ + situationsToCompareIndex[1] + ][displayMode.parametersVariableName] + ?.calculationEvaluationByName["amendment"] + ?.deltaAtVectorIndex ?? 0), bill: $billName === undefined ? undefined - : $evaluationByNameArray[situationsToCompareIndex[1]][ - displayMode.parametersVariableName - ]?.calculationEvaluationByName["bill"] - ?.deltaAtVectorIndex ?? 0, + : ($evaluationByNameArray[ + situationsToCompareIndex[1] + ][displayMode.parametersVariableName] + ?.calculationEvaluationByName["bill"] + ?.deltaAtVectorIndex ?? 0), law: $evaluationByNameArray[situationsToCompareIndex[1]][ displayMode.parametersVariableName @@ -307,10 +312,11 @@ revaluation: $revaluationName === undefined ? undefined - : $evaluationByNameArray[situationsToCompareIndex[1]][ - displayMode.parametersVariableName - ]?.calculationEvaluationByName["revaluation"] - ?.deltaAtVectorIndex ?? 0, + : ($evaluationByNameArray[ + situationsToCompareIndex[1] + ][displayMode.parametersVariableName] + ?.calculationEvaluationByName["revaluation"] + ?.deltaAtVectorIndex ?? 0), }} /> </div> diff --git a/src/lib/components/test_cases/TestCaseGraphXlsxExport.svelte b/src/lib/components/test_cases/TestCaseGraphXlsxExport.svelte index 967437b034a9989f39b35934c422276d3d0a3008..8390bdfaa9b6988e673148bf477cd3452436ce31 100644 --- a/src/lib/components/test_cases/TestCaseGraphXlsxExport.svelte +++ b/src/lib/components/test_cases/TestCaseGraphXlsxExport.svelte @@ -329,7 +329,7 @@ const thresholdValue = bracketAtInstant.threshold === "expected" ? undefined - : bracketAtInstant.threshold?.value ?? undefined + : (bracketAtInstant.threshold?.value ?? undefined) const xlsxRow = [ i === 0 ? parameter?.title : undefined, @@ -350,10 +350,10 @@ const amountValue = asAmountBracketAtInstant(bracketAtInstant).amount === "expected" ? undefined - : ( + : (( asAmountBracketAtInstant(bracketAtInstant) .amount as NumberValue - ).value ?? undefined + ).value ?? undefined) xlsxRow.push(formatValueWithUnit(amountValue, amountUnit)) } else { @@ -365,10 +365,10 @@ const baseValue = asRateBracketAtInstant(bracketAtInstant).base === "expected" ? undefined - : ( + : (( asRateBracketAtInstantOrNullable(bracketAtInstant) ?.base as NumberValue | undefined - )?.value ?? undefined + )?.value ?? undefined) xlsxRow.push(formatValueWithUnit(baseValue, thresholdUnit)) } @@ -381,10 +381,10 @@ const rateValue = asRateBracketAtInstant(bracketAtInstant).rate === "expected" ? undefined - : ( + : (( asRateBracketAtInstant(bracketAtInstant) .rate as MaybeNumberValue - )?.value ?? undefined + )?.value ?? undefined) xlsxRow.push(formatValueWithUnit(rateValue, rateUnit)) } diff --git a/src/lib/components/variables/VariableReferredParameters.svelte b/src/lib/components/variables/VariableReferredParameters.svelte index 0deb7723473b859b9456d606f245337c981f3b4f..1fe99aff2ca4328c988fc6ca4b2057b289afec2f 100644 --- a/src/lib/components/variables/VariableReferredParameters.svelte +++ b/src/lib/components/variables/VariableReferredParameters.svelte @@ -90,10 +90,10 @@ $: bothDirectParametersName = new Set([ ...(lawVariable === undefined ? [] - : getVariableFormula(lawVariable, date)?.parameters ?? []), + : (getVariableFormula(lawVariable, date)?.parameters ?? [])), ...(billVariable === undefined ? [] - : getVariableFormula(billVariable, date)?.parameters ?? []), + : (getVariableFormula(billVariable, date)?.parameters ?? [])), ]) $: bothRootParameterById = mergeParameters( diff --git a/src/lib/components/variables/VariableReferredScaleAtInstant.svelte b/src/lib/components/variables/VariableReferredScaleAtInstant.svelte index f52bcde0592eb2714e2f75093840b7e72696fa22..18ae67b069a8e314039a39b04aaf459bedb4e6b1 100644 --- a/src/lib/components/variables/VariableReferredScaleAtInstant.svelte +++ b/src/lib/components/variables/VariableReferredScaleAtInstant.svelte @@ -240,7 +240,7 @@ unit={getUnitAtDate(billParameter.threshold_unit, date)} value={bracketAtInstant.threshold === "expected" ? null - : bracketAtInstant.threshold?.value ?? null} + : (bracketAtInstant.threshold?.value ?? null)} /> {:else} <VariableReferredValueView @@ -291,9 +291,9 @@ value={asAmountBracketAtInstant(bracketAtInstant) .amount === "expected" ? null - : asNumberValue( + : (asNumberValue( asAmountBracketAtInstant(bracketAtInstant).amount, - ).value ?? null} + ).value ?? null)} /> {:else} <VariableReferredValueView @@ -352,10 +352,10 @@ value={asRateBracketAtInstant(bracketAtInstant).base === "expected" ? null - : asNumberValueOrNullable( + : (asNumberValueOrNullable( asRateBracketAtInstantOrNullable(bracketAtInstant) ?.base, - )?.value ?? null} + )?.value ?? null)} /> {:else} <VariableReferredValueView @@ -411,9 +411,9 @@ value={asRateBracketAtInstant(bracketAtInstant).rate === "expected" ? null - : asMaybeNumberValue( + : (asMaybeNumberValue( asRateBracketAtInstant(bracketAtInstant).rate, - )?.value ?? null} + )?.value ?? null)} /> {:else} <VariableReferredValueView diff --git a/src/lib/components/variables/VariableReferredValueEdit.svelte b/src/lib/components/variables/VariableReferredValueEdit.svelte index e00bf9a416765f985212ec5753d17996ea82845c..c3c70592d47068917e9b8a3ffe31d0e0fb23a98e 100644 --- a/src/lib/components/variables/VariableReferredValueEdit.svelte +++ b/src/lib/components/variables/VariableReferredValueEdit.svelte @@ -168,7 +168,7 @@ ? billValue?.value : isRevaluationActive ? revaluationValue?.value - : lawValue?.value ?? "", + : (lawValue?.value ?? ""), )} > <iconify-icon class="block p-1 text-xl" icon="ri-close-line" /> diff --git a/src/lib/variables.ts b/src/lib/variables.ts index b4388621b063eed2e25fb136d53e9a5a00f0b4e8..7f18b2db09d4d2b110a1488ba7f16cadd1e8d3c5 100644 --- a/src/lib/variables.ts +++ b/src/lib/variables.ts @@ -405,13 +405,13 @@ export const budgetVariablesConfig: { [variableName: string]: BudgetVariable } = }, organisme: "securite_sociale", outputVariables: [ - "rfr_par_part", + "rfr_par_part", "allegement_general", "cotisations_allegement_general", ], quantileBaseVariable: ["rfr_par_part"], quantileCompareVariables: [ - "allegement_general", + "allegement_general", "rfr", "cotisations_allegement_general", ], @@ -490,13 +490,13 @@ export const budgetVariablesConfig: { [variableName: string]: BudgetVariable } = }, organisme: "securite_sociale", outputVariables: [ - "rfr_par_part", + "rfr_par_part", "allegement_general", "cotisations_allegement_general", ], quantileBaseVariable: ["rfr_par_part"], quantileCompareVariables: [ - "allegement_general", + "allegement_general", "rfr", "cotisations_allegement_general", ], diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 10c5ccc29a49128239a86fc042c96c245ac2f154..1fb94f7bc8706f7ff14274836ecdb9f5a280d08f 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -137,8 +137,8 @@ buildDecompositionByNameFromCore( currentBillName === undefined ? decompositionCoreByName - : decompositionCoreByNameByReformName[currentBillName] ?? - decompositionCoreByName, + : (decompositionCoreByNameByReformName[currentBillName] ?? + decompositionCoreByName), ), ) setContext("decompositionByName", decompositionByName) @@ -997,8 +997,8 @@ const calculationNonVirtualVariablesName = calculationName === "law" ? nonVirtualVariablesName - : nonVirtualVariablesNameByReformName[$billName as string] ?? - nonVirtualVariablesName + : (nonVirtualVariablesNameByReformName[$billName as string] ?? + nonVirtualVariablesName) if (calculationNonVirtualVariablesName.includes(variableName)) { if (calculation.situationIndex === undefined) { // Variable has been computed for all test cases. @@ -1139,8 +1139,8 @@ const newDecompositionByName = buildDecompositionByNameFromCore( currentBillName === undefined ? decompositionCoreByName - : decompositionCoreByNameByReformName[currentBillName] ?? - decompositionCoreByName, + : (decompositionCoreByNameByReformName[currentBillName] ?? + decompositionCoreByName), ) as DecompositionByName const oldDecompositionByName = $decompositionByName for (const [name, decomposition] of Object.entries( diff --git a/static/google30e702e970279341.html b/static/google30e702e970279341.html index a02a6e069b72110f4ab34cfb9f56c70610ca4888..2c589961e4db10eb2947f5027bf26920a34fff3d 100644 --- a/static/google30e702e970279341.html +++ b/static/google30e702e970279341.html @@ -1 +1 @@ -google-site-verification: google30e702e970279341.html \ No newline at end of file +google-site-verification: google30e702e970279341.html