Skip to content

Commit 7d19426

Browse files
committed
Misc
1 parent ff6a881 commit 7d19426

28 files changed

+363
-337
lines changed

eslint.config.mjs

Lines changed: 57 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,20 @@
1-
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
2-
import typescriptEslint from '@typescript-eslint/eslint-plugin'
3-
import react from 'eslint-plugin-react'
4-
import reactRefresh from 'eslint-plugin-react-refresh'
1+
import eslint from '@eslint/js'
2+
import eslintPluginReact from 'eslint-plugin-react'
3+
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
4+
import eslintPluginReactRefresh from 'eslint-plugin-react-refresh'
5+
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
6+
import tseslint from 'typescript-eslint'
57
import globals from 'globals'
6-
import tsParser from '@typescript-eslint/parser'
7-
import path from 'node:path'
8-
import { fileURLToPath } from 'node:url'
9-
import js from '@eslint/js'
10-
import { FlatCompat } from '@eslint/eslintrc'
118

12-
const __filename = fileURLToPath(import.meta.url)
13-
const __dirname = path.dirname(__filename)
14-
const compat = new FlatCompat({
15-
baseDirectory: __dirname,
16-
recommendedConfig: js.configs.recommended,
17-
allConfig: js.configs.all,
18-
})
19-
20-
export default [
9+
export default tseslint.config(
2110
{
22-
ignores: ['**/coverage', '**/node_modules/', '**/dist'],
11+
ignores: ['**/dist/**/*'],
2312
},
24-
...fixupConfigRules(
25-
compat.extends(
26-
'eslint:recommended',
27-
'plugin:@typescript-eslint/recommended',
28-
'plugin:@typescript-eslint/recommended-type-checked',
29-
'plugin:@typescript-eslint/stylistic-type-checked',
30-
'plugin:react/recommended',
31-
'plugin:react-hooks/recommended',
32-
'plugin:unicorn/recommended',
33-
),
34-
),
3513
{
36-
plugins: {
37-
'@typescript-eslint': fixupPluginRules(typescriptEslint),
38-
react: fixupPluginRules(react),
39-
'react-refresh': reactRefresh,
40-
},
41-
4214
languageOptions: {
43-
globals: {
44-
...globals.browser,
45-
},
46-
47-
parser: tsParser,
48-
ecmaVersion: 'latest',
49-
sourceType: 'module',
50-
5115
parserOptions: {
52-
project: './tsconfig.json',
16+
project: ['./tsconfig.json'],
17+
tsconfigRootDir: import.meta.dirname,
5318
},
5419
},
5520

@@ -58,46 +23,63 @@ export default [
5823
version: 'detect',
5924
},
6025
},
61-
26+
},
27+
eslint.configs.recommended,
28+
...tseslint.configs.recommended,
29+
...tseslint.configs.stylisticTypeChecked,
30+
...tseslint.configs.strictTypeChecked,
31+
eslintPluginReact.configs.flat.recommended,
32+
{
33+
plugins: {
34+
'react-hooks': eslintPluginReactHooks,
35+
},
36+
rules: eslintPluginReactHooks.configs.recommended.rules,
37+
},
38+
eslintPluginUnicorn.configs['flat/recommended'],
39+
{
40+
// in main config for TSX/JSX source files
41+
plugins: {
42+
'react-refresh': eslintPluginReactRefresh,
43+
},
44+
rules: {},
45+
},
46+
{
6247
rules: {
63-
'unicorn/prevent-abbreviations': 'off',
64-
'unicorn/no-null': 'off',
65-
'unicorn/filename-case': 'off',
48+
'no-empty': 'off',
49+
'no-console': [
50+
'warn',
51+
{
52+
allow: ['error', 'warn'],
53+
},
54+
],
55+
'no-underscore-dangle': 'off',
56+
curly: 'error',
57+
semi: ['error', 'never'],
58+
'spaced-comment': [
59+
'error',
60+
'always',
61+
{
62+
markers: ['/'],
63+
},
64+
],
65+
66+
'@typescript-eslint/no-non-null-assertion': 'off',
67+
'@typescript-eslint/ban-ts-comment': 'off',
6668
'unicorn/no-useless-undefined': 'off',
6769
'unicorn/catch-error-name': 'off',
68-
'unicorn/no-nested-ternary': 'off',
69-
'unicorn/better-regex': 'off',
70-
'react/prop-types': 'off',
71-
'react/react-in-jsx-scope': 'off',
70+
'unicorn/filename-case': 'off',
71+
'unicorn/prevent-abbreviations': 'off',
7272
'react-refresh/only-export-components': 'warn',
73-
'@typescript-eslint/no-base-to-string': 'off',
74-
'@typescript-eslint/no-unsafe-member-access': 'off',
75-
'@typescript-eslint/no-unsafe-argument': 'off',
76-
'@typescript-eslint/no-unsafe-assignment': 'off',
77-
'@typescript-eslint/no-unsafe-call': 'off',
78-
'@typescript-eslint/no-unsafe-return': 'off',
79-
'@typescript-eslint/restrict-template-expressions': 'off',
80-
'@typescript-eslint/ban-ts-comment': 'off',
81-
'@typescript-eslint/no-empty-function': 'off',
82-
73+
'react/no-unescaped-entities': 'off',
74+
'react/prop-types': 'off',
8375
'@typescript-eslint/no-unused-vars': [
8476
'warn',
8577
{
8678
argsIgnorePattern: '^_',
8779
ignoreRestSiblings: true,
80+
caughtErrors: 'none',
8881
},
8982
],
90-
'no-console': [
91-
'warn',
92-
{
93-
allow: ['error', 'warn'],
94-
},
95-
],
96-
curly: 'error',
97-
'no-extra-semi': 'off',
98-
'unicorn/no-negated-condition': 'off',
99-
'unicorn/no-array-callback-reference': 'off',
100-
'unicorn/prefer-spread': 'off',
10183
},
10284
},
103-
]
85+
)

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"scripts": {
1414
"test": "jest",
1515
"clean": "rimraf dist",
16+
"format": "prettier --write .",
1617
"prebuild": "npm run clean",
1718
"start": "node esbuild.mjs",
1819
"build": "tsc && NODE_ENV=production node esbuild.mjs",
@@ -65,7 +66,8 @@
6566
"ts-jest": "^29.1.2",
6667
"ts-node": "^10.3.0",
6768
"tss-react": "^4.9.4",
68-
"typescript": "^5.3.3"
69+
"typescript": "^5.3.3",
70+
"typescript-eslint": "^8.1.0"
6971
},
7072
"author": "Colin <[email protected]>",
7173
"license": "MIT"

src/AddHighlightModel/ProteinToGenomeClickHighlight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ProteinToGenomeClickHighlight = observer(function ({
2222
const assembly = assemblyManager.get(assemblyNames[0])
2323
return assembly ? (
2424
<>
25-
{p?.clickGenomeHighlights.map((r, idx) => (
25+
{p.clickGenomeHighlights.map((r, idx) => (
2626
<Highlight
2727
key={`${JSON.stringify(r)}-${idx}}`}
2828
start={r.start}

src/AddHighlightModel/ProteinToGenomeHoverHighlight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ProteinToGenomeHoverHighlight = observer(function ({
2222
const assembly = assemblyManager.get(assemblyNames[0])
2323
return assembly ? (
2424
<>
25-
{p?.hoverGenomeHighlights.map((r, idx) => (
25+
{p.hoverGenomeHighlights.map((r, idx) => (
2626
<Highlight
2727
key={`${JSON.stringify(r)}-${idx}`}
2828
start={r.start}

src/LaunchProteinView/components/AlphaFoldDBSearch.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const AlphaFoldDBSearch = observer(function ({
116116
variant="h6"
117117
message="Looking up UniProt ID from mygene.info"
118118
/>
119-
) : !uniprotId ? (
119+
) : (uniprotId ? null : (
120120
<div>
121121
UniProt ID not found. Search sequence on AlphaFoldDB{' '}
122122
<a
@@ -130,7 +130,7 @@ const AlphaFoldDBSearch = observer(function ({
130130
After visiting the above link, then paste the structure URL into the
131131
Manual tab
132132
</div>
133-
) : null}
133+
))}
134134
{isIsoformProteinSequencesLoading ? (
135135
<LoadingEllipses
136136
variant="h6"
@@ -160,7 +160,9 @@ const AlphaFoldDBSearch = observer(function ({
160160
<Button
161161
variant="contained"
162162
color="secondary"
163-
onClick={() => handleClose()}
163+
onClick={() => {
164+
handleClose()
165+
}}
164166
>
165167
Cancel
166168
</Button>

src/LaunchProteinView/components/AlphaFoldDBSearchStatus.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ export default function AlphaFoldDBSearchStatus({
3939
: undefined
4040
const [showAllProteinSequences, setShowAllProteinSequences] = useState(false)
4141

42-
return !uniprotId ? (
43-
<Typography>
44-
Searching {getDisplayName(selectedTranscript)} for UniProt ID
45-
</Typography>
46-
) : (
42+
return uniprotId ? (
4743
<>
4844
<Typography>
4945
Found Uniprot ID:{' '}
@@ -62,7 +58,9 @@ export default function AlphaFoldDBSearchStatus({
6258
<Button
6359
variant="contained"
6460
color="primary"
65-
onClick={() => setShowAllProteinSequences(!showAllProteinSequences)}
61+
onClick={() => {
62+
setShowAllProteinSequences(!showAllProteinSequences)
63+
}}
6664
>
6765
{showAllProteinSequences
6866
? 'Hide all isoform protein sequences'
@@ -80,5 +78,9 @@ export default function AlphaFoldDBSearchStatus({
8078
<NotFound uniprotId={uniprotId} />
8179
)}
8280
</>
81+
) : (
82+
<Typography>
83+
Searching {getDisplayName(selectedTranscript)} for UniProt ID
84+
</Typography>
8385
)
8486
}

src/LaunchProteinView/components/HelpButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ export default function HelpButton() {
1010
const [show, setShow] = useState(false)
1111
return (
1212
<>
13-
<IconButton onClick={() => setShow(true)}>
13+
<IconButton
14+
onClick={() => {
15+
setShow(true)
16+
}}
17+
>
1418
<Help />
1519
</IconButton>
1620
{show ? (
1721
<Suspense fallback={null}>
18-
<HelpDialog handleClose={() => setShow(false)} />
22+
<HelpDialog
23+
handleClose={() => {
24+
setShow(false)
25+
}}
26+
/>
1927
</Suspense>
2028
) : null}
2129
</>

src/LaunchProteinView/components/HelpDialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ export default function HelpDialog({
6262
</DialogContent>
6363
<Divider />
6464
<DialogActions>
65-
<Button onClick={() => handleClose()} color="primary">
65+
<Button
66+
onClick={() => {
67+
handleClose()
68+
}}
69+
color="primary"
70+
>
6671
Close
6772
</Button>
6873
</DialogActions>

src/LaunchProteinView/components/LaunchProteinViewDialog.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ export default function LaunchProteinViewDialog({
2222
<Dialog
2323
maxWidth="xl"
2424
title="Launch protein view"
25-
onClose={() => handleClose()}
25+
onClose={() => {
26+
handleClose()
27+
}}
2628
open
2729
>
28-
<Tabs value={choice} onChange={(_, val) => setChoice(val)}>
30+
<Tabs
31+
value={choice}
32+
onChange={(_, val) => {
33+
setChoice(val)
34+
}}
35+
>
2936
<Tab value={0} label="Automatic lookup" />
3037
<Tab value={1} label="Manual" />
3138
</Tabs>

src/LaunchProteinView/components/MSATable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export default function MSATable({
7171
className={classes.margin}
7272
control={
7373
<Checkbox
74-
onChange={event => setShowInFastaFormat(event.target.checked)}
74+
onChange={event => {
75+
setShowInFastaFormat(event.target.checked)
76+
}}
7577
checked={showInFastaFormat}
7678
/>
7779
}

0 commit comments

Comments
 (0)