Skip to content

Commit

Permalink
51 eslint stylistic semi rule (#53)
Browse files Browse the repository at this point in the history
* add semi rule

* autofix semi rule
  • Loading branch information
ann-kilzer authored Jul 11, 2024
1 parent 3ded3fe commit 1281ab4
Show file tree
Hide file tree
Showing 26 changed files with 520 additions and 84 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-unsafe-call': ['off'],
'@stylistic/ts/indent': ['error', 4],
'@stylistic/ts/semi': ['error', 'never'],
},
settings: {
react: {
Expand Down
8 changes: 4 additions & 4 deletions e2e/home.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from '@playwright/test';
import { test, expect } from '@playwright/test'

test('has title', async ({ page }) => {
await page.goto('/');
await page.goto('/')

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/WiSE/);
});
await expect(page).toHaveTitle(/WiSE/)
})
441 changes: 438 additions & 3 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from '@playwright/test';
import { defineConfig, devices } from '@playwright/test'

/**
* Read environment variables from file.
Expand Down Expand Up @@ -74,4 +74,4 @@ export default defineConfig({
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
})
2 changes: 1 addition & 1 deletion src/@types/i18next.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resources, defaultNS } from './i18n';
import { resources, defaultNS } from './i18n'

declare module 'i18next' {
interface CustomTypeOptions {
Expand Down
14 changes: 7 additions & 7 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FC } from 'react';
import { FC } from 'react'
import BottomNavigation from '@mui/material/BottomNavigation'
import Paper from '@mui/material/Paper'
import InstagramIcon from '@mui/icons-material/Instagram';
import LinkedInIcon from '@mui/icons-material/LinkedIn';
import FacebookIcon from '@mui/icons-material/Facebook';
import GitHubIcon from '@mui/icons-material/GitHub';
import EventIcon from '@mui/icons-material/Event';
import FooterIcon from './FooterIcon';
import InstagramIcon from '@mui/icons-material/Instagram'
import LinkedInIcon from '@mui/icons-material/LinkedIn'
import FacebookIcon from '@mui/icons-material/Facebook'
import GitHubIcon from '@mui/icons-material/GitHub'
import EventIcon from '@mui/icons-material/Event'
import FooterIcon from './FooterIcon'


const Footer: FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/FooterIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react';
import { FC } from 'react'
import BottomNavigationAction from '@mui/material/BottomNavigationAction'

interface FooterIconProps {
Expand Down
12 changes: 6 additions & 6 deletions src/components/Header/DesktopHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FC } from 'react';
import { FC } from 'react'

import Stack from '@mui/material/Stack'
import Toolbar from '@mui/material/Toolbar'
import Typography from '@mui/material/Typography';
import { styled } from '@mui/material/styles';
import SideDrawer from '../SideDrawer/SideDrawer';
import Typography from '@mui/material/Typography'
import { styled } from '@mui/material/styles'
import SideDrawer from '../SideDrawer/SideDrawer'
import StyledNavLink from '@/components/StyledNavLink/StyledNavLink'
import { useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next'


const StyledToolbar = styled(Toolbar)(({ theme }) => ({
Expand All @@ -23,7 +23,7 @@ const StyledToolbar = styled(Toolbar)(({ theme }) => ({


const DesktopHeader: FC = () => {
const { t } = useTranslation();
const { t } = useTranslation()

return <StyledToolbar aria-label="desktop-toolbar">
<Stack direction='row' spacing={2} sx={{ alignItems: 'center' }}>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from 'react'
import AppBar from '@mui/material/AppBar'
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import MobileHeader from './MobileHeader';
import DesktopHeader from './DesktopHeader';
import { useTheme } from '@mui/material/styles'
import useMediaQuery from '@mui/material/useMediaQuery'
import MobileHeader from './MobileHeader'
import DesktopHeader from './DesktopHeader'



Expand Down
2 changes: 1 addition & 1 deletion src/components/ImageCard/ImageCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react';
import { FC } from 'react'
import Card from '@mui/material/Card'

interface ImageCardProps {
Expand Down
20 changes: 10 additions & 10 deletions src/components/LocaleToggle/LocaleToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { FC, useEffect, useState, useCallback } from 'react'
import ToggleButton from '@mui/material/ToggleButton'
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup'
import { useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next'
import Locale from '@/i18n/locales'

const LocaleToggle: FC = () => {
const [locale, setLocale] = useState(Locale.EN);
const { i18n } = useTranslation();
const [locale, setLocale] = useState(Locale.EN)
const { i18n } = useTranslation()

const changeLanguage = useCallback(async (nextLocale: Locale) => {
await i18n.changeLanguage(nextLocale).then(() => {
setLocale(nextLocale);
localStorage.setItem('locale', nextLocale);
});
}, [i18n]);
setLocale(nextLocale)
localStorage.setItem('locale', nextLocale)
})
}, [i18n])

useEffect(() => {
const savedLocale = localStorage.getItem('locale');
const savedLocale = localStorage.getItem('locale')
if (savedLocale) {
changeLanguage(savedLocale as Locale).catch((e: Error) => {
console.error(e)
})
}
}, [changeLanguage]);
}, [changeLanguage])

const handleChange = (_: React.MouseEvent<HTMLElement>, nextLocale: Locale) => {
changeLanguage(nextLocale).catch((e: Error) => {
Expand All @@ -38,7 +38,7 @@ const LocaleToggle: FC = () => {
<ToggleButton value={Locale.EN}>English</ToggleButton>
<ToggleButton value={Locale.JA}>日本語</ToggleButton>
</ToggleButtonGroup>
);
)
}

export default LocaleToggle
22 changes: 11 additions & 11 deletions src/components/LocaleToggle/__test__/LocaleToggle.test.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { describe, expect, it } from 'vitest'
import { render } from '@/tests/customRender'
import LocaleToggle from '../LocaleToggle';
import LocaleToggle from '../LocaleToggle'
import userEvent from '@testing-library/user-event'
import { screen } from '@testing-library/react'

describe('LocaleToggle', () => {
it('renders correctly', async () => {
render(<LocaleToggle />)

const english = await screen.findByText('English');
const japanese = await screen.findByText('日本語');
expect(english).toBeInTheDocument();
expect(japanese).toBeInTheDocument();
});
const english = await screen.findByText('English')
const japanese = await screen.findByText('日本語')
expect(english).toBeInTheDocument()
expect(japanese).toBeInTheDocument()
})
})

it('changes locale when toggling', async () => {
render(<LocaleToggle />);
const japaneseButton = screen.getByText('日本語');
render(<LocaleToggle />)
const japaneseButton = screen.getByText('日本語')

const user = userEvent.setup()
await user.click(japaneseButton)
expect(localStorage.getItem('locale')).toBe('ja');
expect(localStorage.getItem('locale')).toBe('ja')

localStorage.removeItem('locale');
});
localStorage.removeItem('locale')
})
4 changes: 2 additions & 2 deletions src/components/SideDrawer/SideDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const SideDrawer: FC = () => {
((event as React.KeyboardEvent).key === 'Tab' ||
(event as React.KeyboardEvent).key === 'Shift')
) {
return;
return
}

setOpen(open)
};
}

return <>
<IconButton
Expand Down
4 changes: 2 additions & 2 deletions src/components/StyledNavLink/StyledNavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from '@mui/material/styles';
import { NavLink } from 'react-router-dom';
import { styled } from '@mui/material/styles'
import { NavLink } from 'react-router-dom'

const StyledNavLink = styled(NavLink)(() => ({
color: 'white',
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextBlock/Body1.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, ReactNode } from 'react'
import Typography from '@mui/material/Typography';
import Typography from '@mui/material/Typography'

interface Body1Props {
children: ReactNode
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ i18next.use(initReactI18next).init({
// if you see an error like: "Argument of type 'DefaultTFuncReturn' is not assignable to parameter of type xyz"
// set returnNull to false (and also in the i18next.d.ts options)
// returnNull: false,
});
})
10 changes: 5 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import CssBaseline from '@mui/material/CssBaseline';
import Router from './routes/Router';
import GlobalStyles from '@mui/material/GlobalStyles';
import CustomThemeProvider from './theme/CustomThemeProvider';
import './i18n/config';
import CssBaseline from '@mui/material/CssBaseline'
import Router from './routes/Router'
import GlobalStyles from '@mui/material/GlobalStyles'
import CustomThemeProvider from './theme/CustomThemeProvider'
import './i18n/config'
import './index.css'

import '@fontsource/noto-sans-jp/300.css'
Expand Down
2 changes: 1 addition & 1 deletion src/routes/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Loader = () => (
<div>
<div>Loading...</div>
</div>
);
)

const BaseLayout: FC = () => {
return <Suspense fallback={<Loader />}>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/CodeOfConduct/CodeOfConduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { FC } from 'react'
import Container from '@mui/material/Container'
import Stack from '@mui/material/Stack'
import { Typography } from '@mui/material'
import { useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next'

const CodeOfConduct: FC = () => {
const { t } = useTranslation();
const { t } = useTranslation()

return <Container style={{ padding: 32 }}>
<Stack spacing={2}>
Expand Down
8 changes: 4 additions & 4 deletions src/routes/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FC } from 'react';
import { FC } from 'react'
import Stack from '@mui/material/Stack'
import Container from '@mui/material/Container'
import Typography from '@mui/material/Typography';
import Typography from '@mui/material/Typography'
import Button from '@mui/material/Button'
import { useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next'

const Home: FC = () => {
const { t } = useTranslation();
const { t } = useTranslation()

return <Container style={{ padding: 32 }}>
<Stack spacing={2}>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/ThemePreview/ColorSwatch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Paper from '@mui/material/Paper'
import { Theme, styled } from '@mui/material/styles';
import { Theme, styled } from '@mui/material/styles'

interface SwatchProps {
color: string
Expand All @@ -23,6 +23,6 @@ const ColorSwatch = styled(Paper)<SwatchProps>(({ theme, color }) => ({
padding: theme.spacing(4),
textAlign: 'center',
color: theme.palette.text.secondary,
}));
}))

export default ColorSwatch
10 changes: 5 additions & 5 deletions src/routes/ThemePreview/ThemePreview.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FC } from 'react';
import Button from '@mui/material/Button';
import { FC } from 'react'
import Button from '@mui/material/Button'
import Container from '@mui/material/Container'
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Grid from '@mui/material/Grid'
import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
import Divider from '@mui/material/Divider'
import ColorSwatch from './ColorSwatch';
import ColorSwatch from './ColorSwatch'
import StarIcon from '@mui/icons-material/Star'


Expand Down
8 changes: 4 additions & 4 deletions src/tests/customRender.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { ReactElement } from 'react'
import { render, RenderOptions } from '@testing-library/react'
import CssBaseline from '@mui/material/CssBaseline';
import CustomThemeProvider from '@/theme/CustomThemeProvider';
import { MemoryRouter } from 'react-router-dom';
import '@/i18n/config';
import CssBaseline from '@mui/material/CssBaseline'
import CustomThemeProvider from '@/theme/CustomThemeProvider'
import { MemoryRouter } from 'react-router-dom'
import '@/i18n/config'

// eslint-disable-next-line react-refresh/only-export-components
const AllTheProviders = ({ children }: { children: React.ReactNode }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/theme/customColorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Custom Colors in Typescript requires module augmentation
Read more: https://mui.com/material-ui/customization/palette/#typescript
*/
import '@mui/material';
import '@mui/material'


declare module '@mui/material/styles' {
Expand Down
6 changes: 3 additions & 3 deletions src/theme/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import createTheme from '@mui/material/styles/createTheme'
import typography from './typography/default';
import { teal, lightBlue, deepPurple, purple, grey } from '@mui/material/colors';
import typography from './typography/default'
import { teal, lightBlue, deepPurple, purple, grey } from '@mui/material/colors'

const theme = createTheme({
palette: {
Expand Down Expand Up @@ -38,6 +38,6 @@ const theme = createTheme({

},
typography
});
})

export default theme
2 changes: 1 addition & 1 deletion src/theme/typography/default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TypographyOptions } from '@mui/material/styles/createTypography';
import { TypographyOptions } from '@mui/material/styles/createTypography'

const typography: TypographyOptions = {
fontFamily: ['Noto Sans JP', 'serif'].join(','),
Expand Down

0 comments on commit 1281ab4

Please sign in to comment.