From 12bf7e3181f1e5f2cd58dfdc12fafb71ffe5c987 Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart <emmanuel@raviart.com> Date: Mon, 16 Sep 2024 10:45:24 +0200 Subject: [PATCH] Prettify --- eslint.config.js | 19 ++++--- src/lib/calculations.ts | 4 +- src/lib/components/ModificationsPanel.svelte | 4 +- src/lib/components/ReformsChanges.svelte | 4 +- src/lib/components/WaterfallPlainView.svelte | 4 +- .../components/budget/BudgetDetailView.svelte | 2 +- src/lib/components/budget/BudgetLayout.svelte | 12 +---- .../parameters/ParameterView.svelte | 2 +- .../parameters/ValueAtInstantEdit.svelte | 8 +-- .../test_cases/TestCaseCompareView.svelte | 54 ++++++++++--------- .../test_cases/TestCaseGraphXlsxExport.svelte | 14 ++--- .../VariableReferredParameters.svelte | 4 +- .../VariableReferredScaleAtInstant.svelte | 14 ++--- .../VariableReferredValueEdit.svelte | 2 +- src/lib/variables.ts | 8 +-- src/routes/+layout.svelte | 12 ++--- static/google30e702e970279341.html | 2 +- 17 files changed, 85 insertions(+), 84 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index c19b64f71..2710f3765 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 acf5a1c2c..6f0b25def 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 54d072487..aa31ad699 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 dd8d05a13..d82fdead1 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 0e5e79123..b7f1e16b0 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 6c774e9a8..ce895cf73 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 2f3737596..358884409 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 9baf94468..a267b2a1e 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 699dd0b14..6dc25d102 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 16222703b..862d6fc35 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 967437b03..8390bdfaa 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 0deb77234..1fe99aff2 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 f52bcde05..18ae67b06 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 e00bf9a41..c3c70592d 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 b4388621b..7f18b2db0 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 10c5ccc29..1fb94f7bc 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 a02a6e069..2c589961e 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 -- GitLab