From 3a165c1978bc48646170ec3ad878f26a4d000d10 Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart Date: Sat, 4 Mar 2023 10:16:47 +0100 Subject: [PATCH] Prettify & lint --- src/lib/auditors/jorf/articles.ts | 1 - src/lib/auditors/legi/articles.ts | 2 - src/lib/auditors/legi/texte_version.ts | 52 -------------------- src/lib/auditors/legi/textelr.ts | 1 - src/lib/components/IdPagesSwitcher.svelte | 2 +- src/lib/components/SectionTaView.svelte | 1 - src/lib/server/database/configuration.ts | 1 - src/lib/summaries.ts | 4 +- src/routes/api/textes/natures/+server.ts | 2 +- src/routes/articles/[id]/+page.svelte | 5 +- src/routes/textes/+page.svelte | 2 +- src/routes/textes/[id]/+page.svelte | 11 +++-- src/scripts/export_dole_echeancier_to_csv.ts | 2 +- src/scripts/import_dole.ts | 2 +- src/scripts/import_jorf.ts | 4 +- src/scripts/import_kali.ts | 2 +- src/scripts/import_legi.ts | 2 +- 17 files changed, 21 insertions(+), 75 deletions(-) diff --git a/src/lib/auditors/jorf/articles.ts b/src/lib/auditors/jorf/articles.ts index d46f2fd..a4ed30c 100644 --- a/src/lib/auditors/jorf/articles.ts +++ b/src/lib/auditors/jorf/articles.ts @@ -4,7 +4,6 @@ import { auditEmptyToNull, auditFunction, auditHttpUrl, - auditInteger, auditNullish, auditNumber, auditOptions, diff --git a/src/lib/auditors/legi/articles.ts b/src/lib/auditors/legi/articles.ts index 4771d64..fc28880 100644 --- a/src/lib/auditors/legi/articles.ts +++ b/src/lib/auditors/legi/articles.ts @@ -3,8 +3,6 @@ import { auditDateIso8601String, auditEmptyToNull, auditFunction, - auditHttpUrl, - auditInteger, auditNumber, auditOptions, auditRequire, diff --git a/src/lib/auditors/legi/texte_version.ts b/src/lib/auditors/legi/texte_version.ts index 84b966b..36e19e3 100644 --- a/src/lib/auditors/legi/texte_version.ts +++ b/src/lib/auditors/legi/texte_version.ts @@ -674,31 +674,6 @@ function auditNota(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } -function auditNotice(audit: Audit, dataUnknown: unknown): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - audit.attribute( - data, - "CONTENU", - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} - function auditRect(audit: Audit, dataUnknown: unknown): [unknown, unknown] { if (dataUnknown == null) { return [dataUnknown, null] @@ -752,33 +727,6 @@ function auditSignataires( return audit.reduceRemaining(data, errors, remainingKeys) } -function auditSm(audit: Audit, dataUnknown: unknown): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - audit.attribute( - data, - "CONTENU", - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditFunction((num) => num.toString())], - [auditTrimString, auditEmptyToNull], - ), - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} - function auditTp(audit: Audit, dataUnknown: unknown): [unknown, unknown] { if (dataUnknown == null) { return [dataUnknown, null] diff --git a/src/lib/auditors/legi/textelr.ts b/src/lib/auditors/legi/textelr.ts index 0cb5e7d..bba17bc 100644 --- a/src/lib/auditors/legi/textelr.ts +++ b/src/lib/auditors/legi/textelr.ts @@ -3,7 +3,6 @@ import { auditDateIso8601String, auditEmptyToNull, auditFunction, - auditHttpUrl, auditInteger, auditNullish, auditNumber, diff --git a/src/lib/components/IdPagesSwitcher.svelte b/src/lib/components/IdPagesSwitcher.svelte index acc8526..8615765 100644 --- a/src/lib/components/IdPagesSwitcher.svelte +++ b/src/lib/components/IdPagesSwitcher.svelte @@ -12,7 +12,7 @@ {#if items !== undefined}
{#each items as { href, label }} - {label} {/each} diff --git a/src/lib/components/SectionTaView.svelte b/src/lib/components/SectionTaView.svelte index 361e849..442cab8 100644 --- a/src/lib/components/SectionTaView.svelte +++ b/src/lib/components/SectionTaView.svelte @@ -1,6 +1,5 @@ diff --git a/src/routes/textes/+page.svelte b/src/routes/textes/+page.svelte index 3bfc458..05171ce 100644 --- a/src/routes/textes/+page.svelte +++ b/src/routes/textes/+page.svelte @@ -4,7 +4,7 @@ import { page } from "$app/stores" import Pagination from "$lib/components/Pagination.svelte" - import type { Article, SectionTa, Textelr, TexteVersion } from "$lib/legal" + import type { TexteVersion } from "$lib/legal" import { summarizeTexteVersionProperties } from "$lib/summaries" import type { PageData } from "./$types" diff --git a/src/routes/textes/[id]/+page.svelte b/src/routes/textes/[id]/+page.svelte index aa58169..1173c1d 100644 --- a/src/routes/textes/[id]/+page.svelte +++ b/src/routes/textes/[id]/+page.svelte @@ -6,6 +6,7 @@ import type { Follow } from "$lib/aggregates" import IdPagesSwitcher from "$lib/components/IdPagesSwitcher.svelte" import TexteVersionView from "$lib/components/TexteVersionView.svelte" + import type { TexteVersion } from "$lib/legal" import { summarizeLegalObject } from "$lib/summaries" import type { PageData } from "./$types" @@ -16,8 +17,10 @@ let showRawData = false $: follow = data.follow - $: id = data.id! - $: texteVersion = data.texte_version![id] + $: id = data.id + $: texteVersion = ( + data.texte_version as { [texteVersionId: string]: TexteVersion } + )[id] $: url = $page.url $: summary = summarizeLegalObject( @@ -45,8 +48,8 @@ searchParams.append("follow", aFollow) } goto(new URL(`${url.pathname}?${searchParams.toString()}`, url), { - keepfocus: true, - noscroll: true, + keepFocus: true, + noScroll: true, }) } diff --git a/src/scripts/export_dole_echeancier_to_csv.ts b/src/scripts/export_dole_echeancier_to_csv.ts index 7dca9ed..dddc518 100644 --- a/src/scripts/export_dole_echeancier_to_csv.ts +++ b/src/scripts/export_dole_echeancier_to_csv.ts @@ -62,7 +62,7 @@ async function exportEcheanciers(csvFilePath: string): Promise { } } } - const csvFile = await fs.writeFile( + await fs.writeFile( csvFilePath, Papa.unparse(data, { columns: [ diff --git a/src/scripts/import_dole.ts b/src/scripts/import_dole.ts index ecc9c07..957d31b 100644 --- a/src/scripts/import_dole.ts +++ b/src/scripts/import_dole.ts @@ -47,7 +47,7 @@ async function importDole( iterXmlFiles: for (const relativeSplitPath of walkDir(dataDir)) { const relativePath = path.join(...relativeSplitPath) if (skip) { - if (relativePath.startsWith(resume!)) { + if (relativePath.startsWith(resume as string)) { skip = false console.log(`Resuming at file ${relativePath}...`) } else { diff --git a/src/scripts/import_jorf.ts b/src/scripts/import_jorf.ts index 882a57c..aaa3d74 100644 --- a/src/scripts/import_jorf.ts +++ b/src/scripts/import_jorf.ts @@ -22,7 +22,7 @@ import { // jorfArticleStats, // jorfSectionTaStats, // joStats, - jorfTextelrStats, + // jorfTextelrStats, // jorfTexteVersionStats, } from "$lib/auditors/jorf" import type { @@ -175,7 +175,7 @@ async function importJorf( iterXmlFiles: for (const relativeSplitPath of walkDir(dataDir)) { const relativePath = path.join(...relativeSplitPath) if (skip) { - if (relativePath.startsWith(resume!)) { + if (relativePath.startsWith(resume as string)) { skip = false console.log(`Resuming at file ${relativePath}...`) } else { diff --git a/src/scripts/import_kali.ts b/src/scripts/import_kali.ts index 5127791..c2bd825 100644 --- a/src/scripts/import_kali.ts +++ b/src/scripts/import_kali.ts @@ -102,7 +102,7 @@ async function importKali( iterXmlFiles: for (const relativeSplitPath of walkDir(dataDir)) { const relativePath = path.join(...relativeSplitPath) if (skip) { - if (relativePath.startsWith(resume!)) { + if (relativePath.startsWith(resume as string)) { skip = false console.log(`Resuming at file ${relativePath}...`) } else { diff --git a/src/scripts/import_legi.ts b/src/scripts/import_legi.ts index 97f9c7a..88f9ad2 100644 --- a/src/scripts/import_legi.ts +++ b/src/scripts/import_legi.ts @@ -160,7 +160,7 @@ async function importLegi( iterXmlFiles: for (const relativeSplitPath of walkDir(dataDir)) { const relativePath = path.join(...relativeSplitPath) if (skip) { - if (relativePath.startsWith(resume!)) { + if (relativePath.startsWith(resume as string)) { skip = false console.log(`Resuming at file ${relativePath}...`) } else {