Skip to content

Commit

Permalink
typescript-eslint major version updates
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens committed Nov 16, 2024
1 parent 1644cec commit fadd7fc
Show file tree
Hide file tree
Showing 35 changed files with 187 additions and 198 deletions.
12 changes: 7 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ module.exports = {
{ line: { markers: ['/'] } },
],
// @typescript-eslint/eslint-plugin rules (override recommended)
'@typescript-eslint/lines-between-class-members': [
'warn',
'always',
{ exceptAfterSingleLine: true },
],
'@typescript-eslint/no-extraneous-class': [
'error',
{ allowWithDecorator: true },
Expand Down Expand Up @@ -149,5 +144,12 @@ module.exports = {
'tsdoc/syntax': 'off',
},
},
// Temporary override
{
files: ['packages/apollo-cli/src/**/*.ts'],
rules: {
'@typescript-eslint/no-deprecated': 'off',
},
},
],
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
"@types/node": "^18.14.2",
"@types/semver": "^7",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"@yarnpkg/types": "^4.0.0",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"eslint": "^8.57.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-cypress": "^2.15.2",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-tsdoc": "^0.3.0",
"eslint-plugin-unicorn": "^48.0.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
Expand Down
6 changes: 5 additions & 1 deletion packages/apollo-cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ export const waitFor = <T>(
): Promise<T> => {
const promise = new Promise<T>((resolve, reject) => {
const handleEvent = (eventData: T): void => {
eventData instanceof Error ? reject(eventData) : resolve(eventData)
if (eventData instanceof Error) {
reject(eventData)
} else {
resolve(eventData)
}

emitter.removeListener(eventName, handleEvent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface UploadedFile extends Express.Multer.File {
export class FileStorageEngine implements StorageEngine {
private readonly logger = new Logger(FileStorageEngine.name)

// eslint-disable-next-line @typescript-eslint/no-misused-promises
async _handleFile(
req: Express.Request,
file: Express.Multer.File,
Expand Down
14 changes: 7 additions & 7 deletions packages/apollo-collaboration-server/src/files/filesUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ export class LocalFileGzip implements GenericFilehandle {
return { bytesRead, buffer }
}

public async readFile(): Promise<Buffer>
public async readFile(options: BufferEncoding): Promise<string>
public async readFile<T extends undefined>(
options:
public async readFile(
options?:
| Omit<FilehandleOptions, 'encoding'>
| (Omit<FilehandleOptions, 'encoding'> & { encoding: T }),
| (Omit<FilehandleOptions, 'encoding'> & { encoding: undefined }),
): Promise<Buffer>
public async readFile<T extends BufferEncoding>(
options: Omit<FilehandleOptions, 'encoding'> & { encoding: T },
public async readFile(
options:
| BufferEncoding
| (Omit<FilehandleOptions, 'encoding'> & { encoding: BufferEncoding }),
): Promise<string>

public async readFile(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { ApolloPlugin } from '@apollo-annotation/common'
import { Inject, Injectable } from '@nestjs/common'

import { APOLLO_PLUGINS } from './plugins.constants'

@Injectable()
export class PluginsService {
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
extensionPoints = new Map<string, Function[]>()

constructor(@Inject(APOLLO_PLUGINS) private plugins: ApolloPlugin[]) {
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo-mst/src/AnnotationFeatureModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export const AnnotationFeatureModel = types
self.max = max
}
},
setStrand(strand?: 1 | -1 | undefined) {
setStrand(strand?: 1 | -1) {
self.strand = strand
},
addChild(childFeature: AnnotationFeatureSnapshot) {
Expand Down Expand Up @@ -345,7 +345,7 @@ export type Children = IMSTMap<typeof AnnotationFeatureModel> | undefined

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface AnnotationFeatureRaw
extends Instance<typeof AnnotationFeatureModel> {}
// This type isn't exactly right, since "children" is actually an IMSTMap and
Expand All @@ -354,7 +354,7 @@ export interface AnnotationFeature
extends Omit<AnnotationFeatureRaw, 'children'> {
children?: Map<string, AnnotationFeature>
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface AnnotationFeatureSnapshotRaw
extends SnapshotIn<typeof AnnotationFeatureModel> {}
export interface AnnotationFeatureSnapshot
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-mst/src/ApolloAssembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const ApolloAssembly = types

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloAssemblyI extends Instance<typeof ApolloAssembly> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloAssemblySnapshot
extends SnapshotIn<typeof ApolloAssembly> {}
4 changes: 2 additions & 2 deletions packages/apollo-mst/src/ApolloRefSeq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const ApolloRefSeq = types

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloRefSeqI extends Instance<typeof ApolloRefSeq> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloRefSeqSnapshot extends SnapshotIn<typeof ApolloRefSeq> {}
4 changes: 2 additions & 2 deletions packages/apollo-mst/src/CheckResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const CheckResult = types.model('CheckResult', {

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface CheckResultI extends Instance<typeof CheckResult> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface CheckResultSnapshot extends SnapshotIn<typeof CheckResult> {}
2 changes: 1 addition & 1 deletion packages/apollo-shared/src/Changes/DeleteUserChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface SerializedDeleteUserChangeBase extends SerializedChange {
userId: string
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface DeleteUserChangeDetails {}

interface SerializedDeleteUserChangeSingle
Expand Down
7 changes: 4 additions & 3 deletions packages/jbrowse-plugin-apollo/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
// eslint-disable-next-line @typescript-eslint/no-var-requires

const { defineConfig } = require('cypress')
// eslint-disable-next-line @typescript-eslint/no-var-requires

const { configurePlugin } = require('cypress-mongodb')
// eslint-disable-next-line @typescript-eslint/no-var-requires

const fs = require('node:fs')

module.exports = defineConfig({
Expand Down
3 changes: 2 additions & 1 deletion packages/jbrowse-plugin-apollo/jestSetup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-var-requires */

require('jest-fetch-mock').enableMocks()
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export const AuthTypeSelector = ({
setLoginTypes(data)
}
getAuthTypes().catch((error) => {
isAbortException(error) ? '' : setErrorMessage(String(error))
if (!isAbortException(error)) {
setErrorMessage(String(error))
}
})
return () => {
controller.abort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type ApolloInternetAccountConfigModel = typeof ApolloConfigSchema

// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloInternetAccountConfig
extends Instance<ApolloInternetAccountConfigModel> {}
export default ApolloConfigSchema
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,9 @@ const stateModelFactory = (configSchema: ApolloInternetAccountConfigModel) => {
socket.on(
'REQUEST_INFORMATION',
(message: RequestUserInformationMessage) => {
const { channel, reqType, userSessionId } = message
const { channel, userSessionId } = message
if (channel === 'REQUEST_INFORMATION' && userSessionId !== token) {
switch (reqType) {
case 'CURRENT_LOCATION': {
session.broadcastLocations()
break
}
}
session.broadcastLocations()
}
},
)
Expand Down Expand Up @@ -462,6 +457,6 @@ export type ApolloInternetAccountStateModel = ReturnType<
>
// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloInternetAccountModel
extends Instance<ApolloInternetAccountStateModel> {}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class RefNameAliasAdapter
return refNameAliases
}

async freeResources() {
freeResources() {
// no resources to free
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export class DesktopFileDriver extends BackendDriver {
const { file } = getConf(assembly, ['sequence', 'metadata']) as {
file: string
}
// eslint-disable-next-line @typescript-eslint/no-var-requires

// eslint-disable-next-line @typescript-eslint/no-require-imports
const fs = require('node:fs') as typeof import('fs')
const fileContents = await fs.promises.readFile(file, 'utf8')
return loadAssemblyIntoClient(assemblyName, fileContents, this.clientStore)
Expand Down Expand Up @@ -165,7 +166,7 @@ export class DesktopFileDriver extends BackendDriver {

const gff3Contents = gff.formatSync(gff3Items)

// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const fs = require('node:fs') as typeof import('fs')
await fs.promises.writeFile(file, gff3Contents, 'utf8')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export const ApolloFeatureDetailsWidgetModel = types

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloFeatureDetailsWidget
extends Instance<typeof ApolloFeatureDetailsWidgetModel> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloFeatureDetailsWidgetSnapshot
extends SnapshotIn<typeof ApolloFeatureDetailsWidgetModel> {}

Expand Down Expand Up @@ -126,9 +126,9 @@ export const ApolloTranscriptDetailsModel = types

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloTranscriptDetailsWidget
extends Instance<typeof ApolloTranscriptDetailsModel> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ApolloTranscriptDetailsWidgetSnapshot
extends SnapshotIn<typeof ApolloTranscriptDetailsModel> {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-misused-promises */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export function stateModelFactory(
export type LinearApolloDisplayStateModel = ReturnType<typeof stateModelFactory>
// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface LinearApolloDisplay
extends Instance<LinearApolloDisplayStateModel> {}
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,6 @@ export type LinearApolloDisplayMouseEventsModel = ReturnType<
>
// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface LinearApolloDisplayMouseEvents
extends Instance<LinearApolloDisplayMouseEventsModel> {}
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,6 @@ export type LinearApolloDisplayRenderingModel = ReturnType<
>
// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface LinearApolloDisplayRendering
extends Instance<LinearApolloDisplayRenderingModel> {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BlobLocation,
LocalPathLocation,
UriLocation,
isLocalPathLocation,
isUriLocation,
} from '@jbrowse/core/util'
import {
Expand Down Expand Up @@ -43,15 +44,6 @@ export type Transaction<
/** the format of the loading data source */
type SourceType = 'obo-graph-json' | 'obo' | 'owl'

/**
* @deprecated use the one from jbrowse core when it is published
**/
function isLocalPathLocation(location: unknown): location is LocalPathLocation {
return (
typeof location === 'object' && location !== null && 'localPath' in location
)
}

async function arrayFromAsync<T>(iter: AsyncIterable<T>) {
const a = []
for await (const i of iter) {
Expand Down Expand Up @@ -508,7 +500,7 @@ export default class OntologyStore {

// fetch the full nodes and filter out deprecated ones
const terms: OntologyClass[] = []
for await (const termId of termIds) {
for (const termId of termIds) {
const node = await myTx.objectStore('nodes').get(termId)
if (node && isOntologyClass(node) && !isDeprecated(node)) {
terms.push(node)
Expand Down
4 changes: 2 additions & 2 deletions packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ export const OntologyRecordConfiguration = ConfigurationSchema(

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface OntologyManager extends Instance<typeof OntologyManagerType> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface OntologyRecord extends Instance<typeof OntologyRecordType> {}

export type OntologyTerm = OntologyDBNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,6 @@ export type SixFrameFeatureDisplayStateModel = ReturnType<
>
// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface SixFrameFeatureDisplay
extends Instance<SixFrameFeatureDisplayStateModel> {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { Menu, MenuItem } from '@jbrowse/core/ui'
import { useTheme } from '@mui/material'
import { observer } from 'mobx-react'
Expand Down
2 changes: 1 addition & 1 deletion packages/jbrowse-plugin-apollo/src/TabularEditor/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export const TabularEditorStateModelType = types

// eslint disable because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface TabularEditorStateModel
extends Instance<typeof TabularEditorStateModelType> {}
Loading

0 comments on commit fadd7fc

Please sign in to comment.