Skip to content

Commit

Permalink
Enable @typescript-eslint/strict-type-checked preset (GMOD#392)
Browse files Browse the repository at this point in the history
* auto-fixes: typescript-eslint/strict-type-checked

* Ignore all remaining eslint errors

* Remove some eslint-disables for require-await

* Fix some TS errors

* Fix type in a test

* Remove now-unused disable from test

* Revert bad fix for eslint problem

* Revert some non-type-only changes

* Remove unused eslint disable directives
  • Loading branch information
garrettjstevens authored May 28, 2024
1 parent 6889e5b commit d998e74
Show file tree
Hide file tree
Showing 146 changed files with 605 additions and 208 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'plugin:cypress/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/strict',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:prettier/recommended',
],
Expand Down Expand Up @@ -81,10 +81,6 @@ module.exports = {
'unicorn/no-null': 'off', // A lot of null in React and other libraries
'unicorn/prefer-module': 'off', // Cypress and apollo-collaboration-server need this
'unicorn/prevent-abbreviations': 'off', // Doesn't guess a lot of abbreviations correctly
// Special case @typescript-eslint/eslint-plugin rule
// Will be part of "plugin:@typescript-eslint/recommended-type-checked" when
// that extension is enabled. Remove from here at that time.
'@typescript-eslint/no-floating-promises': 'error',
},
overrides: [
// Only use React-specific lint rules in jbrowse-plugin-apollo
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ npm install -g apollo-cli
$ apollo COMMAND
running command...
$ apollo (--version)
apollo-cli/0.0.0 linux-x64 node-v18.20.1
apollo-cli/0.0.0 linux-x64 node-v20.13.0
$ apollo --help [COMMAND]
USAGE
$ apollo COMMAND
Expand Down
13 changes: 7 additions & 6 deletions packages/apollo-cli/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import fs from 'node:fs'
import path from 'node:path'

Expand Down Expand Up @@ -175,11 +180,7 @@ export class Config {
if (arr.length === 0) {
return obj
}
return this.index(
obj[arr[0]] as unknown as RecursiveObject,
arr.slice(1),
value,
)
return this.index(obj[arr[0]] as RecursiveObject, arr.slice(1), value)
}

private addProps(
Expand Down Expand Up @@ -222,7 +223,7 @@ export class Config {
// throw new Error(`No profile name "${profileName}" found`)
return ''
}
this.addProps(profile as RecursiveObject, key)
this.addProps(profile, key)
const value = this.index(profile, key)
if (typeof value === 'object' && Object.keys(value).length === 0) {
// The key is valid but missing from config
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/assembly/add-fasta.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import * as fs from 'node:fs'
import * as path from 'node:path'

Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/assembly/add-gff.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as fs from 'node:fs'
import * as path from 'node:path'

Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/assembly/sequence.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { Flags } from '@oclif/core'
import { Response, fetch } from 'undici'

Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import fs from 'node:fs'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
Expand Down
1 change: 1 addition & 0 deletions packages/apollo-cli/src/commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import path from 'node:path'

import input from '@inquirer/input'
Expand Down
5 changes: 5 additions & 0 deletions packages/apollo-cli/src/commands/feature/add-child.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Flags } from '@oclif/core'
import { ObjectId } from 'bson'
import { Response, fetch } from 'undici'
Expand Down
4 changes: 4 additions & 0 deletions packages/apollo-cli/src/commands/feature/delete.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Flags } from '@oclif/core'
import { Response, fetch } from 'undici'

Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-cli/src/commands/feature/edit-attribute.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Flags } from '@oclif/core'
import { Response, fetch } from 'undici'

Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-cli/src/commands/feature/edit-coords.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Flags } from '@oclif/core'
import { Response, fetch } from 'undici'

Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-cli/src/commands/feature/edit-type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Flags } from '@oclif/core'
import { Response, fetch } from 'undici'

Expand Down
5 changes: 3 additions & 2 deletions packages/apollo-cli/src/commands/feature/edit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as fs from 'node:fs'

import { Flags } from '@oclif/core'
Expand All @@ -13,8 +14,8 @@ import {
export default class Get extends BaseCommand<typeof Get> {
static summary = 'Edit features using an appropiate json input'
static description = wrapLines(
`Edit a feature by submitting a json input with all the required attributes for Apollo to process it. This is a very low level command which most users probably do not need.
`Edit a feature by submitting a json input with all the required attributes for Apollo to process it. This is a very low level command which most users probably do not need.
Input may be a json string or a json file and it may be an array of changes. This is an example input for editing feature type:
{
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/feature/import.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as fs from 'node:fs'

import { Flags } from '@oclif/core'
Expand Down
15 changes: 8 additions & 7 deletions packages/apollo-cli/src/commands/feature/search.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Flags } from '@oclif/core'
import { Response, fetch } from 'undici'

Expand Down Expand Up @@ -45,23 +46,23 @@ export default class Search extends BaseCommand<typeof Search> {
static summary = 'Free text search for feature in one or more assemblies'
static description = wrapLines(
`Return features matching a query string. This command searches only in:
- Attribute *values* (not attribute names)
- Source field (which in fact is stored as an attribute)
- Feature type
The search mode is:
- Case insensitive
- Match only full words, but not necessarily the full value
- Common words are ignored. E.g. "the", "with"
For example, given this feature:
chr1 example SNP 10 30 0.987 . . "someKey=Fingerprint BAC with reads"
Queries "bac" or "mRNA" return the feature. Instead these queries will NOT match:
- "someKey"
- "with"
- "Finger"
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/login.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import fs from 'node:fs'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-cli/src/commands/login.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/no-misused-promises */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import EventEmitter from 'node:events'
import * as http from 'node:http'
import path from 'node:path'
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-cli/src/commands/logout.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import fs from 'node:fs'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
Expand Down
1 change: 1 addition & 0 deletions packages/apollo-cli/src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import path from 'node:path'

import { BaseCommand } from '../baseCommand.js'
Expand Down
5 changes: 5 additions & 0 deletions packages/apollo-cli/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import * as crypto from 'node:crypto'
import EventEmitter from 'node:events'
import * as fs from 'node:fs'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/require-await */
import {
BadRequestException,
Body,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import fs from 'node:fs/promises'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import { Body, Controller, Get, Logger, Post, Query, Req } from '@nestjs/common'
import { Change } from 'apollo-common'
import { DecodedJWT } from 'apollo-shared'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Module } from '@nestjs/common'
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose'
import { Change, ChangeSchema } from 'apollo-schemas'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import {
Logger,
NotFoundException,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { Module } from '@nestjs/common'
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose'
import { CheckResultSnapshot } from 'apollo-mst'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-base-to-string */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import { BgzipIndexedFasta, IndexedFasta } from '@gmod/indexedfasta'
import { Injectable, Logger } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import { Injectable, Logger, NotFoundException } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
import { Counter, CounterDocument } from 'apollo-schemas'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import {
Controller,
Get,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import {
Readable,
Transform,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { Module, forwardRef } from '@nestjs/common'
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose'
import { Feature, FeatureDocument, FeatureSchema } from 'apollo-schemas'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { Injectable, Logger, NotFoundException } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import {
Body,
Controller,
Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-collaboration-server/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import fs from 'node:fs'

import { LogLevel } from '@nestjs/common'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/require-await */
import { Injectable } from '@nestjs/common'
import {
SubscribeMessage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import fs from 'node:fs'
import fsPromises from 'node:fs/promises'
import path from 'node:path'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Module } from '@nestjs/common'
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose'
import { RefSeqChunk, RefSeqChunkSchema } from 'apollo-schemas'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Module } from '@nestjs/common'
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose'
import { RefSeq, RefSeqSchema } from 'apollo-schemas'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-base-to-string */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import { BgzipIndexedFasta, IndexedFasta } from '@gmod/indexedfasta'
import { Injectable, Logger } from '@nestjs/common'
import { InjectModel } from '@nestjs/mongoose'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Body, Controller, Get, Logger, Param, Post, Req } from '@nestjs/common'
import { DecodedJWT } from 'apollo-shared'
import { Request } from 'express'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { createHash } from 'node:crypto'
import { createWriteStream } from 'node:fs'
import { mkdir, mkdtemp, rename, rmdir } from 'node:fs/promises'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { ExecutionContext, Injectable } from '@nestjs/common'
import { AuthGuard, IAuthModuleOptions } from '@nestjs/passport'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { ExecutionContext, Injectable } from '@nestjs/common'
import { AuthGuard, IAuthModuleOptions } from '@nestjs/passport'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Logger } from '@nestjs/common'
import { Change, SerializedChange } from 'apollo-common'
import {
Expand Down
4 changes: 4 additions & 0 deletions packages/apollo-collaboration-server/test/app/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { INestApplication } from '@nestjs/common'
import { Test } from '@nestjs/testing'
import * as request from 'supertest'
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-common/src/AssemblySpecificChange.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { GFF3Feature } from '@gmod/gff'
import type { AnnotationFeatureSnapshot } from 'apollo-mst'
import { FileDocument, RefSeqDocument } from 'apollo-schemas'
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-common/src/Change.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { AppRootModel, Region } from '@jbrowse/core/util'
import {
AnnotationFeatureI,
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-common/src/FeatureChange.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import type { AnnotationFeatureSnapshot } from 'apollo-mst'
import { Feature } from 'apollo-schemas'
import ObjectID from 'bson-objectid'
Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-common/src/Operation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import type { ReadStream } from 'node:fs'
import type { FileHandle } from 'node:fs/promises'

Expand Down
Loading

0 comments on commit d998e74

Please sign in to comment.