Skip to content

Commit

Permalink
apply typescript-eslint/prefer-ts-expect-error
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Nov 14, 2023
1 parent b136fd6 commit d24b3c0
Show file tree
Hide file tree
Showing 30 changed files with 66 additions and 67 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
}],
rules: {
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
}
}
4 changes: 2 additions & 2 deletions design-system/packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const forwardRefWithAs = <DefaultElementType extends ElementType, BasePro
ref: React.Ref<any>
) => Exclude<ReactNode, undefined>
): CompWithAsProp<BaseProps, DefaultElementType> => {
// @ts-ignore
// @ts-expect-error
return forwardRef(render)
}

Expand Down Expand Up @@ -105,7 +105,7 @@ export const mapResponsiveProp = <
if (Array.isArray(value)) {
return value.map(k => (k == null ? null : valueMap[k]))
}
// @ts-ignore
// @ts-expect-error
return valueMap[value]
}

Expand Down
2 changes: 1 addition & 1 deletion design-system/packages/modals/src/DrawerBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const DrawerBase = ({
if (onSubmit) {
Tag = 'form'
let oldOnSubmit = onSubmit
// @ts-ignore
// @ts-expect-error
onSubmit = (event: any) => {
if (!event.defaultPrevented) {
event.preventDefault()
Expand Down
12 changes: 6 additions & 6 deletions docs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ export function Header () {
document.body.style.overflow = 'auto'
// search - init field
let searchAttempt = 0
// @ts-ignore
// @ts-expect-error
document.getElementById('search-field').disabled = true
const loadSearch = (searchAttempt: number) => {
// @ts-ignore
// @ts-expect-error
if (window.docsearch && searchAttempt < 10) {
// @ts-ignore
// @ts-expect-error
document.getElementById('search-field').disabled = false
// @ts-ignore
// @ts-expect-error
window.docsearch({
appId: 'N3ZF861Q5G',
apiKey: 'f52fa93b9068fe8824beab5727ae84a1',
Expand All @@ -278,14 +278,14 @@ export function Header () {
transformData: (results: any) => {
if (window.location.hostname == 'keystonejs.com') return results
return results.map((result: object) => {
// @ts-ignore
// @ts-expect-error
result.url = result.url.replace('https://keystonejs.com', window.location.origin)
return result
})
},
})
} else if (searchAttempt >= 10) {
// @ts-ignore
// @ts-expect-error
document.getElementById('search-field-container').style.visibility = 'hidden'
} else {
setTimeout(() => loadSearch(searchAttempt++), 500)
Expand Down
2 changes: 1 addition & 1 deletion docs/lib/forwardRefWithAs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export const forwardRefWithAs = <DefaultElementType extends ElementType, BasePro
ref: React.Ref<any>
) => Exclude<ReactNode, undefined>
): CompWithAsProp<BaseProps, DefaultElementType> => {
// @ts-ignore
// @ts-expect-error
return forwardRef(render)
}
6 changes: 3 additions & 3 deletions examples/extend-graphql-subscriptions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ export const extendGraphqlSchema = (schema: GraphQLSchema) =>
// add the subscription resolvers
Subscription: {
time: {
// @ts-ignore
// @ts-expect-error
subscribe: () => pubSub.asyncIterator(['TIME']),
},
postPublished: {
// @ts-ignore
// @ts-expect-error
subscribe: () => pubSub.asyncIterator(['POST_PUBLISHED']),
},
postUpdated: {
// @ts-ignore
// @ts-expect-error
subscribe: () => pubSub.asyncIterator(['POST_UPDATED']),
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/pages/SigninPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const SigninPage = ({
if (!submitted) return

// TODO: this is horrible, we need to resolve this mess
// @ts-ignore
// @ts-expect-error
if (rawKeystone.adminMeta?.error?.message === 'Access denied') {
router.push('/no-access')
return
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudinary/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function cloudinaryImage<ListTypeInfo extends BaseListTypeInfo> ({
const { public_id, format } = val._meta

// ref https://github.com/cloudinary/cloudinary_npm/blob/439586eac73cee7f2803cf19f885e98f237183b3/src/utils.coffee#L472
// @ts-ignore
// @ts-expect-error
return cloudinary.url(public_id, {
type: 'upload',
format,
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudinary/src/test-fixtures.skip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createReadStream } from 'node:fs'
import { resolve, basename } from 'node:path'
// @ts-ignore
// @ts-expect-error
import Upload from 'graphql-upload/Upload.js'
import cloudinary from 'cloudinary'
import { cloudinaryImage } from './index'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/password/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import bcryptjs from 'bcryptjs'
// @ts-ignore
// @ts-expect-error
import dumbPasswords from 'dumb-passwords'
import { userInputError } from '../../../lib/core/graphql-errors'
import { humanize } from '../../../lib/utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/password/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EyeIcon } from '@keystone-ui/icons/icons/EyeIcon'
import { EyeOffIcon } from '@keystone-ui/icons/icons/EyeOffIcon'
import { XIcon } from '@keystone-ui/icons/icons/XIcon'
import { SegmentedControl } from '@keystone-ui/segmented-control'
// @ts-ignore
// @ts-expect-error
import dumbPasswords from 'dumb-passwords'
import {
type CardValueComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export const RelationshipSelect = ({
? {
value: state.value.id,
label: state.value.label,
// @ts-ignore
// @ts-expect-error
data: state.value.data,
}
: null
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/core/access-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function getOperationAccess (
const access = list.access.operation[operation]
let result
try {
// @ts-ignore
// @ts-expect-error
result = await access(args)
} catch (error: any) {
throw extensionError('Access control', [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/server/createExpressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { GraphQLFormattedError, GraphQLSchema } from 'graphql'
import { ApolloServer, type ApolloServerOptions } from '@apollo/server'
import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default'
// @ts-ignore
// @ts-expect-error
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js'
import type { KeystoneConfig, KeystoneContext, GraphQLConfig } from '../../types'
import { addHealthCheck } from './addHealthCheck'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/schema/graphql-ts-schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ReadStream } from 'fs'
import * as graphqlTsSchema from '@graphql-ts/schema'
// @ts-ignore
// @ts-expect-error
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
import { GraphQLError, GraphQLScalarType } from 'graphql'
import { Decimal as DecimalValue } from 'decimal.js'
Expand Down
14 changes: 7 additions & 7 deletions packages/core/tests/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ jest.mock('ci-info', () => {
const lists: Record<string, InitialisedList> = {
Thing: {
fields: {
// @ts-ignore
// @ts-expect-error
id: {
__ksTelemetryFieldTypeName: 'id',
},
// @ts-ignore
// @ts-expect-error
name: {
__ksTelemetryFieldTypeName: 'id',
},
// @ts-ignore
// @ts-expect-error
thing: {
__ksTelemetryFieldTypeName: 'id',
},
},
},
Stuff: {
fields: {
// @ts-ignore
// @ts-expect-error
id: {
__ksTelemetryFieldTypeName: 'id',
},
// @ts-ignore
// @ts-expect-error
name: {
__ksTelemetryFieldTypeName: 'id',
},
Expand Down Expand Up @@ -229,12 +229,12 @@ describe('Telemetry tests', () => {
const envBefore = process.env[key]

beforeEach(() => {
// @ts-ignore
// @ts-expect-error
process.env[key] = value
})

afterEach(() => {
// @ts-ignore
// @ts-expect-error
process.env[key] = envBefore
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mdASTUtilFromMarkdown from 'mdast-util-from-markdown'
// @ts-ignore
// @ts-expect-error
import autoLinkLiteralFromMarkdownExtension from 'mdast-util-gfm-autolink-literal/from-markdown'
// @ts-ignore
// @ts-expect-error
import autoLinkLiteralMarkdownSyntax from 'micromark-extension-gfm-autolink-literal'
// @ts-ignore
// @ts-expect-error
import gfmStrikethroughFromMarkdownExtension from 'mdast-util-gfm-strikethrough/from-markdown'
import gfmStrikethroughMarkdownSyntax from 'micromark-extension-gfm-strikethrough'
import { type Block } from '..'
Expand Down
6 changes: 3 additions & 3 deletions tests/api-tests/access-control/mutations-field.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const runner = setupTestRunner({
}),
badAccess: text({
access: {
// @ts-ignore Intentionally return a string for testing purposes
// @ts-expect-error Intentionally return a string for testing purposes
read: () => 'non boolean value',
// @ts-ignore Intentionally return a string for testing purposes
// @ts-expect-error Intentionally return a string for testing purposes
create: () => 'non boolean value',
// @ts-ignore Intentionally return a string for testing purposes
// @ts-expect-error Intentionally return a string for testing purposes
update: () => 'non boolean value',
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ const runner = setupTestRunner({
fields: { name: text() },
access: {
operation: {
// @ts-ignore Intentionally return a filter for testing purposes
// @ts-expect-error Intentionally return a filter for testing purposes
query: () => {
return { name: { not: { equals: 'bad' } } }
},
// @ts-ignore Intentionally return a filter for testing purposes
// @ts-expect-error Intentionally return a filter for testing purposes
create: () => {
return { name: { not: { equals: 'bad' } } }
},
// @ts-ignore Intentionally return a filter for testing purposes
// @ts-expect-error Intentionally return a filter for testing purposes
update: () => {
return { name: { not: { equals: 'bad' } } }
},
// @ts-ignore Intentionally return a filter for testing purposes
// @ts-expect-error Intentionally return a filter for testing purposes
delete: async () => {
return { name: { not: { startsWtih: 'no delete' } } }
},
Expand Down
4 changes: 2 additions & 2 deletions tests/api-tests/fields/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createHash } from 'crypto'
import os from 'os'
import fs from 'fs-extra'
import fetch from 'node-fetch'
// @ts-ignore
// @ts-expect-error
import Upload from 'graphql-upload/Upload.js'
import mime from 'mime'
import { file, text } from '@keystone-6/core/fields'
Expand All @@ -21,7 +21,7 @@ export const prepareFile = (_filePath: string, kind: 'image' | 'file') => {
upload.resolve({
createReadStream: () => fs.createReadStream(filePath),
filename: path.basename(filePath),
// @ts-ignore
// @ts-expect-error
mimetype: mime.getType(filePath),
encoding: 'utf-8',
})
Expand Down
4 changes: 2 additions & 2 deletions tests/api-tests/fields/images.crud.test.disabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createHash } from 'crypto'
import os from 'os'
import fs from 'fs-extra'
import fetch from 'node-fetch'
// @ts-ignore
// @ts-expect-error
import Upload from 'graphql-upload/Upload.js'
import mime from 'mime'
import { text, image } from '@keystone-6/core/fields'
Expand All @@ -21,7 +21,7 @@ export const prepareFile = (_filePath: string, kind: 'image' | 'file') => {
upload.resolve({
createReadStream: () => fs.createReadStream(filePath),
filename: path.basename(filePath),
// @ts-ignore
// @ts-expect-error
mimetype: mime.getType(filePath),
encoding: 'utf-8',
})
Expand Down
4 changes: 2 additions & 2 deletions tests/api-tests/fields/types/fixtures/file/test-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import os from 'os'
import fs from 'fs-extra'
// @ts-ignore
// @ts-expect-error
import Upload from 'graphql-upload/Upload.js'
import mime from 'mime'
import { file } from '@keystone-6/core/fields'
Expand All @@ -13,7 +13,7 @@ export const prepareFile = (_filePath: string) => {
upload.resolve({
createReadStream: () => fs.createReadStream(filePath),
filename: path.basename(filePath),
// @ts-ignore
// @ts-expect-error
mimetype: mime.getType(filePath),
encoding: 'utf-8',
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import os from 'os'
import fs from 'fs-extra'
// @ts-ignore
// @ts-expect-error
import Upload from 'graphql-upload/Upload.js'
import mime from 'mime'
import { type KeystoneConfig } from '@keystone-6/core/types'
Expand All @@ -13,7 +13,7 @@ export const prepareFile = (_filePath: string) => {
upload.resolve({
createReadStream: () => fs.createReadStream(filePath),
filename: path.basename(filePath),
// @ts-ignore
// @ts-expect-error
mimetype: mime.getType(filePath),
encoding: 'utf-8',
})
Expand Down
4 changes: 2 additions & 2 deletions tests/api-tests/hooks/hook-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ function stripStackTrace (errors: any[] = []) {
(['dev', 'production'] as const).map(mode =>
describe(`NODE_ENV=${mode}, debug=${debug} useHttp=${useHttp}`, () => {
beforeAll(() => {
// @ts-ignore
// @ts-expect-error
process.env.NODE_ENV = mode
})
afterAll(() => {
// @ts-ignore
// @ts-expect-error
process.env.NODE_ENV = 'test'
});

Expand Down
10 changes: 5 additions & 5 deletions tests/api-tests/queries/orderBy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const runner = setupTestRunner({
orderTrue: integer({ isOrderable: true }),
orderFunctionFalse: integer({ isOrderable: () => false }),
orderFunctionTrue: integer({ isOrderable: () => true }),
// @ts-ignore
// @ts-expect-error
orderFunctionOtherFalsey: integer({ isOrderable: () => null }),
// @ts-ignore
// @ts-expect-error
orderFunctionOtherTruthy: integer({ isOrderable: () => ({}) }),
orderFunctionFalseToo: integer({ isOrderable: () => false }),
},
Expand All @@ -44,7 +44,7 @@ const runner = setupTestRunner({
DefaultOrderTrue: list({
access: allowAll,
fields: { a: integer(), b: integer({ isOrderable: true }) },
// @ts-ignore
// @ts-expect-error
defaultIsOrderable: true,
}),
DefaultOrderFunctionFalse: list({
Expand All @@ -60,13 +60,13 @@ const runner = setupTestRunner({
DefaultOrderFunctionFalsey: list({
access: allowAll,
fields: { a: integer(), b: integer({ isOrderable: true }) },
// @ts-ignore
// @ts-expect-error
defaultIsOrderable: () => null,
}),
DefaultOrderFunctionTruthy: list({
access: allowAll,
fields: { a: integer(), b: integer({ isOrderable: true }) },
// @ts-ignore
// @ts-expect-error
defaultIsOrderable: () => ({}),
}),
},
Expand Down
Loading

0 comments on commit d24b3c0

Please sign in to comment.