From c3f472c7c9b721b0a85bf737806ee97b04050ae4 Mon Sep 17 00:00:00 2001 From: Nicolas Froidure Date: Tue, 21 Nov 2023 15:17:37 +0100 Subject: [PATCH] fix(lint): fix linting --- src/pages/conferences/index.tsx | 10 +++------- src/utils/markdown.tsx | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/pages/conferences/index.tsx b/src/pages/conferences/index.tsx index d0f23432..55ba81db 100644 --- a/src/pages/conferences/index.tsx +++ b/src/pages/conferences/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import useSWR from 'swr'; -import lunr from 'lunr'; +import lunr, { type Index } from 'lunr'; import { join as pathJoin } from 'path'; import Layout from '../../layouts/main'; import ContentBlock from '../../components/contentBlock'; @@ -70,7 +70,7 @@ const BlogEntries = ({ pagesCount, }: Props) => { const [search, setSearch] = useState(''); - const [searchIndex, setSearchIndex] = useState(); + const [searchIndex, setSearchIndex] = useState(); const [searchResults, setSearchResults] = useState< { id: string; title: string; description: string }[] >([]); @@ -92,11 +92,7 @@ const BlogEntries = ({ if (searchIndex && search) { setSearchResults( ( - searchIndex.search(search) as { - ref: string; - score: number; - metadata: Record; - }[] + searchIndex.search(search) ).map((result) => ({ result, id: result.ref, diff --git a/src/utils/markdown.tsx b/src/utils/markdown.tsx index 378da4b0..cbc0b3cc 100644 --- a/src/utils/markdown.tsx +++ b/src/utils/markdown.tsx @@ -355,7 +355,7 @@ const hyperlinkMap: NodeToElementMapper = (context, node) => { ); }; -const elementsMapping: Record> = { +const elementsMapping = { root: rootMap, paragraph: paragraphMap, heading: headingMap, @@ -371,7 +371,7 @@ const elementsMapping: Record> = { bold: boldMap, strong: boldMap, html: htmlMap, -}; +} as const; export function parseMarkdown(input: string): MarkdownNode { return unified().use(remarkParse).parse(input) as unknown as MarkdownNode; @@ -386,7 +386,7 @@ export function renderMarkdown( } if (elementsMapping[node.type]) { - return elementsMapping[node.type](context, node); + return elementsMapping[node.type as 'root'](context, node as MarkdownRootNode); } console.warn(`Unrecognized Markdown element:`, node);