Skip to content

Commit

Permalink
fix all linting errors on documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkarimoff committed Feb 26, 2024
1 parent 3c940fe commit b9c4fab
Show file tree
Hide file tree
Showing 20 changed files with 166 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type HeadingNode } from '~/lib/tableOfContents';
import TOCLink from './TOCLink';

interface TableOfContentsProps {
type TableOfContentsProps = {
nodes: HeadingNode[] | null;
}
};

const TableOfContents = ({ nodes }: TableOfContentsProps) => {
if (!nodes) return null;
Expand All @@ -14,7 +14,7 @@ const TableOfContents = ({ nodes }: TableOfContentsProps) => {
nodes.length > 10 && 'h-[750px]'
} min-w-[300px] overflow-y-auto`}
>
<h3 className="text-sm uppercase text-slate-400">Table of contents</h3>
<h3 className="text-slate-400 text-sm uppercase">Table of contents</h3>
{renderNodes(nodes)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function generateMetadata({ params }: { params: PageParams }) {
project,
pathSegment: docPath,
});
if (!doc || !doc.title) {
if (!doc?.title) {
throw new Error(`Error getting document title for:${docPath.join('')}`);
}

Expand Down Expand Up @@ -78,7 +78,7 @@ const Page = async ({ params }: { params: PageParams }) => {
pathSegment: docPath,
});

if (!doc || doc?.content === null) notFound();
if (!doc?.content) notFound();

// Frontmatter data of markdown files
const {
Expand All @@ -95,7 +95,7 @@ const Page = async ({ params }: { params: PageParams }) => {

return (
<div className="flex items-start gap-1">
<article className="DocSearch-content prose prose-sm prose-slate mx-5 dark:prose-invert md:prose-base prose-blockquote:border-blue-500">
<article className="DocSearch-content prose-blockquote:border-blue-500 prose prose-sm prose-slate mx-5 dark:prose-invert md:prose-base">
<h1>{title}</h1>
<InnerLanguageSwitcher currentLocale={locale} filePath={filePath} />
{interfaceSummary && <InterfaceSummary data={interfaceSummary} />}
Expand All @@ -107,7 +107,7 @@ const Page = async ({ params }: { params: PageParams }) => {
source={content}
/>
{bestPractices && <BestPractices data={bestPractices} />}
<p className="text-sm text-red-400">{lastUpdated}</p>
<p className="text-red-400 text-sm">{lastUpdated}</p>
</article>
{headings && (
<div className="sticky top-20">
Expand Down
6 changes: 3 additions & 3 deletions apps/documentation/app/[locale]/[project]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ export default function Page({ params }: PageProps) {
pathSegment: ['index'], // pointing to home page for the project
});

if (!doc || doc?.content === null) notFound();
if (!doc?.content) notFound();

// Frontmatter data of markdown files
const { title, content, lastUpdated } = doc;

return (
<article className="DocSearch-content prose prose-sm prose-slate mx-5 dark:prose-invert md:prose-base prose-blockquote:border-blue-500">
<article className="DocSearch-content prose-blockquote:border-blue-500 prose prose-sm prose-slate mx-5 dark:prose-invert md:prose-base">
<h1>{title}</h1>
<InnerLanguageSwitcher currentLocale={locale} filePath={filePath} />
<MDXRemote
options={options}
components={customComponents}
source={content}
/>
<p className="text-sm text-red-400">{lastUpdated}</p>
<p className="text-red-400 text-sm">{lastUpdated}</p>
</article>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
useSearchBox,
} from 'react-instantsearch';

interface CustomSearchBoxProps extends UseSearchBoxProps {
type CustomSearchBoxProps = {
placeholder: string;
}
} & UseSearchBoxProps;

export default function CustomSearchBox(props: CustomSearchBoxProps) {
const { query, refine } = useSearchBox(props);
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function CustomSearchBox(props: CustomSearchBoxProps) {
>
<div className="flex items-center px-1.5">
{isSearchStalled ? (
<Loader size={'19px'} className="animate-spin text-gray-400" />
<Loader size={'19px'} className="text-gray-400 animate-spin" />
) : (
<SearchIcon size={'19px'} className="text-gray-400" />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ type DialogContextType = {

export const DialogContext = createContext<DialogContextType>({
open: false,
setOpen: () => {},
setOpen: () => undefined,
});

interface DialogContextProviderProps extends DialogContextType {
type DialogContextProviderProps = {
children: React.ReactNode;
}
} & DialogContextType;

export const DialogContextProvider: React.FC<DialogContextProviderProps> = ({
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import data from '~/public/sidebar.json';
import { type SidebarData } from '~/types';
import { useLocale } from 'next-intl';

interface LanguageSwitcherProps {
type LanguageSwitcherProps = {
width: string;
}
};

const LanguageSwitcher = ({ width }: LanguageSwitcherProps) => {
const locale = useLocale();
Expand Down Expand Up @@ -43,11 +43,11 @@ const LanguageSwitcher = ({ width }: LanguageSwitcherProps) => {
return (
<Select onValueChange={handleLanguageChange}>
<SelectTrigger
className={`bg-white hover:bg-stone-100 dark:bg-slate-700 dark:hover:bg-slate-600 ${width} space-x-1 text-xs sm:text-sm`}
className={`hover:bg-stone-100 dark:bg-slate-700 dark:hover:bg-slate-600 bg-white ${width} space-x-1 text-xs sm:text-sm`}
>
<SelectValue placeholder={locale === 'en' ? 'English' : 'Русский'} />
</SelectTrigger>
<SelectContent className="bg-white dark:bg-slate-700">
<SelectContent className="dark:bg-slate-700 bg-white">
<SelectItem value="en">English</SelectItem>
<SelectItem value="ru">Русский</SelectItem>
</SelectContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Menu from './Menu';
import NavigationLink from './NavigationLink';
import OpenMenu from './OpenMenu';

export interface NavigationMenusProps {
export type NavigationMenusProps = {
sidebarData: (Folder | DocFile)[];
pathItems: string[];
}
};

export default function NavigationMenus({
sidebarData,
Expand Down
5 changes: 3 additions & 2 deletions apps/documentation/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ export default async function MainLayout({
let messages: Messages;

try {
messages = (await import(`../../messages/${locale}.json`))
.default as Messages;
messages =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(await import(`../../messages/${locale}.json`)).default as Messages;
} catch (error) {
notFound(); // redirecting to 404 page in case there's no translated locale json
}
Expand Down
7 changes: 3 additions & 4 deletions apps/documentation/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ const buttonVariants = cva(
},
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
export type ButtonProps = {
asChild?: boolean;
}
} & React.ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof buttonVariants>;

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
Expand Down
80 changes: 40 additions & 40 deletions apps/documentation/components/ui/command.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client"
'use client';

import * as React from "react"
import { type DialogProps } from "@radix-ui/react-dialog"
import { Command as CommandPrimitive } from "cmdk"
import { Search } from "lucide-react"
import * as React from 'react';
import { type DialogProps } from '@radix-ui/react-dialog';
import { Command as CommandPrimitive } from 'cmdk';
import { Search } from 'lucide-react';

import { cn } from "~/lib/utils"
import { Dialog, DialogContent } from "~/components/ui/dialog"
import { cn } from '~/lib/utils';
import { Dialog, DialogContent } from '~/components/ui/dialog';

const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
Expand All @@ -15,15 +15,15 @@ const Command = React.forwardRef<
<CommandPrimitive
ref={ref}
className={cn(
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
className
'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
className,
)}
{...props}
/>
))
Command.displayName = CommandPrimitive.displayName
));
Command.displayName = CommandPrimitive.displayName;

interface CommandDialogProps extends DialogProps {}
type CommandDialogProps = object & DialogProps;

const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
return (
Expand All @@ -34,8 +34,8 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
</Command>
</DialogContent>
</Dialog>
)
}
);
};

const CommandInput = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Input>,
Expand All @@ -46,28 +46,28 @@ const CommandInput = React.forwardRef<
<CommandPrimitive.Input
ref={ref}
className={cn(
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
className
'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
className,
)}
{...props}
/>
</div>
))
));

CommandInput.displayName = CommandPrimitive.Input.displayName
CommandInput.displayName = CommandPrimitive.Input.displayName;

const CommandList = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.List>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
>(({ className, ...props }, ref) => (
<CommandPrimitive.List
ref={ref}
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}
{...props}
/>
))
));

CommandList.displayName = CommandPrimitive.List.displayName
CommandList.displayName = CommandPrimitive.List.displayName;

const CommandEmpty = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Empty>,
Expand All @@ -78,9 +78,9 @@ const CommandEmpty = React.forwardRef<
className="py-6 text-center text-sm"
{...props}
/>
))
));

CommandEmpty.displayName = CommandPrimitive.Empty.displayName
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;

const CommandGroup = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Group>,
Expand All @@ -89,26 +89,26 @@ const CommandGroup = React.forwardRef<
<CommandPrimitive.Group
ref={ref}
className={cn(
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
className
'overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground',
className,
)}
{...props}
/>
))
));

CommandGroup.displayName = CommandPrimitive.Group.displayName
CommandGroup.displayName = CommandPrimitive.Group.displayName;

const CommandSeparator = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Separator
ref={ref}
className={cn("-mx-1 h-px bg-border", className)}
className={cn('-mx-1 h-px bg-border', className)}
{...props}
/>
))
CommandSeparator.displayName = CommandPrimitive.Separator.displayName
));
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;

const CommandItem = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Item>,
Expand All @@ -117,14 +117,14 @@ const CommandItem = React.forwardRef<
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
className,
)}
{...props}
/>
))
));

CommandItem.displayName = CommandPrimitive.Item.displayName
CommandItem.displayName = CommandPrimitive.Item.displayName;

const CommandShortcut = ({
className,
Expand All @@ -133,14 +133,14 @@ const CommandShortcut = ({
return (
<span
className={cn(
"ml-auto text-xs tracking-widest text-muted-foreground",
className
'ml-auto text-xs tracking-widest text-muted-foreground',
className,
)}
{...props}
/>
)
}
CommandShortcut.displayName = "CommandShortcut"
);
};
CommandShortcut.displayName = 'CommandShortcut';

export {
Command,
Expand All @@ -152,4 +152,4 @@ export {
CommandItem,
CommandShortcut,
CommandSeparator,
}
};
3 changes: 1 addition & 2 deletions apps/documentation/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from 'react';

import { cn } from '~/lib/utils';

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
export type InputProps = object & React.InputHTMLAttributes<HTMLInputElement>;

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
Expand Down
3 changes: 3 additions & 0 deletions apps/documentation/lib/algolia-search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function transformDocsToSearchObjects(articles) {

// Index the files after build
(async function indexAllFiles() {
// eslint-disable-next-line no-console
console.log('STARTED INDEXING');

try {
Expand All @@ -104,10 +105,12 @@ function transformDocsToSearchObjects(articles) {

const algoliaResponse = await index.saveObjects(transformed);

// eslint-disable-next-line no-console
console.log(
`SUCCESSFULLY ADDED ${algoliaResponse.objectIDs.length} RECORDS TO Algolia SEARCH.`,
);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
})();
Loading

0 comments on commit b9c4fab

Please sign in to comment.