Skip to content

Commit 0105ad3

Browse files
committed
chore: modernize things (lint TS)
1 parent 3679627 commit 0105ad3

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
"pretty-format": "^26.6.2"
4949
},
5050
"devDependencies": {
51-
"@testing-library/jest-dom": "^5.11.5",
51+
"@testing-library/jest-dom": "^5.11.6",
5252
"@types/estree": "0.0.45",
5353
"dtslint": "^4.0.5",
5454
"jest-in-case": "^1.0.2",
5555
"jest-serializer-ansi": "^1.0.3",
5656
"jest-watch-select-projects": "^2.0.0",
5757
"jsdom": "^16.4.0",
58-
"kcd-scripts": "^6.7.0",
58+
"kcd-scripts": "^7.0.3",
5959
"typescript": "^4.0.5"
6060
},
6161
"eslintConfig": {

src/__tests__/suggestions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ test('should get the first label with aria-labelledby contains multiple ids', ()
552552
})
553553

554554
test('should suggest hidden option if element is not in the accessibilty tree', () => {
555+
console.warn.mockImplementation(() => {})
556+
555557
const {container} = renderIntoDocument(`
556558
<input type="text" aria-hidden=true />
557559
`)

types/.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"rules": {
3+
"one-var": "off",
4+
"@typescript-eslint/no-explicit-any": "off" // let's do better in the future
5+
}
6+
}

types/__tests__/type-tests.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const {
2323
findByRole,
2424
} = queries
2525

26-
async function testQueries() {
26+
export async function testQueries() {
2727
// element queries
2828
const element = document.createElement('div')
2929
getByText(element, 'foo')
@@ -46,7 +46,7 @@ async function testQueries() {
4646
await screen.findAllByText('bar', undefined, {timeout: 10})
4747
}
4848

49-
async function testQueryHelpers() {
49+
export async function testQueryHelpers() {
5050
const element = document.createElement('div')
5151
const includesAutomationId = (content: string, automationId: string) =>
5252
content.split(/\s+/).some(id => id === automationId)
@@ -78,16 +78,16 @@ async function testQueryHelpers() {
7878
queryByAutomationId(element, 'id')
7979
getAllByAutomationId(element, 'id')
8080
getByAutomationId(element, ['id', 'automationId'])
81-
findAllByAutomationId(element, 'id', {}, {timeout: 1000})
82-
findByAutomationId(element, 'id', {}, {timeout: 1000})
81+
await findAllByAutomationId(element, 'id', {}, {timeout: 1000})
82+
await findByAutomationId(element, 'id', {}, {timeout: 1000})
8383
// test optional params too
84-
findAllByAutomationId(element, 'id', {})
85-
findByAutomationId(element, 'id', {})
86-
findAllByAutomationId(element, 'id')
87-
findByAutomationId(element, 'id')
84+
await findAllByAutomationId(element, 'id', {})
85+
await findByAutomationId(element, 'id', {})
86+
await findAllByAutomationId(element, 'id')
87+
await findByAutomationId(element, 'id')
8888
}
8989

90-
async function testByRole() {
90+
export async function testByRole() {
9191
const element = document.createElement('button')
9292
element.setAttribute('aria-hidden', 'true')
9393

@@ -115,8 +115,7 @@ async function testByRole() {
115115
console.assert(queryByRole(element, 'button', {name: /^Log/}) === null)
116116
console.assert(
117117
queryByRole(element, 'button', {
118-
name: (name, element) =>
119-
name === 'Login' && element.hasAttribute('disabled'),
118+
name: (name, el) => name === 'Login' && el.hasAttribute('disabled'),
120119
}) === null,
121120
)
122121

@@ -127,12 +126,12 @@ async function testByRole() {
127126
console.assert(screen.queryByRole(/foo/) === null)
128127
}
129128

130-
function testA11yHelper() {
129+
export function testA11yHelper() {
131130
const element = document.createElement('svg')
132131
console.assert(!isInaccessible(element))
133132
}
134133

135-
function eventTest() {
134+
export function eventTest() {
136135
fireEvent.popState(window, {
137136
location: 'http://www.example.com/?page=1',
138137
state: {page: 1},
@@ -156,7 +155,7 @@ function eventTest() {
156155
fireEvent(element, customEvent)
157156
}
158157

159-
async function testWaitFors() {
158+
export async function testWaitFors() {
160159
const element = document.createElement('div')
161160

162161
await waitFor(() => getByText(element, 'apple'))
@@ -181,3 +180,8 @@ async function testWaitFors() {
181180

182181
await waitFor(async () => {})
183182
}
183+
184+
/*
185+
eslint
186+
@typescript-eslint/no-unnecessary-condition: "off",
187+
*/

types/screen.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import {OptionsReceived} from 'pretty-format'
12
import {BoundFunctions, Queries} from './get-queries-for-element'
23
import * as queries from './queries'
3-
import {OptionsReceived} from 'pretty-format'
44

55
export type Screen<Q extends Queries = typeof queries> = BoundFunctions<Q> & {
66
/**

0 commit comments

Comments
 (0)