diff --git a/eslint.config.js b/eslint.config.js index aec617c49671df001678d8aff02d7d87682b195f..ef39ed78dbb9f4ad560e229bf441dfb50fc6feb4 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 5948c582ddccb162c03a8416881fa2d913561364..fbe0e81c465056569c8b807079f5d77ae33e7982 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 875c44f7844bbf28ab207e09fa5ff0cb0668cd5f..91e2ae6fd96a86f9132477688d77e35d3c4e07c7 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 185820cb80f6ff8cf6c4790856e41564f24fd5d7..e6150509714571c6cdc8082813ac929fc5188e09 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 159717732d5f02fe71483e0319e843cfac0cf983..557eed831a4e796605a193a5d13e3b5e5ff0db54 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 71d497c7ac8f2dfb169144d34195244a4eab4dbc..357a61643b91e989384c05d8751b418301c8709c 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 52851071fb419cd5647b6856e1c8c084c6002597..8f042fa078d3e1ee67483208106513b9b6935d1b 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 d6457444b5d8e40f5fc0a0050d26615649bfcccc..536a5c193164ac6ac40c6deed3d7d720b93a1501 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 c6c58bcae2816aa79775c0828e66a25e23aaf77c..2166bf203a77e6996c5de5d7809a661663febf04 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 b928efbca7fe1e320afb7c7c6d98a1c41600bddc..bd0e9f69ead2fdbe5d92248aabefdadf8eb371a7 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 54f547346726adf2e29ebaffadebf6e0f1cd982f..4ac32f75a259e4fbd37d4f46345f637e83230f92 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 7df0ec2c48a0ae1a0bd5ac147dc7bab3254658ef..ff381009351cdae67a27d41004d7f93a77f8648c 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 4e213b74e1333aaac2924d0cb8114f21b0c41cd7..f529ef76ed7e601e36968336d2a9be60bed4d2f1 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 543d074315ab48b9641ff6b02a0460e8d8f83228..417a21233eece33dbc1d252f6be640dec60f57f1 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 2c528b75e7c4c1e342a3c6344269383730b7c16f..c0946b98e08b3f9862f127d2c88c55c4016db6ac 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 5cf6fb7e948be87a210c66a43c463a2c1c1c6e05..8bc8ddd01a280cabdd2d1e9f6ef491d1676d0074 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 8bb5559a5b21fea0fab445dc9275c029eb322446..5af501b03bc1d68cdd98a23216b360d818a1e309 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 :</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 dd323309c8daae5b6d559edb1f4ccb4631e0d26f..65657efab8d8ce96143fac1b75bdb4c087f5a489 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 c7d11e4fb0a822da22cd7f49436c429256601f59..ed4e14cccea2bfd2a8ac87278f22f8b4b5479b5b 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>