diff --git a/src/app/App.test.tsx b/src/app/App.test.tsx index 2b3f1338..be6e123b 100644 --- a/src/app/App.test.tsx +++ b/src/app/App.test.tsx @@ -1,5 +1,5 @@ import { expect, it } from 'vitest'; -import React, { act } from 'react'; +import { act } from 'react'; import { createRoot } from 'react-dom/client'; import Page from './index'; diff --git a/src/app/App.tsx b/src/app/App.tsx index fcc4d269..ac3dadd4 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -171,7 +171,7 @@ const App = (): React.JSX.Element => { > store.setActive( value )} + onChange={( _event, value ) => store.setActive( value )} > {TabItems} diff --git a/src/app/components/ErrorDialog.test.tsx b/src/app/components/ErrorDialog.test.tsx index be6864fe..01616ab0 100644 --- a/src/app/components/ErrorDialog.test.tsx +++ b/src/app/components/ErrorDialog.test.tsx @@ -1,5 +1,5 @@ import { expect, it, vi } from 'vitest'; -import React, { act } from 'react'; +import { act } from 'react'; import { createRoot } from 'react-dom/client'; import type { RendererBridge } from '../../common/rendererBridge'; import type RunList from '../store/RunList'; diff --git a/src/app/components/OptionCheck.tsx b/src/app/components/OptionCheck.tsx index f689af81..906b5719 100644 --- a/src/app/components/OptionCheck.tsx +++ b/src/app/components/OptionCheck.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { observer } from 'mobx-react-lite'; import type { SxProps, Theme } from '@mui/material/styles'; import FormControlLabel from '@mui/material/FormControlLabel'; diff --git a/src/app/components/OptionSelect.tsx b/src/app/components/OptionSelect.tsx index 33866371..71fd069f 100644 --- a/src/app/components/OptionSelect.tsx +++ b/src/app/components/OptionSelect.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { observer } from 'mobx-react-lite'; import type { SxProps, Theme } from '@mui/material/styles'; import FormControl from '@mui/material/FormControl'; diff --git a/src/app/components/OptionTextField.tsx b/src/app/components/OptionTextField.tsx index 4642fe08..850fb3c2 100644 --- a/src/app/components/OptionTextField.tsx +++ b/src/app/components/OptionTextField.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { observer } from 'mobx-react-lite'; import type { SxProps, Theme } from '@mui/material/styles'; import TextField from '@mui/material/TextField'; diff --git a/src/app/droppedFile.test.tsx b/src/app/droppedFile.test.tsx index c5770429..9dadcc80 100644 --- a/src/app/droppedFile.test.tsx +++ b/src/app/droppedFile.test.tsx @@ -1,5 +1,5 @@ import { expect, it, vi } from 'vitest'; -import React, { act } from 'react'; +import { act } from 'react'; import { createRoot } from 'react-dom/client'; import { ThemeProvider } from '@mui/material/styles'; import theme from './theme'; diff --git a/src/app/store/FinalAlignment.ts b/src/app/store/FinalAlignment.ts index 77a6d9dc..c69298cc 100644 --- a/src/app/store/FinalAlignment.ts +++ b/src/app/store/FinalAlignment.ts @@ -103,10 +103,7 @@ class FinalAlignment { const setMethod = this.fillTaxonGapsWithEmptySeqeunces ? union : intersection; - return setMethod.apply( - setMethod, - this.run.alignments.map( ( { taxons } ) => taxons ), - ); + return setMethod( ...this.run.alignments.map( ( { taxons } ) => taxons ) ); } get numSequences(): number { diff --git a/src/app/unhandledError.test.tsx b/src/app/unhandledError.test.tsx index f95f701f..3f3b90f4 100644 --- a/src/app/unhandledError.test.tsx +++ b/src/app/unhandledError.test.tsx @@ -1,5 +1,5 @@ import { expect, it } from 'vitest'; -import React, { act } from 'react'; +import { act } from 'react'; import { createRoot } from 'react-dom/client'; import Page from './index'; import store from './store'; diff --git a/src/common/io.test.ts b/src/common/io.test.ts index 9312f114..1608108b 100644 --- a/src/common/io.test.ts +++ b/src/common/io.test.ts @@ -1,7 +1,24 @@ // @vitest-environment node +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import { expect, it } from 'vitest'; import io from './io'; +it( 'writeAlignment writes every sequence as FASTA', async () => { + const dir = fs.mkdtempSync( path.join( os.tmpdir(), 'io-test-' ) ); + try { + const filePath = path.join( dir, 'out.fas' ); + await io.writeAlignment( filePath, { + sequences: [{ taxon: 'a', code: 'ACGT' }, { taxon: 'b', code: 'TTGA' }], + length: 4, + } ); + expect( fs.readFileSync( filePath, 'utf8' ) ).toBe( '>a\nACGT\n>b\nTTGA' ); + } finally { + fs.rmSync( dir, { recursive: true, force: true } ); + } +} ); + it( 'parseAlignment rejects a missing file with a user-fix error naming the file', async () => { await expect( io.parseAlignment( 'Tt-5.fas' ) ).rejects.toMatchObject( { isUserFix: true, diff --git a/src/common/io.ts b/src/common/io.ts index 6d428609..f8b2e677 100644 --- a/src/common/io.ts +++ b/src/common/io.ts @@ -75,17 +75,19 @@ export const writeAlignment = async ( filePath: string, alignment: Alignment ): console.log( `Write alignment in FASTA format to ${filePath}` ); console.log( alignment ); const writeStream = fs.createWriteStream( filePath ); - const write = util.promisify( writeStream.write ); - const end = util.promisify( writeStream.end ); + const write = util.promisify( + ( chunk: string, cb: ( err?: Error | null ) => void ) => writeStream.write( chunk, cb ), + ); + const end = util.promisify( ( cb: () => void ) => writeStream.end( cb ) ); for ( let i = 0; i < alignment.sequences.length; ++i ) { const prefix = i === 0 ? '>' : '\n>'; const sequence = alignment.sequences[i]; - await write.call( writeStream, `${prefix}${sequence.taxon}\n` ); - await write.call( writeStream, sequence.code ); + await write( `${prefix}${sequence.taxon}\n` ); + await write( sequence.code ); } - await end.call( writeStream ); + await end(); }; interface Io { diff --git a/src/index.tsx b/src/index.tsx index e344c5a6..aff8e277 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './app/'; diff --git a/src/main/api.ts b/src/main/api.ts index 249a2e55..c113d677 100644 --- a/src/main/api.ts +++ b/src/main/api.ts @@ -141,7 +141,7 @@ async function readalGetFormat( alignmentPath: string ): Promise { diff --git a/src/main/cancelRun.test.ts b/src/main/cancelRun.test.ts index 9e5d7033..3de2af54 100644 --- a/src/main/cancelRun.test.ts +++ b/src/main/cancelRun.test.ts @@ -31,7 +31,7 @@ it( 'cancelRun stops that run and sends no terminal event', async () => { } ); it( 'a late exit from a cancelled run leaves the next run tracked', () => { - const oldProc = { kill() { this.killed = true; } }; + const oldProc: { killed?: boolean; kill(): void } = { kill() { this.killed = true; } }; const nextProc: { killed?: boolean; kill(): void } = { kill() { this.killed = true; } }; const token = beginRun( 8 ); trackRun( 8, oldProc ); diff --git a/tsconfig.json b/tsconfig.json index 012427b4..9a1bf437 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,11 @@ "allowSyntheticDefaultImports": true, "strict": false, "noImplicitAny": true, + "noImplicitThis": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictBindCallApply": true, "skipLibCheck": true }, "include": ["src", "e2e/helpers/**/*.test.ts"]