From 8b6a8f8abfc0e800680798f4a5b987754f9f4e3a Mon Sep 17 00:00:00 2001 From: q9i <46249765+quantum9Innovation@users.noreply.github.com> Date: Sun, 18 Feb 2024 20:34:38 -0800 Subject: [PATCH] chore: enforce authoritarian import ordering Some random VSC prompt allows me to do this, still have no idea how to automate or reproduce this behavior --- .../[shortName]/findDocumentsByAffiliation.ts | 2 +- src/app/author/[author]/AuthorDisplay.tsx | 12 ++++++------ src/app/author/[author]/KonamiSnowfall.tsx | 6 +++--- src/app/author/[author]/page.tsx | 2 +- src/app/components/DataDisplay.tsx | 6 +++--- src/app/components/DataDisplayClient.tsx | 4 ++-- src/app/components/DocumentCard.tsx | 10 +++++----- src/app/components/MobileMenu.tsx | 6 +++--- src/app/components/News.tsx | 2 +- src/app/components/RandomDocs.tsx | 2 +- src/app/components/RecentDocuments.tsx | 2 +- src/app/document/view/[slug]/DocumentViewer.tsx | 16 ++++++++-------- src/app/document/view/[slug]/VersionChooser.tsx | 8 ++++---- src/app/document/view/[slug]/page.tsx | 2 +- src/app/layout.tsx | 12 ++++++------ src/app/legal/copyright/page.tsx | 1 + src/app/page.tsx | 14 +++++++------- src/app/providers.tsx | 2 +- src/app/search/page.tsx | 16 ++++++++-------- src/app/topic/[slug]/page.tsx | 4 ++-- src/app/utils/ErrorBoundary.tsx | 2 +- src/app/utils/search.worker.ts | 8 ++++---- 22 files changed, 70 insertions(+), 69 deletions(-) diff --git a/src/app/affiliation/[shortName]/findDocumentsByAffiliation.ts b/src/app/affiliation/[shortName]/findDocumentsByAffiliation.ts index 8ef2f60..5201b26 100644 --- a/src/app/affiliation/[shortName]/findDocumentsByAffiliation.ts +++ b/src/app/affiliation/[shortName]/findDocumentsByAffiliation.ts @@ -1,4 +1,4 @@ -import { Document, documents, authors } from '@/app/db/data' +import { Document, authors, documents } from '@/app/db/data' // Assuming the types Document, DocumentStatus, and reviewer are defined as provided in your question diff --git a/src/app/author/[author]/AuthorDisplay.tsx b/src/app/author/[author]/AuthorDisplay.tsx index e9a4431..722876b 100644 --- a/src/app/author/[author]/AuthorDisplay.tsx +++ b/src/app/author/[author]/AuthorDisplay.tsx @@ -1,13 +1,13 @@ +import DocumentCard from '@/app/components/DocumentCard' +import cardEffects from '@/app/styles/cardEffects.module.css' +import { Zilla_Slab } from 'next/font/google' +import Image from 'next/image' import Link from 'next/link' +import { notFound } from 'next/navigation' import { Fragment, Suspense } from 'react' import { Author, affiliations, authors } from '../../db/data' -import { Zilla_Slab } from 'next/font/google' -import { notFound } from 'next/navigation' -import DocumentCard from '@/app/components/DocumentCard' -import findDocumentsByAuthor from './findDocumentsByAuthor' -import cardEffects from '@/app/styles/cardEffects.module.css' import KonamiSnowfall from './KonamiSnowfall' -import Image from 'next/image' +import findDocumentsByAuthor from './findDocumentsByAuthor' const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] }) diff --git a/src/app/author/[author]/KonamiSnowfall.tsx b/src/app/author/[author]/KonamiSnowfall.tsx index 933334b..965e746 100644 --- a/src/app/author/[author]/KonamiSnowfall.tsx +++ b/src/app/author/[author]/KonamiSnowfall.tsx @@ -1,9 +1,9 @@ 'use client' -import Konami from 'react-konami-code' -import { Snowfall } from 'react-snowfall' -import { Fragment, useEffect, useState } from 'react' import { nationalities } from '@/app/db/data' import NextImage from 'next/image' +import { Fragment, useEffect, useState } from 'react' +import Konami from 'react-konami-code' +import { Snowfall } from 'react-snowfall' const NationalityDisplay = ({ nationality, diff --git a/src/app/author/[author]/page.tsx b/src/app/author/[author]/page.tsx index 0942ac5..066d94b 100644 --- a/src/app/author/[author]/page.tsx +++ b/src/app/author/[author]/page.tsx @@ -1,5 +1,5 @@ -import AuthorDisplay from './AuthorDisplay' import { authors } from '@/app/db/data' +import AuthorDisplay from './AuthorDisplay' export function generateStaticParams() { const authorsList = Object.keys(authors) diff --git a/src/app/components/DataDisplay.tsx b/src/app/components/DataDisplay.tsx index 8742e1a..742ff4a 100644 --- a/src/app/components/DataDisplay.tsx +++ b/src/app/components/DataDisplay.tsx @@ -1,10 +1,10 @@ -import { Fragment } from 'react' -import Link from 'next/link' import { - reviewer, authors as authorList, + reviewer, topics as topicList, } from '@/app/db/data' +import Link from 'next/link' +import { Fragment } from 'react' const getRepo = (link: string) => { if (link.includes('github.com')) { diff --git a/src/app/components/DataDisplayClient.tsx b/src/app/components/DataDisplayClient.tsx index c7657b9..5bff611 100644 --- a/src/app/components/DataDisplayClient.tsx +++ b/src/app/components/DataDisplayClient.tsx @@ -1,9 +1,9 @@ // these variants of the data display components are designed for client side components // and fetch data asynchronously -import { loadAllTopics, loadAllAuthors } from '@/app/db/loaders' +import { loadAllAuthors, loadAllTopics } from '@/app/db/loaders' import { useSuspenseQuery } from '@tanstack/react-query' -import { Fragment } from 'react' import Link from 'next/link' +import { Fragment } from 'react' export const Authors = ({ authors, diff --git a/src/app/components/DocumentCard.tsx b/src/app/components/DocumentCard.tsx index 447d088..a298fff 100644 --- a/src/app/components/DocumentCard.tsx +++ b/src/app/components/DocumentCard.tsx @@ -1,10 +1,10 @@ import { Document } from '@/app/db/data' -import { Zilla_Slab } from 'next/font/google' -import { Authors, Topics } from './DataDisplay' -import { ItemBadge, Status } from './Badges' -import { epoch2datestring } from '@/app/utils/epoch2datestring' -import Link from 'next/link' import cardEffects from '@/app/styles/cardEffects.module.css' +import { epoch2datestring } from '@/app/utils/epoch2datestring' +import { Zilla_Slab } from 'next/font/google' +import Link from 'next/link' +import { ItemBadge, Status } from './Badges' +import { Authors, Topics } from './DataDisplay' const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] }) diff --git a/src/app/components/MobileMenu.tsx b/src/app/components/MobileMenu.tsx index 8970755..c5d7412 100644 --- a/src/app/components/MobileMenu.tsx +++ b/src/app/components/MobileMenu.tsx @@ -1,8 +1,8 @@ 'use client' -import { RxHamburgerMenu } from 'react-icons/rx' -import styles from './mobileMenu.module.css' -import { create } from 'zustand' import SearchBar from '@/app/components/SearchBar' +import { RxHamburgerMenu } from 'react-icons/rx' +import { create } from 'zustand' +import styles from './mobileMenu.module.css' interface MobileMenuState { isOpen: boolean diff --git a/src/app/components/News.tsx b/src/app/components/News.tsx index 9574325..adceff8 100644 --- a/src/app/components/News.tsx +++ b/src/app/components/News.tsx @@ -1,5 +1,5 @@ -import Link from 'next/link' import { Inter, Zilla_Slab } from 'next/font/google' +import Link from 'next/link' const zillaSlab = Zilla_Slab({ weight: '600', subsets: ['latin'] }) const inter = Inter({ weight: ['400', '500'], subsets: ['latin'] }) diff --git a/src/app/components/RandomDocs.tsx b/src/app/components/RandomDocs.tsx index d441f23..daee366 100644 --- a/src/app/components/RandomDocs.tsx +++ b/src/app/components/RandomDocs.tsx @@ -1,5 +1,5 @@ -import { epoch2datestring } from '@/app/utils/epoch2datestring' import { documents, topics as topicsList } from '@/app/db/data' +import { epoch2datestring } from '@/app/utils/epoch2datestring' import Link from 'next/link' const RandomDocs = (): React.ReactNode[] => { diff --git a/src/app/components/RecentDocuments.tsx b/src/app/components/RecentDocuments.tsx index 0ec8428..7888301 100644 --- a/src/app/components/RecentDocuments.tsx +++ b/src/app/components/RecentDocuments.tsx @@ -1,5 +1,5 @@ +import { Document, documents, topics as topicsList } from '@/app/db/data' import { epoch2datestring } from '@/app/utils/epoch2datestring' -import { documents, topics as topicsList, Document } from '@/app/db/data' import Link from 'next/link' function getThreeMostRecentDocuments( diff --git a/src/app/document/view/[slug]/DocumentViewer.tsx b/src/app/document/view/[slug]/DocumentViewer.tsx index 5599037..7293786 100644 --- a/src/app/document/view/[slug]/DocumentViewer.tsx +++ b/src/app/document/view/[slug]/DocumentViewer.tsx @@ -1,19 +1,19 @@ 'use client' -import { Zilla_Slab } from 'next/font/google' -import { epoch2datestring } from '@/app/utils/epoch2datestring' +import { ItemBadge, Status } from '@/app/components/Badges' import { + Authors, Code, References, - Topics, - Authors, Reviewers, + Topics, } from '@/app/components/DataDisplay' -import { ItemBadge, Status } from '@/app/components/Badges' -import VersionChooser from './VersionChooser' -import generateHash from '@/app/utils/hash' -import { Suspense } from 'react' import { loadDocument } from '@/app/db/loaders' +import { epoch2datestring } from '@/app/utils/epoch2datestring' +import generateHash from '@/app/utils/hash' import { useSuspenseQuery } from '@tanstack/react-query' +import { Zilla_Slab } from 'next/font/google' +import { Suspense } from 'react' +import VersionChooser from './VersionChooser' const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] }) diff --git a/src/app/document/view/[slug]/VersionChooser.tsx b/src/app/document/view/[slug]/VersionChooser.tsx index e688713..5e59842 100644 --- a/src/app/document/view/[slug]/VersionChooser.tsx +++ b/src/app/document/view/[slug]/VersionChooser.tsx @@ -1,13 +1,13 @@ 'use client' -import { useState } from 'react' import { Document } from '@/app/db/data' -import Link from 'next/link' import { loadAuthors } from '@/app/db/loaders' -import { useSuspenseQuery } from '@tanstack/react-query' import { epoch2date } from '@/app/utils/epoch2datestring' -import { toast } from 'react-toastify' import generateHash from '@/app/utils/hash' +import { useSuspenseQuery } from '@tanstack/react-query' +import Link from 'next/link' import QRCode from 'qrcode.react' +import { useState } from 'react' +import { toast } from 'react-toastify' const VersionChooser = ({ doc, diff --git a/src/app/document/view/[slug]/page.tsx b/src/app/document/view/[slug]/page.tsx index 40f5290..6f7e298 100644 --- a/src/app/document/view/[slug]/page.tsx +++ b/src/app/document/view/[slug]/page.tsx @@ -1,6 +1,6 @@ 'use client' -import DocumentViewer from './DocumentViewer' import ErrorBoundary from '@/app/utils/ErrorBoundary' +import DocumentViewer from './DocumentViewer' export default function Page({ params, diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 2f161c2..e609158 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,15 +1,15 @@ import type { Metadata } from 'next' import { Inter, Zilla_Slab } from 'next/font/google' -import './globals.css' -import styles from './home.module.css' +import Image from 'next/legacy/image' import Link from 'next/link' -import SearchBar from './components/SearchBar' -import Container from './container/Container' -import MobileMenu from './components/MobileMenu' import { ToastContainer } from 'react-toastify' import 'react-toastify/dist/ReactToastify.css' +import MobileMenu from './components/MobileMenu' +import SearchBar from './components/SearchBar' +import Container from './container/Container' +import './globals.css' +import styles from './home.module.css' import Providers from './providers' -import Image from 'next/legacy/image' /* The default font is Inter. If you want to use Zilla Slab (or any other Google Font, which are pre-provided by Next.js in the 'next/font/google' module), you need to diff --git a/src/app/legal/copyright/page.tsx b/src/app/legal/copyright/page.tsx index 88a94ca..2243c14 100644 --- a/src/app/legal/copyright/page.tsx +++ b/src/app/legal/copyright/page.tsx @@ -1,4 +1,5 @@ import Link from 'next/link' + export default function Page() { return (
diff --git a/src/app/page.tsx b/src/app/page.tsx index a52861f..661481d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,14 +1,14 @@ import Link from 'next/link' -import { - documents, - authors, - affiliations, - Author, - Affiliation, -} from './db/data' import News from './components/News' import RandomDocs from './components/RandomDocs' import RecentDocuments from './components/RecentDocuments' +import { + Affiliation, + Author, + affiliations, + authors, + documents, +} from './db/data' function sortAuthorsByDocumentsPublished(authors: { [key: string]: Author diff --git a/src/app/providers.tsx b/src/app/providers.tsx index 155e1bf..4912003 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -1,7 +1,7 @@ 'use client' -import { useMemo } from 'react' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { useMemo } from 'react' type ProvidersProps = { children: React.ReactNode diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index 62b3741..b2c0a30 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -1,15 +1,15 @@ 'use client' -import { useSearchParams, useRouter } from 'next/navigation' -import { Zilla_Slab } from 'next/font/google' -import { Topics, Authors } from '@/app/components/DataDisplay' -import { Status, ItemBadge } from '@/app/components/Badges' -import { epoch2datestring } from '../utils/epoch2datestring' +import { ItemBadge, Status } from '@/app/components/Badges' +import { Authors, Topics } from '@/app/components/DataDisplay' +import cardEffects from '@/app/styles/cardEffects.module.css' import searchDocs, { CustomSearchResult } from '@/app/utils/searchDocs' import { useSuspenseQuery } from '@tanstack/react-query' -import cardEffects from '@/app/styles/cardEffects.module.css' -import { toast } from 'react-toastify' -import { useEffect } from 'react' import { hash as fnv } from 'fnv-plus' +import { Zilla_Slab } from 'next/font/google' +import { useRouter, useSearchParams } from 'next/navigation' +import { useEffect } from 'react' +import { toast } from 'react-toastify' +import { epoch2datestring } from '../utils/epoch2datestring' const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500', '700'] }) diff --git a/src/app/topic/[slug]/page.tsx b/src/app/topic/[slug]/page.tsx index 48a6b93..25693e8 100644 --- a/src/app/topic/[slug]/page.tsx +++ b/src/app/topic/[slug]/page.tsx @@ -1,7 +1,7 @@ -import { Zilla_Slab } from 'next/font/google' import { topics } from '@/app/db/data' -import { notFound } from 'next/navigation' import string2hex from '@/app/utils/string2hex' +import { Zilla_Slab } from 'next/font/google' +import { notFound } from 'next/navigation' const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] }) diff --git a/src/app/utils/ErrorBoundary.tsx b/src/app/utils/ErrorBoundary.tsx index 75b8fe8..8f060c6 100644 --- a/src/app/utils/ErrorBoundary.tsx +++ b/src/app/utils/ErrorBoundary.tsx @@ -1,5 +1,5 @@ -import React from 'react' import { notFound } from 'next/navigation' +import React from 'react' interface ErrorBoundaryProps { children: React.ReactNode diff --git a/src/app/utils/search.worker.ts b/src/app/utils/search.worker.ts index 8a1f524..ed89149 100644 --- a/src/app/utils/search.worker.ts +++ b/src/app/utils/search.worker.ts @@ -1,9 +1,9 @@ -import { documents, authors, affiliations, topics } from '@/app/db/data' -import MiniSearch from 'minisearch' -import { CustomSearchResult } from './searchDocs' -import hash from './hash' +import { affiliations, authors, documents, topics } from '@/app/db/data' import { hash as fnv } from 'fnv-plus' +import MiniSearch from 'minisearch' import { Document } from '../db/data' +import hash from './hash' +import { CustomSearchResult } from './searchDocs' const miniSearch = new MiniSearch({ fields: [