Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add import order rule to eslint, add eslint to lint-staged #453

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
113 changes: 67 additions & 46 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,92 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parser: '@typescript-eslint/parser',
plugins: [
"react",
"react-hooks",
"testing-library",
"jest",
"jest-dom",
"@typescript-eslint",
'react',
'react-hooks',
'testing-library',
'jest',
'jest-dom',
'@typescript-eslint',
],
ignorePatterns: ["apps/portals/src/tests/*"],
ignorePatterns: ['apps/portals/src/tests/*'],
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jest/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:storybook/recommended",
'eslint:recommended',
'plugin:react/recommended',
'plugin:jest/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:storybook/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
"./tsconfig.json",
"./packages/**/tsconfig.json",
"./apps/**/tsconfig.json",
'./tsconfig.json',
'./packages/**/tsconfig.json',
'./apps/**/tsconfig.json',
],
},
rules: {
"react/prop-types": [0],
"react/no-unstable-nested-components": "warn",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": [
"warn",
'react/prop-types': [0],
'react/no-unstable-nested-components': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: "useDebouncedEffect",
additionalHooks: 'useDebouncedEffect',
},
],
"no-extra-semi": "off",
"prefer-const": "warn",
"jest/expect-expect": "off",
"@typescript-eslint/restrict-template-expressions": [
"warn",
'no-extra-semi': 'off',
'prefer-const': 'warn',
'jest/expect-expect': 'off',
'@typescript-eslint/restrict-template-expressions': [
'warn',
{ allowBoolean: true },
],
"@typescript-eslint/unbound-method": "warn",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-extra-semi": "warn",
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-extra-semi': 'warn',
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
},
],
},
settings: {
react: {
version: "detect",
version: 'detect',
},
'import/resolver': {
typescript: true,
node: true,
},
},
globals: {
JSX: true,
},
};
}
1 change: 1 addition & 0 deletions apps/SageAccountWeb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
},
"scripts": {
"clean": "rimraf build coverage",
"lint": "eslint src",
"start": "vite",
"build": "vite build",
"test": "vitest",
Expand Down
20 changes: 10 additions & 10 deletions apps/SageAccountWeb/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { StyledEngineProvider } from '@mui/material/styles'
import React from 'react'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import {
ApplicationSessionManager,
SynapseClient,
SynapseToastContainer,
SynapseContextType,
SynapseContextConsumer,
} from 'synapse-react-client'
import { QueryClient, QueryClientProvider } from 'react-query'
import { AppContextConsumer } from './AppContext'
import { SageResourcesPage } from './components/SageResourcesPage'
import { AccountCreatedPage } from './components/AccountCreatedPage'
Expand All @@ -12,20 +22,10 @@ import { RegisterAccount1 } from './components/RegisterAccount1'
import { RegisterAccount2 } from './components/RegisterAccount2'
import { ResetPassword } from './components/ResetPassword'
import { TermsOfUsePage } from './components/TermsOfUsePage'
import React from 'react'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import {
ApplicationSessionManager,
SynapseClient,
SynapseToastContainer,
SynapseContextType,
SynapseContextConsumer,
} from 'synapse-react-client'
import { getSearchParam } from './URLUtils'
import './App.scss'
import AppInitializer from './AppInitializer'
import LoginPage from './LoginPage'
import { QueryClient, QueryClientProvider } from 'react-query'
import TwoFactorAuthEnrollmentPage from './components/TwoFactorAuth/TwoFactorAuthEnrollmentPage'
import TwoFactorAuthBackupCodesPage from './components/TwoFactorAuth/TwoFactorAuthBackupCodesPage'
import { PersonalAccessTokensPage } from './components/PersonalAccessTokensPage'
Expand Down
8 changes: 4 additions & 4 deletions apps/SageAccountWeb/src/AppInitializer.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React, { useEffect, useState } from 'react'
import { Redirect } from 'react-router-dom'
import { getSearchParam } from './URLUtils'
import useAnalytics from './useAnalytics'
import { SignedTokenInterface } from '@sage-bionetworks/synapse-types'
import { createTheme, ThemeProvider } from '@mui/material/styles'
import { useSourceApp } from './components/SourceApp.js'
import { sageAccountWebThemeOverrides } from './style/theme'
import { Theme } from '@mui/material'
import {
useLastLoginInfoState,
SynapseTheme,
SynapseUtilityFunctions,
useApplicationSessionContext,
} from 'synapse-react-client'
import { getSearchParam } from './URLUtils'
import useAnalytics from './useAnalytics'
import { useSourceApp } from './components/SourceApp.js'
import { sageAccountWebThemeOverrides } from './style/theme'
import { AppContextProvider } from './AppContext'

function AppInitializer(props: { children?: React.ReactNode }) {
Expand Down
10 changes: 4 additions & 6 deletions apps/SageAccountWeb/src/components/AccountCreatedPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from 'react'
import { SourceAppLogo, useSourceApp, useSourceAppConfigs } from './SourceApp'
import { Button, Grid, Link, Typography } from '@mui/material'
import { AppContextConsumer } from '../AppContext'
import { Link as RouterLink } from 'react-router-dom'
import { LeftRightPanel } from './LeftRightPanel'
import { AppContextConsumer } from '../AppContext'
import useMembershipInvitationTokenHandler from '../hooks/useMembershipInvitationTokenHandler'
import { LeftRightPanel } from './LeftRightPanel'
import { SourceAppLogo, useSourceApp, useSourceAppConfigs } from './SourceApp'

export type AccountCreatedPageProps = {}

export const AccountCreatedPage = (props: AccountCreatedPageProps) => {
export const AccountCreatedPage = () => {
const membershipInvitation = useMembershipInvitationTokenHandler()
const sourceApp = useSourceApp()
const sourceAppConfigs = useSourceAppConfigs()
Expand Down
2 changes: 1 addition & 1 deletion apps/SageAccountWeb/src/components/AccountSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import {
} from 'synapse-react-client'
import { Link as RouterLink, useHistory, useLocation } from 'react-router-dom'
import { Form } from 'react-bootstrap'
import UniversalCookies from 'universal-cookie'
import { ChangePassword } from './ChangePassword'
import { ORCiDButton } from './ProfileValidation/ORCiDButton'
import AccountSettingsTopBar from './AccountSettingsTopBar'
import { ConfigureEmail } from './ConfigureEmail'
import { UnbindORCiDDialog } from './ProfileValidation/UnbindORCiD'
import UniversalCookies from 'universal-cookie'
import { StyledFormControl } from './StyledComponents'
import { ProfileAvatar } from './ProfileAvatar'
import { useSourceAppConfigs } from './SourceApp'
Expand Down
4 changes: 2 additions & 2 deletions apps/SageAccountWeb/src/components/AccountSettingsTopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { BadgeOutlined } from '@mui/icons-material'
import { Box, Button, SxProps, Typography } from '@mui/material'
import { useSourceApp } from './SourceApp'
import { useAppContext } from '../AppContext'
import {
SynapseClient,
useApplicationSessionContext,
} from 'synapse-react-client'
import { useAppContext } from '../AppContext'
import { useSourceApp } from './SourceApp'

const AccountSettingsTopBar: React.FunctionComponent = () => {
const sourceApp = useSourceApp()
Expand Down
14 changes: 10 additions & 4 deletions apps/SageAccountWeb/src/components/ConfigureEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
SynapseQueries,
useSynapseContext,
} from 'synapse-react-client'
import { getSearchParam, hexDecodeAndDeserialize } from '../URLUtils'
import {
Box,
Button,
Expand All @@ -20,6 +19,7 @@ import {
} from '@mui/material'
import DeleteIcon from '@mui/icons-material/DeleteTwoTone'
import AddCircleTwoToneIcon from '@mui/icons-material/AddCircleTwoTone'
import { getSearchParam, hexDecodeAndDeserialize } from '../URLUtils'
import { StyledFormControl } from './StyledComponents'

export type ConfigureEmailProps = {
Expand Down Expand Up @@ -158,13 +158,17 @@ export const ConfigureEmail = (props: ConfigureEmailProps) => {
<Box sx={{ flexGrow: 1, marginRight: '10px' }}>{email}</Box>
<Button
variant="outlined"
onClick={e => changePrimaryEmail(e, email)}
onClick={e => {
changePrimaryEmail(e, email)
}}
>
Make Primary
</Button>
<IconButton
aria-label="close"
onClick={e => deleteEmail(e, email)}
onClick={e => {
deleteEmail(e, email)
}}
>
<DeleteIcon />
</IconButton>
Expand Down Expand Up @@ -202,7 +206,9 @@ export const ConfigureEmail = (props: ConfigureEmailProps) => {
control={
<Checkbox
checked={sendEmailNotifications}
onChange={e => updateEmailNotifications(!sendEmailNotifications)}
onChange={e => {
updateEmailNotifications(!sendEmailNotifications)
}}
/>
}
label={
Expand Down
2 changes: 1 addition & 1 deletion apps/SageAccountWeb/src/components/CropImage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Area } from 'react-easy-crop/types'
import type { Area } from 'react-easy-crop/types'

export const createImg = (url: string) =>
new Promise<HTMLImageElement>((res, rej) => {
Expand Down
6 changes: 3 additions & 3 deletions apps/SageAccountWeb/src/components/CurrentAffiliationPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useEffect, useState } from 'react'
import { SourceAppLogo, useSourceApp } from './SourceApp'
import { InputLabel, TextField, Typography } from '@mui/material'
import { LeftRightPanel } from './LeftRightPanel'
import { StyledFormControl } from './StyledComponents'
import {
displayToast,
SynapseClient,
SynapseQueries,
useSynapseContext,
} from 'synapse-react-client'
import { Redirect } from 'react-router-dom'
import { SourceAppLogo, useSourceApp } from './SourceApp'
import { LeftRightPanel } from './LeftRightPanel'
import { StyledFormControl } from './StyledComponents'
import { ContinueButton } from './ProfileValidation/ContinueButton'

export const CurrentAffiliationPage = () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/SageAccountWeb/src/components/EmailConfirmationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const EmailConfirmationPage: React.FunctionComponent<
<div className="thankYouText">
<h3>Please check your email.</h3>
<p>
We've sent an email to <strong>{email}</strong>
We&apos;ve sent an email to <strong>{email}</strong>
</p>
<p>
Click the link in the message to verify your address, then continue
Expand All @@ -49,7 +49,7 @@ export const EmailConfirmationPage: React.FunctionComponent<
}
target="_blank"
>
I didn't receive an email
I didn&apos;t receive an email
</Link>
</div>
<Button
Expand Down
6 changes: 2 additions & 4 deletions apps/SageAccountWeb/src/components/JoinTeamPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Box, Button, Typography, useTheme } from '@mui/material'
import { useAppContext } from '../AppContext'
import {
displayToast,
SynapseClient,
Expand All @@ -15,11 +14,10 @@ import {
ResponseMessage,
} from '@sage-bionetworks/synapse-types'
import { CelebrationOutlined, Groups2Outlined } from '@mui/icons-material'
import { useAppContext } from '../AppContext'
import { StyledOuterContainer } from './StyledComponents'

export type JoinTeamPageProps = {}

export const JoinTeamPage = (props: JoinTeamPageProps) => {
export const JoinTeamPage = () => {
const context = useAppContext()
const theme = useTheme()
const [joinTeamToken, setJoinTeamToken] = useState<JoinTeamSignedToken>()
Expand Down
2 changes: 1 addition & 1 deletion apps/SageAccountWeb/src/components/LeftRightPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { StyledInnerContainer, StyledOuterContainer } from './StyledComponents'
import { Box, useTheme } from '@mui/material'
import { StyledInnerContainer, StyledOuterContainer } from './StyledComponents'

export const LeftRightPanel: React.FC<{
leftContent: JSX.Element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import { Box, Paper, Typography } from '@mui/material'
import { OAuthClientManagement } from 'synapse-react-client'
import { SourceAppLogo } from './SourceApp'
import { StyledOuterContainer } from './StyledComponents'
import { Box, Paper, Typography } from '@mui/material'
import { BackButton } from './BackButton'
import { OAuthClientManagement } from 'synapse-react-client'

export const OAuthClientManagementPage = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import { Box, Paper, Typography } from '@mui/material'
import { AccessTokenPage } from 'synapse-react-client'
import { SourceAppLogo } from './SourceApp'
import { StyledOuterContainer } from './StyledComponents'
import { Box, Paper, Typography } from '@mui/material'
import { BackButton } from './BackButton'
import { AccessTokenPage } from 'synapse-react-client'

export const PersonalAccessTokensPage = () => {
return (
Expand Down
Loading