Skip to content

Commit f9b43d5

Browse files
committed
fix: disable @typescript-eslint/no-non-null-assertion
1 parent ce2f04d commit f9b43d5

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"import/prefer-default-export": "off",
6666
"import/no-unassigned-import": "off",
6767
"import/no-useless-path-segments": "off",
68-
"no-console": "off"
68+
"no-console": "off",
69+
"@typescript-eslint/no-non-null-assertion": "off"
6970
}
7071
},
7172
"eslintIgnore": [

src/__tests__/suggestions.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,37 +188,35 @@ test('escapes regular expressions in suggestion', () => {
188188

189189
expect(
190190
getSuggestedQuery(
191-
container.querySelector('img') as HTMLImageElement,
191+
container.querySelector('img')!,
192192
'get',
193193
'AltText',
194194
)?.toString(),
195195
).toEqual(`getByAltText(/the problem \\(picture of a question mark\\)/i)`)
196196

197-
expect(
198-
getSuggestedQuery(
199-
container.querySelector('p') as HTMLParagraphElement,
200-
)?.toString(),
201-
).toEqual(`getByText(/loading \\.\\.\\. \\(1\\)/i)`)
197+
expect(getSuggestedQuery(container.querySelector('p')!)?.toString()).toEqual(
198+
`getByText(/loading \\.\\.\\. \\(1\\)/i)`,
199+
)
202200

203201
expect(
204202
getSuggestedQuery(
205-
container.querySelector('input') as HTMLInputElement,
203+
container.querySelector('input')!,
206204
'get',
207205
'PlaceholderText',
208206
)?.toString(),
209207
).toEqual(`getByPlaceholderText(/should escape \\+\\-'\\(\\//i)`)
210208

211209
expect(
212210
getSuggestedQuery(
213-
container.querySelector('input') as HTMLInputElement,
211+
container.querySelector('input')!,
214212
'get',
215213
'DisplayValue',
216214
)?.toString(),
217215
).toEqual(`getByDisplayValue(/my super string \\+\\-\\('\\{\\}\\^\\$\\)/i)`)
218216

219217
expect(
220218
getSuggestedQuery(
221-
container.querySelector('input') as HTMLInputElement,
219+
container.querySelector('input')!,
222220
'get',
223221
'LabelText',
224222
)?.toString(),
@@ -437,9 +435,8 @@ test('getSuggestedQuery can return specified methods in addition to the best', (
437435
<button>button</button>
438436
`)
439437

440-
const input = container.querySelector('input') as HTMLInputElement
441-
const button = container.querySelector('button') as HTMLButtonElement
442-
438+
const input = container.querySelector('input')!
439+
const button = container.querySelector('button')!
443440
// this function should be insensitive for the method param.
444441
// Role and role should work the same
445442
expect(getSuggestedQuery(input, 'get', 'role')).toMatchObject({
@@ -520,7 +517,7 @@ test('getSuggestedQuery works with custom testIdAttribute', () => {
520517
<button>button</button>
521518
`)
522519

523-
const input = container.querySelector('input') as HTMLInputElement
520+
const input = container.querySelector('input')!
524521

525522
expect(getSuggestedQuery(input, 'get', 'TestId')).toMatchObject({
526523
queryName: 'TestId',
@@ -536,8 +533,8 @@ test('getSuggestedQuery does not create suggestions for script and style element
536533
<style data-testid="style"></style>
537534
`)
538535

539-
const script = container.querySelector('script') as HTMLScriptElement
540-
const style = container.querySelector('style') as HTMLStyleElement
536+
const script = container.querySelector('script')!
537+
const style = container.querySelector('style')!
541538

542539
expect(getSuggestedQuery(script, 'get', 'TestId')).toBeUndefined()
543540
expect(getSuggestedQuery(style, 'get', 'TestId')).toBeUndefined()
@@ -557,11 +554,7 @@ test('should get the first label with aria-labelledby contains multiple ids', ()
557554
`)
558555

559556
expect(
560-
getSuggestedQuery(
561-
container.querySelector('input') as HTMLInputElement,
562-
'get',
563-
'LabelText',
564-
),
557+
getSuggestedQuery(container.querySelector('input')!, 'get', 'LabelText'),
565558
).toMatchObject({
566559
queryName: 'LabelText',
567560
queryMethod: 'getByLabelText',
@@ -603,7 +596,7 @@ test('should suggest hidden option if element is not in the accessibility tree',
603596
`)
604597

605598
const suggestion = getSuggestedQuery(
606-
container.querySelector('input') as HTMLInputElement,
599+
container.querySelector('input')!,
607600
'get',
608601
'role',
609602
)
@@ -643,7 +636,7 @@ test('should find label text using the aria-labelledby', () => {
643636

644637
expect(
645638
getSuggestedQuery(
646-
container.querySelector('[id="sixth-id"]') as HTMLInputElement,
639+
container.querySelector('[id="sixth-id"]')!,
647640
'get',
648641
'LabelText',
649642
),

0 commit comments

Comments
 (0)