From 18e94c974ecc8a4474335dee855e44b4025cdee5 Mon Sep 17 00:00:00 2001
From: Emmanuel Raviart <emmanuel@raviart.com>
Date: Thu, 9 Jan 2025 14:00:10 +0100
Subject: [PATCH] Corrections d'erreurs de lint

---
 eslint.config.js                              | 14 +++++++-----
 gitlab-ci/src/gitlab-ci.ts                    | 22 +++++--------------
 package-lock.json                             | 19 ++++++++++++++++
 package.json                                  |  1 +
 plugin-yaml-patched.ts                        |  1 -
 src/global.d.ts                               |  1 -
 src/lib/calculations.svelte.ts                |  2 +-
 src/lib/components/Autocomplete.svelte        |  3 +++
 .../variables/VariableHeader.svelte           |  8 +++----
 .../VariableReferredScaleAtInstant.svelte     |  1 +
 .../VariableReferredValueParameter.svelte     |  1 -
 .../components/variables/VariableView.svelte  |  7 +++---
 src/lib/parameters.ts                         |  1 -
 src/lib/server/auditors/server_config.ts      |  6 -----
 src/routes/auth/login_callback/+server.ts     |  7 +-----
 src/routes/contribuer/+page.svelte            |  2 --
 .../parameters/[parameter]/edit/+page.svelte  |  1 -
 .../parameters/[parameter]/edit/+page.ts      |  3 +--
 src/routes/variables/[variable]/+page.svelte  |  3 +++
 19 files changed, 52 insertions(+), 51 deletions(-)

diff --git a/eslint.config.js b/eslint.config.js
index aec617c49..ef39ed78d 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -1,11 +1,15 @@
+import { includeIgnoreFile } from "@eslint/compat"
 import js from "@eslint/js"
-import ts from "typescript-eslint"
-import svelte from "eslint-plugin-svelte"
 import prettier from "eslint-config-prettier"
 import globals from "globals"
+import svelte from "eslint-plugin-svelte"
+import { fileURLToPath } from "node:url"
+import ts from "typescript-eslint"
+
+const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url))
 
-/** @type {import('eslint').Linter.Config[]} */
-export default [
+export default ts.config(
+  includeIgnoreFile(gitignorePath),
   js.configs.recommended,
   ...ts.configs.recommended,
   ...svelte.configs["flat/recommended"],
@@ -50,4 +54,4 @@ export default [
   {
     ignores: ["build/", ".svelte-kit/", "dist/", "gitlab-ci/build/"],
   },
-]
+)
diff --git a/gitlab-ci/src/gitlab-ci.ts b/gitlab-ci/src/gitlab-ci.ts
index 5948c582d..fbe0e81c4 100644
--- a/gitlab-ci/src/gitlab-ci.ts
+++ b/gitlab-ci/src/gitlab-ci.ts
@@ -65,10 +65,8 @@ async function commitAndPushWithUpdatedVersions(
     // Retrieve next version of project.
     nextVersionObject = await latestVersionObjectFromTags()
     assert.notStrictEqual(nextVersionObject, undefined)
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     nextVersionObject!.patch++
   }
-  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
   const nextVersion = versionFromObject(nextVersionObject!)
 
   if ((await $`git diff --quiet --staged`.exitCode) !== 0) {
@@ -159,16 +157,11 @@ async function latestVersionObjectFromTags(): Promise<
     .map(objectFromVersion)
     .filter((versionObject) => versionObject !== undefined)
     .sort((versionObject1, versionObject2) =>
-      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-      versionObject1!.major !== versionObject2!.major
-        ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-          versionObject2!.major - versionObject1!.major
-        : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-          versionObject1!.minor !== versionObject2!.minor
-          ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-            versionObject2!.minor - versionObject1!.minor
-          : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-            versionObject2!.patch - versionObject1!.patch,
+      versionObject1.major !== versionObject2.major
+        ? versionObject2.major - versionObject1.major
+        : versionObject1.minor !== versionObject2.minor
+          ? versionObject2.minor - versionObject1.minor
+          : versionObject2.patch - versionObject1.patch,
     )[0]
 }
 
@@ -314,8 +307,7 @@ async function nextVersionObjectFromPackageAndTags(
   const tagVersion = versionFromObject(tagVersionObject)
   let nextVersionObject = {
     ...tagVersionObject,
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    patch: tagVersionObject!.patch + 1,
+    patch: tagVersionObject.patch + 1,
   }
 
   // Ensure that the version numbers of project packages are
@@ -373,7 +365,6 @@ async function triggerDevDeployPipeline() {
   const response = await fetch(urlString, {
     body: new URLSearchParams({
       ref: "master",
-      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
       token: CI_JOB_TOKEN!,
     }).toString(),
     headers: {
@@ -400,7 +391,6 @@ async function triggerProdDeployPipeline() {
   const response = await fetch(urlString, {
     body: new URLSearchParams({
       ref: "master",
-      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
       token: CI_JOB_TOKEN!,
     }).toString(),
     headers: {
diff --git a/package-lock.json b/package-lock.json
index 875c44f78..91e2ae6fd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
       "version": "0.0.945",
       "devDependencies": {
         "@auditors/core": "^0.7.0",
+        "@eslint/compat": "^1.2.4",
         "@fontsource/lato": "^5.0.5",
         "@fontsource/lora": "^5.0.5",
         "@leximpact/socio-fiscal-openfisca-json": "^0.0.294",
@@ -709,6 +710,24 @@
         "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
       }
     },
+    "node_modules/@eslint/compat": {
+      "version": "1.2.4",
+      "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.4.tgz",
+      "integrity": "sha512-S8ZdQj/N69YAtuqFt7653jwcvuUj131+6qGLUyDqfDg1OIoBQ66OCuXC473YQfO2AaxITTutiRQiDwoo7ZLYyg==",
+      "dev": true,
+      "license": "Apache-2.0",
+      "engines": {
+        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+      },
+      "peerDependencies": {
+        "eslint": "^9.10.0"
+      },
+      "peerDependenciesMeta": {
+        "eslint": {
+          "optional": true
+        }
+      }
+    },
     "node_modules/@eslint/config-array": {
       "version": "0.19.1",
       "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.19.1.tgz",
diff --git a/package.json b/package.json
index 185820cb8..e61505097 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
   },
   "devDependencies": {
     "@auditors/core": "^0.7.0",
+    "@eslint/compat": "^1.2.4",
     "@fontsource/lato": "^5.0.5",
     "@fontsource/lora": "^5.0.5",
     "@leximpact/socio-fiscal-openfisca-json": "^0.0.294",
diff --git a/plugin-yaml-patched.ts b/plugin-yaml-patched.ts
index 159717732..557eed831 100644
--- a/plugin-yaml-patched.ts
+++ b/plugin-yaml-patched.ts
@@ -49,7 +49,6 @@ export default function yaml(opts: Options = {}): PluginOption {
 
       if (typeof options.transform === "function") {
         const result = options.transform(data, id)
-        // eslint-disable-next-line no-undefined
         if (result !== undefined) {
           data = result
         }
diff --git a/src/global.d.ts b/src/global.d.ts
index 71d497c7a..357a61643 100644
--- a/src/global.d.ts
+++ b/src/global.d.ts
@@ -5,7 +5,6 @@
 // https://github.com/sveltejs/language-tools/issues/431.
 declare type DndEvent = import("svelte-dnd-action").DndEvent
 declare namespace svelte.JSX {
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
   interface HTMLAttributes<T> {
     onconsider?: (
       event: CustomEvent<DndEvent> & { target: EventTarget & T },
diff --git a/src/lib/calculations.svelte.ts b/src/lib/calculations.svelte.ts
index 52851071f..8f042fa07 100644
--- a/src/lib/calculations.svelte.ts
+++ b/src/lib/calculations.svelte.ts
@@ -687,7 +687,7 @@ async function sendTestCasesSimulation(
 
     let calculation = shared.calculationByName[calculationName] as Calculation
 
-    let updatedEvaluationByNameArray =
+    const updatedEvaluationByNameArray =
       calculation.situationIndex === undefined
         ? shared.evaluationByNameArray
         : [...shared.evaluationByNameArray]
diff --git a/src/lib/components/Autocomplete.svelte b/src/lib/components/Autocomplete.svelte
index d6457444b..536a5c193 100644
--- a/src/lib/components/Autocomplete.svelte
+++ b/src/lib/components/Autocomplete.svelte
@@ -223,8 +223,10 @@
   bind:clientWidth={width}
   onclick={stopPropagation(bubble("click"))}
   onkeyup={bubble("keyup")}
+  role="none"
 >
   <input
+    aria-autocomplete="list"
     autocomplete="off"
     bind:this={inputField}
     class={inputClass}
@@ -249,6 +251,7 @@
         : ''}
       z-10 shadow-md"
       onmousedown={preventDefault(bubble("mousedown"))}
+      role="menu"
       style="min-width: {width}px"
     >
       {#each filteredItems as result, index}
diff --git a/src/lib/components/variables/VariableHeader.svelte b/src/lib/components/variables/VariableHeader.svelte
index c6c58bcae..2166bf203 100644
--- a/src/lib/components/variables/VariableHeader.svelte
+++ b/src/lib/components/variables/VariableHeader.svelte
@@ -143,11 +143,11 @@
   <!--Description du dispositif-->
   {#if descriptionsByInstant !== undefined}
     <!--Add variable descriptions as described in decomposition customization and order them by date. -->
-    {@const [latestInstant, latestDescriptions] = Object.entries(
-      descriptionsByInstant,
-    ).sort(([instant1], [instant2]) => instant2.localeCompare(instant1))[0]}
+    {@const [, latestDescriptions] = Object.entries(descriptionsByInstant).sort(
+      ([instant1], [instant2]) => instant2.localeCompare(instant1),
+    )[0]}
     {#if latestDescriptions !== undefined && latestDescriptions.length > 0}
-      {@const { href, note, title } = latestDescriptions[0]}
+      {@const { note } = latestDescriptions[0]}
       <article class="mr-4">
         <div class="">
           {#if note !== undefined}
diff --git a/src/lib/components/variables/VariableReferredScaleAtInstant.svelte b/src/lib/components/variables/VariableReferredScaleAtInstant.svelte
index b928efbca..bd0e9f69e 100644
--- a/src/lib/components/variables/VariableReferredScaleAtInstant.svelte
+++ b/src/lib/components/variables/VariableReferredScaleAtInstant.svelte
@@ -240,6 +240,7 @@
                 <div class="flex items-end gap-1">
                   {#if edit}
                     <button
+                      aria-label="Supprimer"
                       class="group mb-1 rounded p-1 hover:bg-gray-200 active:bg-gray-300"
                       onclick={() => deleteBracket(index)}
                       title="Supprimer"
diff --git a/src/lib/components/variables/VariableReferredValueParameter.svelte b/src/lib/components/variables/VariableReferredValueParameter.svelte
index 54f547346..4ac32f75a 100644
--- a/src/lib/components/variables/VariableReferredValueParameter.svelte
+++ b/src/lib/components/variables/VariableReferredValueParameter.svelte
@@ -380,7 +380,6 @@
           </p>
           <button
             class="hover:decoration-none flex px-1 pb-2 pr-2 text-sm tracking-wide text-black underline decoration-dotted hover:decoration-solid"
-            rel="noreferrer"
             onclick={() => {
               goto(`/parameters/${billParameter.name}/edit`)
               trackLawEditParameterStatus()
diff --git a/src/lib/components/variables/VariableView.svelte b/src/lib/components/variables/VariableView.svelte
index 7df0ec2c4..ff3810093 100644
--- a/src/lib/components/variables/VariableView.svelte
+++ b/src/lib/components/variables/VariableView.svelte
@@ -68,7 +68,7 @@
         {#if variable.label !== undefined}
           <p class="font-serif text-3xl font-bold">{variable.label}</p>
         {/if}
-        {#each buildInstantFormulaAndReferencesArray(variable) as { formula, instant, references }}
+        {#each buildInstantFormulaAndReferencesArray(variable) as { instant, references }}
           {#if references.length > 0}
             <div class="">
               {#each references as { href, note, title }}
@@ -101,7 +101,7 @@
             <VariableInput
               {date}
               bind:inputInstantsByVariableName
-              bind:situation
+              {situation}
               {situationIndex}
               bind:valuesByCalculationNameByVariableName
               {variable}
@@ -183,7 +183,7 @@
             </div>
           {/if}
 
-          {#each buildInstantFormulaAndReferencesArray(variable) as { formula, instant, references }}
+          {#each buildInstantFormulaAndReferencesArray(variable) as { formula, instant }}
             <p class="mt-5 text-xl font-bold">
               {#if formula === undefined}
                 <!-- {#if instant !== "0001-01-01"}
@@ -221,7 +221,6 @@
 
         <div class="flex-col">
           <div class="px-5">
-            <!-- svelte-ignore a11y_missing_attribute -->
             <a
               class="lx-link-text text-base text-gray-900"
               {...newSelfTargetAProps(
diff --git a/src/lib/parameters.ts b/src/lib/parameters.ts
index 4e213b74e..f529ef76e 100644
--- a/src/lib/parameters.ts
+++ b/src/lib/parameters.ts
@@ -54,7 +54,6 @@ export const rootParameterByReformName: { [name: string]: NodeParameter } =
 
 export const leafParametersName = new Set<string>()
 for (const parameter of walkParameters(rootParameter)) {
-  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
   leafParametersName.add(parameter.name!)
 }
 
diff --git a/src/lib/server/auditors/server_config.ts b/src/lib/server/auditors/server_config.ts
index 543d07431..417a21233 100644
--- a/src/lib/server/auditors/server_config.ts
+++ b/src/lib/server/auditors/server_config.ts
@@ -1,17 +1,11 @@
 import {
   auditBoolean,
-  auditCleanArray,
-  auditFunction,
   auditHttpUrl,
-  auditInteger,
   auditRequire,
   auditSetNullish,
-  auditString,
   auditStringToBoolean,
-  auditStringToNumber,
   auditSwitch,
   auditTrimString,
-  auditUnique,
   cleanAudit,
   type Audit,
 } from "@auditors/core"
diff --git a/src/routes/auth/login_callback/+server.ts b/src/routes/auth/login_callback/+server.ts
index 2c528b75e..c0946b98e 100644
--- a/src/routes/auth/login_callback/+server.ts
+++ b/src/routes/auth/login_callback/+server.ts
@@ -8,12 +8,7 @@ import type { SigninPayload } from "$lib/users"
 
 import type { RequestHandler } from "./$types"
 
-export const GET: RequestHandler = async ({
-  cookies,
-  locals,
-  request,
-  url,
-}) => {
+export const GET: RequestHandler = async ({ cookies, locals, url }) => {
   const { openIdConnectConfiguration } = locals
   if (openIdConnectConfiguration === undefined) {
     console.error(`No authentication method defined`)
diff --git a/src/routes/contribuer/+page.svelte b/src/routes/contribuer/+page.svelte
index 5cf6fb7e9..8bc8ddd01 100644
--- a/src/routes/contribuer/+page.svelte
+++ b/src/routes/contribuer/+page.svelte
@@ -1,6 +1,4 @@
 <script lang="ts">
-  import type { PageData } from "./$types"
-
   import { goto } from "$app/navigation"
   import publicConfig from "$lib/public_config"
 
diff --git a/src/routes/parameters/[parameter]/edit/+page.svelte b/src/routes/parameters/[parameter]/edit/+page.svelte
index 8bb5559a5..5af501b03 100644
--- a/src/routes/parameters/[parameter]/edit/+page.svelte
+++ b/src/routes/parameters/[parameter]/edit/+page.svelte
@@ -165,7 +165,6 @@
               <h2 class="text-base">Parents du paramètre&nbsp;:</h2>
               <div class="flex-col">
                 {#each [...iterParameterAncestors(processedParameter.parent)] as ancestor}
-                  <!-- svelte-ignore a11y_missing_attribute -->
                   <a
                     class="lx-link-text font-serif text-sm text-gray-500"
                     {...newSelfTargetAProps(`/parameters/${ancestor.name}`)}
diff --git a/src/routes/parameters/[parameter]/edit/+page.ts b/src/routes/parameters/[parameter]/edit/+page.ts
index dd323309c..65657efab 100644
--- a/src/routes/parameters/[parameter]/edit/+page.ts
+++ b/src/routes/parameters/[parameter]/edit/+page.ts
@@ -16,8 +16,7 @@ import { units } from "$lib/units"
 
 const { openfiscaRepository } = publicConfig
 
-export const load: PageLoad = async function ({ fetch, params, parent }) {
-  const data = await parent()
+export const load: PageLoad = async function ({ fetch, params }) {
   const { parameter: name } = params
   const processedParameter = getParameter(rootParameter, name)
   if (processedParameter === undefined) {
diff --git a/src/routes/variables/[variable]/+page.svelte b/src/routes/variables/[variable]/+page.svelte
index c7d11e4fb..ed4e14ccc 100644
--- a/src/routes/variables/[variable]/+page.svelte
+++ b/src/routes/variables/[variable]/+page.svelte
@@ -82,6 +82,9 @@
       valuesByCalculationNameByVariableName,
     ),
   )
+  $effect(() => {
+    updateInputInstantsByVariableName(inputInstantsByVariableName)
+  })
 </script>
 
 <svelte:head>
-- 
GitLab