Skip to content

Commit 6e2e864

Browse files
authoredJan 29, 2023
Bump kcd-scripts to 12.x (#1208)
* Bump kcd-scripts to 9.x * Fix lint issues * fix lint
1 parent c37ea2e commit 6e2e864

10 files changed

+36
-23
lines changed
 

‎package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@
7474
"jest-in-case": "^1.0.2",
7575
"jest-snapshot-serializer-ansi": "^1.0.0",
7676
"jest-watch-select-projects": "^2.0.0",
77-
"jsdom": "^16.4.0",
78-
"kcd-scripts": "^11.0.0",
77+
"jsdom": "19.0.0",
78+
"kcd-scripts": "^12.3.0",
7979
"typescript": "^4.1.2"
8080
},
8181
"eslintConfig": {
8282
"extends": [
8383
"./node_modules/kcd-scripts/eslint.js",
8484
"plugin:import/typescript"
8585
],
86+
"parserOptions": {
87+
"ecmaVersion": 2020
88+
},
8689
"rules": {
8790
"@typescript-eslint/prefer-optional-chain": "off",
8891
"@typescript-eslint/no-explicit-any": "off",

‎src/__tests__/config.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ describe('configuration API', () => {
1111
return {}
1212
})
1313
})
14-
afterEach(() => {
15-
configure(originalConfig)
16-
})
1714

1815
beforeEach(() => {
1916
configure({other: 123})
2017
})
2118

19+
afterEach(() => {
20+
configure(originalConfig)
21+
})
22+
2223
describe('getConfig', () => {
2324
test('returns existing configuration', () => {
2425
const conf = getConfig()

‎src/__tests__/fake-timers.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ test('recursive timers do not cause issues', async () => {
7070
let recurse = true
7171
function startTimer() {
7272
setTimeout(() => {
73+
// eslint-disable-next-line jest/no-conditional-in-test -- false-positive
7374
if (recurse) startTimer()
7475
}, 1)
7576
}

‎src/__tests__/role.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ test('accessible name filter implements TextMatch', () => {
274274
expect(
275275
getByRole('heading', {
276276
name: (name, element) => {
277+
// eslint-disable-next-line jest/no-conditional-in-test -- false-positive
277278
return element.nodeName === 'H2' && name === 'Your Signature'
278279
},
279280
}),
@@ -564,11 +565,11 @@ describe('configuration', () => {
564565
queryByRole('button', {name: 'Hello, Dave!'})
565566

566567
expect(console.error).toHaveBeenCalledTimes(2)
567-
expect(console.error.mock.calls[0][0]).toMatch(
568-
'Error: Not implemented: window.computedStyle(elt, pseudoElt)',
568+
expect(console.error.mock.calls[0][0].message).toMatch(
569+
'Not implemented: window.computedStyle(elt, pseudoElt)',
569570
)
570-
expect(console.error.mock.calls[1][0]).toMatch(
571-
'Error: Not implemented: window.computedStyle(elt, pseudoElt)',
571+
expect(console.error.mock.calls[1][0].message).toMatch(
572+
'Not implemented: window.computedStyle(elt, pseudoElt)',
572573
)
573574
} finally {
574575
jest.restoreAllMocks()

‎src/__tests__/wait-for-element-to-be-removed.js

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ test('rethrows non-testing-lib errors', () => {
9898
const error = new Error('my own error')
9999
return expect(
100100
waitForElementToBeRemoved(() => {
101+
// eslint-disable-next-line jest/no-conditional-in-test -- false-positive
101102
if (throwIt) {
102103
throw error
103104
}

‎src/__tests__/wait-for.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ test('does not work after it resolves', async () => {
275275
context = 'act'
276276
try {
277277
const result = callback()
278-
// eslint-disable-next-line jest/no-if
278+
// eslint-disable-next-line jest/no-if, jest/no-conditional-in-test -- false-positive
279279
if (typeof result?.then === 'function') {
280280
const thenable = result
281281
return {
@@ -319,6 +319,7 @@ test('does not work after it resolves', async () => {
319319

320320
await waitFor(
321321
() => {
322+
// eslint-disable-next-line jest/no-conditional-in-test -- false-positive
322323
if (data === null) {
323324
throw new Error('not found')
324325
}

‎src/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function jestFakeTimersAreEnabled() {
1010
// legacy timers
1111
(setTimeout as any)._isMockFunction === true ||
1212
// modern timers
13+
// eslint-disable-next-line prefer-object-has-own -- not supported by our support matrix
1314
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
1415
)
1516
}

‎src/queries/label-text.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,23 @@ const queryAllByLabelText: AllByText = (
7171
if (
7272
matcher(label.content, label.formControl, text, matchNormalizer) &&
7373
label.formControl
74-
)
74+
) {
7575
labelledElements.push(label.formControl)
76+
}
7677
})
7778
const labelsValue = labelList
7879
.filter(label => Boolean(label.content))
7980
.map(label => label.content)
8081
if (
8182
matcher(labelsValue.join(' '), labelledElement, text, matchNormalizer)
82-
)
83+
) {
8384
labelledElements.push(labelledElement)
85+
}
8486
if (labelsValue.length > 1) {
8587
labelsValue.forEach((labelValue, index) => {
86-
if (matcher(labelValue, labelledElement, text, matchNormalizer))
88+
if (matcher(labelValue, labelledElement, text, matchNormalizer)) {
8789
labelledElements.push(labelledElement)
90+
}
8891

8992
const labelsFiltered = [...labelsValue]
9093
labelsFiltered.splice(index, 1)
@@ -97,8 +100,9 @@ const queryAllByLabelText: AllByText = (
97100
text,
98101
matchNormalizer,
99102
)
100-
)
103+
) {
101104
labelledElements.push(labelledElement)
105+
}
102106
}
103107
})
104108
}

‎src/query-helpers.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type {
2-
GetErrorFunction,
3-
Matcher,
4-
MatcherOptions,
5-
QueryMethod,
6-
Variant,
7-
waitForOptions as WaitForOptions,
8-
WithSuggest,
1+
import {
2+
type GetErrorFunction,
3+
type Matcher,
4+
type MatcherOptions,
5+
type QueryMethod,
6+
type Variant,
7+
type waitForOptions as WaitForOptions,
8+
type WithSuggest,
99
} from '../types'
1010
import {getSuggestedQuery} from './suggestions'
1111
import {fuzzyMatches, matches, makeNormalizer} from './matches'

‎src/screen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// WARNING: `lz-string` only has a default export but statically we assume named exports are allowd
22
// TODO: Statically verify we don't rely on NodeJS implicit named imports.
33
import lzString from 'lz-string'
4-
import type {OptionsReceived} from 'pretty-format'
4+
import {type OptionsReceived} from 'pretty-format'
55
import {getQueriesForElement} from './get-queries-for-element'
66
import {getDocument} from './helpers'
77
import {logDOM} from './pretty-dom'

0 commit comments

Comments
 (0)
Please sign in to comment.