Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rezrah committed Dec 2, 2024
1 parent 8e12576 commit cc1f50f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ module.exports = {
jsx: true,
},
},

extends: [
'plugin:import/recommended',
'prettier',
'plugin:react/jsx-runtime',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
'plugin:github/recommended',
'plugin:github/browser',
'plugin:primer-react/recommended',
'plugin:markdown/recommended',
],
ignorePatterns: ['node_modules', '.next', 'dist/**/*', 'out/**/*', 'types/**/*', 'CHANGELOG.md'],
globals: {
Expand All @@ -40,7 +42,6 @@ module.exports = {
'eslint-comments/no-unused-disable': 0,
'react/prop-types': 0,
'react/display-name': 0,
'react-hooks/exhaustive-deps': 'error',
camelcase: [
'error',
{
Expand Down
1 change: 1 addition & 0 deletions packages/theme/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const base = require('../../.eslintrc')

module.exports = {
...base,
plugins: ['react-hooks'],
parserOptions: {
tsconfigRootDir: __dirname,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/components/context/color-modes/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import {createContext} from 'react'

export type ColorMode = 'light' | 'dark'

Expand All @@ -12,4 +12,4 @@ const defaultValues: ColorModeContextProps = {
setColorMode: () => {},
}

export const ColorModeContext = React.createContext<ColorModeContextProps>(defaultValues)
export const ColorModeContext = createContext<ColorModeContextProps>(defaultValues)
18 changes: 9 additions & 9 deletions packages/theme/components/layout/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {MarkGithubIcon, MoonIcon, SearchIcon, SunIcon, ThreeBarsIcon, XIcon} from '@primer/octicons-react'
import {Box, FormControl, IconButton, TextInput} from '@primer/react'
import {Heading, Stack, Text} from '@primer/react-brand'
import clsx from 'clsx'
import {clsx} from 'clsx'
import {MdxFile, PageMapItem} from 'nextra'
import type {PageItem} from 'nextra/normalize-pages'
import React, {useCallback, useEffect, useMemo} from 'react'
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'
import {debounce} from 'lodash'

import Link from 'next/link'
Expand All @@ -28,14 +28,14 @@ type SearchResults = {

export function Header({pageMap, docsDirectories, siteTitle}: HeaderProps) {
const {colorMode, setColorMode} = useColorMode()
const inputRef = React.useRef<HTMLInputElement | null>(null)
const searchResultsRef = React.useRef<HTMLElement | null>(null)
const inputRef = useRef<HTMLInputElement | null>(null)
const searchResultsRef = useRef<HTMLElement | null>(null)
const [isNavDrawerOpen, setIsNavDrawerOpen] = useNavDrawerState('768')
const [isSearchOpen, setIsSearchOpen] = React.useState(false)
const [isSearchResultOpen, setIsSearchResultOpen] = React.useState(false)
const [searchResults, setSearchResults] = React.useState<SearchResults[] | undefined>()
const [searchTerm, setSearchTerm] = React.useState<string | undefined>('')
const [activeDescendant] = React.useState<number>(-1)
const [isSearchOpen, setIsSearchOpen] = useState(false)
const [isSearchResultOpen, setIsSearchResultOpen] = useState(false)
const [searchResults, setSearchResults] = useState<SearchResults[] | undefined>()
const [searchTerm, setSearchTerm] = useState<string | undefined>('')
const [activeDescendant] = useState<number>(-1)

useEffect(() => {
if (isSearchOpen && inputRef.current) {
Expand Down
12 changes: 6 additions & 6 deletions packages/theme/components/layout/nav-drawer/useNavDrawerState.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import React from 'react'
import {useCallback, useEffect, useMemo, useState} from 'react'
import debounce from 'lodash.debounce'

export function useNavDrawerState(breakpoint): [boolean, (value: boolean) => void] {
if (typeof breakpoint === 'string') {
breakpoint = parseInt(breakpoint, 10)
}
const [isOpen, setOpen] = React.useState<boolean>(false)
const [isOpen, setOpen] = useState<boolean>(false)

const onResize = React.useCallback(() => {
const onResize = useCallback(() => {
if (window.innerWidth >= breakpoint) {
setOpen(false)
}
}, [setOpen, breakpoint])

const handleSetOpen = React.useCallback(
const handleSetOpen = useCallback(
(value: boolean) => {
setOpen(value)
},
[setOpen],
)

const debouncedOnResize = React.useMemo(() => debounce(onResize, 250), [onResize])
const debouncedOnResize = useMemo(() => debounce(onResize, 250), [onResize])

React.useEffect(() => {
useEffect(() => {
if (isOpen) {
// eslint-disable-next-line github/prefer-observers
window.addEventListener('resize', debouncedOnResize)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import type {ComponentProps, ReactElement} from 'react'
import clsx from 'clsx'
import {clsx} from 'clsx'
import type {Components} from 'nextra/mdx'

import {LinkIcon} from '@primer/octicons-react'
Expand Down

0 comments on commit cc1f50f

Please sign in to comment.