Skip to content

Commit aad0849

Browse files
Dependabot/npm and yarn/callstack/eslint config 14.0.0 (#1526)
* chore(deps-dev): bump @callstack/eslint-config from 13.0.2 to 14.0.0 Bumps [@callstack/eslint-config](https://github.com/callstack/eslint-config-callstack) from 13.0.2 to 14.0.0. - [Release notes](https://github.com/callstack/eslint-config-callstack/releases) - [Commits](callstack/eslint-config-callstack@v13.0.2...v14.0.0) --- updated-dependencies: - dependency-name: "@callstack/eslint-config" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * refactor: fix lint issues * refactor: fix lint issues * refactor: fix lint issues * refactor: fix lint issues * chore: update callstack-eslint config --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 4549e7b commit aad0849

22 files changed

+498
-158
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@babel/preset-flow": "^7.22.15",
4242
"@babel/preset-react": "^7.22.15",
4343
"@babel/preset-typescript": "^7.22.15",
44-
"@callstack/eslint-config": "^13.0.1",
44+
"@callstack/eslint-config": "^14.1.0",
4545
"@relmify/jest-serializer-strip-ansi": "^1.0.2",
4646
"@types/jest": "^29.5.5",
4747
"@types/react": "^18.2.21",

Diff for: src/__tests__/act.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test('fireEvent should trigger useState', () => {
4141
expect(counter.props.children).toEqual('Total count: 1');
4242
});
4343

44-
test('should be able to not await act', async () => {
44+
test('should be able to not await act', () => {
4545
const result = act(() => {});
4646
expect(result).toHaveProperty('then');
4747
});
@@ -52,5 +52,5 @@ test('should be able to await act', async () => {
5252
});
5353

5454
test('should be able to await act when promise rejects', async () => {
55-
await expect(act(async () => Promise.reject('error'))).rejects.toBe('error');
55+
await expect(act(() => Promise.reject('error'))).rejects.toBe('error');
5656
});

Diff for: src/__tests__/render-hook.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('allows rerendering', () => {
4545
expect(result.current).toEqual(['right', expect.any(Function)]);
4646
});
4747

48-
test('allows wrapper components', async () => {
48+
test('allows wrapper components', () => {
4949
const Context = React.createContext('default');
5050
function Wrapper({ children }: { children: ReactNode }) {
5151
return <Context.Provider value="provided">{children}</Context.Provider>;

Diff for: src/__tests__/timer-utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { setTimeout } from '../helpers/timers';
22

3-
async function sleep(ms: number): Promise<void> {
3+
function sleep(ms: number): Promise<void> {
44
return new Promise((resolve) => setTimeout(resolve, ms));
55
}
66

Diff for: src/__tests__/wait-for-element-to-be-removed.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { render, fireEvent, waitForElementToBeRemoved } from '..';
55
const TestSetup = ({ shouldUseDelay = true }) => {
66
const [isAdded, setIsAdded] = useState(true);
77

8-
const removeElement = async () => {
8+
const removeElement = () => {
99
if (shouldUseDelay) {
1010
setTimeout(() => setIsAdded(false), 300);
1111
} else {

Diff for: src/__tests__/wait-for.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ test.each([
281281

282282
// On mount, set the color to "red" in a promise microtask
283283
React.useEffect(() => {
284-
// eslint-disable-next-line promise/prefer-await-to-then, promise/catch-or-return
284+
// eslint-disable-next-line @typescript-eslint/no-floating-promises, promise/catch-or-return, promise/prefer-await-to-then
285285
Promise.resolve('red').then((c) => setColor(c));
286286
}, []);
287287

Diff for: src/fire-event.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function findEventHandler(
8888
if (handler && isEventEnabled(element, eventName, touchResponder))
8989
return handler;
9090

91+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
9192
if (element.parent === null || element.parent.parent === null) {
9293
return null;
9394
}
@@ -141,7 +142,7 @@ function fireEvent(
141142
}
142143

143144
let returnValue;
144-
act(() => {
145+
void act(() => {
145146
returnValue = handler(...data);
146147
});
147148

Diff for: src/helpers/__tests__/timers.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { jestFakeTimersAreEnabled } from '../timers';
22
describe('timers', () => {
3-
it('should not mock timers if RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS is set', async () => {
3+
it('should not mock timers if RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS is set', () => {
44
process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS = 'true';
55
jest.useFakeTimers();
66
expect(jestFakeTimersAreEnabled()).toEqual(false);

Diff for: src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { cleanup } from './pure';
22
import { flushMicroTasksLegacy } from './flush-micro-tasks';
33
import { getIsReactActEnvironment, setReactActEnvironment } from './act';
44

5-
if (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {
5+
if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
66
// If we're running in a test runner that supports afterEach
77
// then we'll automatically run cleanup afterEach test
88
// this ensures that tests run in isolation from each other

Diff for: src/matchers/__tests__/to-have-accessible-name.test.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('toHaveAccessibleName() handles view with "aria-label" prop', () => {
1717
expect(element).not.toHaveAccessibleName('Other label');
1818
});
1919

20-
test('toHaveAccessibleName() handles view with "accessibilityLabelledBy" prop', async () => {
20+
test('toHaveAccessibleName() handles view with "accessibilityLabelledBy" prop', () => {
2121
render(
2222
<View>
2323
<Text nativeID="label">External label</Text>
@@ -30,7 +30,7 @@ test('toHaveAccessibleName() handles view with "accessibilityLabelledBy" prop',
3030
expect(element).not.toHaveAccessibleName('Other label');
3131
});
3232

33-
test('toHaveAccessibleName() handles nested "accessibilityLabelledBy"', async () => {
33+
test('toHaveAccessibleName() handles nested "accessibilityLabelledBy"', () => {
3434
render(
3535
<>
3636
<View nativeID="label">
@@ -45,7 +45,7 @@ test('toHaveAccessibleName() handles nested "accessibilityLabelledBy"', async ()
4545
expect(element).not.toHaveAccessibleName('Other label');
4646
});
4747

48-
test('toHaveAccessibleName() handles view with nested "accessibilityLabelledBy" with no text', async () => {
48+
test('toHaveAccessibleName() handles view with nested "accessibilityLabelledBy" with no text', () => {
4949
render(
5050
<>
5151
<View nativeID="label">
@@ -59,7 +59,7 @@ test('toHaveAccessibleName() handles view with nested "accessibilityLabelledBy"
5959
expect(element).not.toHaveAccessibleName();
6060
});
6161

62-
test('toHaveAccessibleName() handles view with "aria-labelledby" prop', async () => {
62+
test('toHaveAccessibleName() handles view with "aria-labelledby" prop', () => {
6363
render(
6464
<View>
6565
<Text nativeID="label">External label</Text>

Diff for: src/queries/__tests__/accessibility-state.test.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ test('byA11yState queries support hidden option', () => {
277277
`);
278278
});
279279

280-
test('*ByA11yState deprecation warnings', () => {
280+
test('*ByA11yState deprecation warnings', async () => {
281281
const mockCalls = (console.warn as ConsoleLogMock).mock.calls;
282282
const view = render(<View accessibilityState={{ disabled: true }} />);
283283

@@ -309,22 +309,22 @@ test('*ByA11yState deprecation warnings', () => {
309309
Use queryAllByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from "@testing-library/jest-native" package instead."
310310
`);
311311

312-
view.findByA11yState({ disabled: true });
312+
await view.findByA11yState({ disabled: true });
313313
expect(mockCalls[4][0]).toMatchInlineSnapshot(`
314314
"findByA11yState(...) is deprecated and will be removed in the future.
315315
316316
Use findByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from "@testing-library/jest-native" package instead."
317317
`);
318318

319-
view.findAllByA11yState({ disabled: true });
319+
await view.findAllByA11yState({ disabled: true });
320320
expect(mockCalls[5][0]).toMatchInlineSnapshot(`
321321
"findAllByA11yState(...) is deprecated and will be removed in the future.
322322
323323
Use findAllByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from "@testing-library/jest-native" package instead."
324324
`);
325325
});
326326

327-
test('*ByAccessibilityState deprecation warnings', () => {
327+
test('*ByAccessibilityState deprecation warnings', async () => {
328328
const mockCalls = (console.warn as ConsoleLogMock).mock.calls;
329329
const view = render(<View accessibilityState={{ disabled: true }} />);
330330

@@ -356,14 +356,14 @@ test('*ByAccessibilityState deprecation warnings', () => {
356356
Use queryAllByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from "@testing-library/jest-native" package instead."
357357
`);
358358

359-
view.findByAccessibilityState({ disabled: true });
359+
await view.findByAccessibilityState({ disabled: true });
360360
expect(mockCalls[4][0]).toMatchInlineSnapshot(`
361361
"findByAccessibilityState(...) is deprecated and will be removed in the future.
362362
363363
Use findByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from "@testing-library/jest-native" package instead."
364364
`);
365365

366-
view.findAllByAccessibilityState({ disabled: true });
366+
await view.findAllByAccessibilityState({ disabled: true });
367367
expect(mockCalls[5][0]).toMatchInlineSnapshot(`
368368
"findAllByAccessibilityState(...) is deprecated and will be removed in the future.
369369

Diff for: src/queries/__tests__/accessibility-value.test.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test('byA11yValue error messages', () => {
156156
`);
157157
});
158158

159-
test('*ByA11yValue deprecation warnings', () => {
159+
test('*ByA11yValue deprecation warnings', async () => {
160160
const mockCalls = (console.warn as ConsoleLogMock).mock.calls;
161161
const view = render(<View accessibilityValue={{ min: 10 }} />);
162162

@@ -188,22 +188,22 @@ test('*ByA11yValue deprecation warnings', () => {
188188
Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or queryAllByRole(role, { value: ... }) query instead."
189189
`);
190190

191-
view.findByA11yValue({ min: 10 });
191+
await view.findByA11yValue({ min: 10 });
192192
expect(mockCalls[4][0]).toMatchInlineSnapshot(`
193193
"findByA11yValue(...) is deprecated and will be removed in the future.
194194
195195
Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or findByRole(role, { value: ... }) query instead."
196196
`);
197197

198-
view.findAllByA11yValue({ min: 10 });
198+
await view.findAllByA11yValue({ min: 10 });
199199
expect(mockCalls[5][0]).toMatchInlineSnapshot(`
200200
"findAllByA11yValue(...) is deprecated and will be removed in the future.
201201
202202
Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or findAllByRole(role, { value: ... }) query instead."
203203
`);
204204
});
205205

206-
test('*ByAccessibilityValue deprecation warnings', () => {
206+
test('*ByAccessibilityValue deprecation warnings', async () => {
207207
const mockCalls = (console.warn as ConsoleLogMock).mock.calls;
208208
const view = render(<View accessibilityValue={{ min: 10 }} />);
209209

@@ -235,14 +235,14 @@ test('*ByAccessibilityValue deprecation warnings', () => {
235235
Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or queryAllByRole(role, { value: ... }) query instead."
236236
`);
237237

238-
view.findByAccessibilityValue({ min: 10 });
238+
await view.findByAccessibilityValue({ min: 10 });
239239
expect(mockCalls[4][0]).toMatchInlineSnapshot(`
240240
"findByAccessibilityValue(...) is deprecated and will be removed in the future.
241241
242242
Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or findByRole(role, { value: ... }) query instead."
243243
`);
244244

245-
view.findAllByAccessibilityValue({ min: 10 });
245+
await view.findAllByAccessibilityValue({ min: 10 });
246246
expect(mockCalls[5][0]).toMatchInlineSnapshot(`
247247
"findAllByAccessibilityValue(...) is deprecated and will be removed in the future.
248248

Diff for: src/queries/__tests__/label-text.test.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ test('byLabelText queries support hidden option', () => {
173173
`);
174174
});
175175

176-
test('getByLabelText supports aria-label', async () => {
176+
test('getByLabelText supports aria-label', () => {
177177
const screen = render(
178178
<>
179179
<View testID="view" aria-label="view-label" />
@@ -191,7 +191,7 @@ test('getByLabelText supports aria-label', async () => {
191191
);
192192
});
193193

194-
test('getByLabelText supports accessibilityLabelledBy', async () => {
194+
test('getByLabelText supports accessibilityLabelledBy', () => {
195195
const { getByLabelText, getByTestId } = render(
196196
<>
197197
<Text nativeID="label">Label for input</Text>
@@ -203,7 +203,7 @@ test('getByLabelText supports accessibilityLabelledBy', async () => {
203203
expect(getByLabelText(/input/)).toBe(getByTestId('textInput'));
204204
});
205205

206-
test('getByLabelText supports nested accessibilityLabelledBy', async () => {
206+
test('getByLabelText supports nested accessibilityLabelledBy', () => {
207207
const { getByLabelText, getByTestId } = render(
208208
<>
209209
<View nativeID="label">
@@ -217,7 +217,7 @@ test('getByLabelText supports nested accessibilityLabelledBy', async () => {
217217
expect(getByLabelText(/input/)).toBe(getByTestId('textInput'));
218218
});
219219

220-
test('getByLabelText supports aria-labelledby', async () => {
220+
test('getByLabelText supports aria-labelledby', () => {
221221
const screen = render(
222222
<>
223223
<Text nativeID="label">Text Label</Text>
@@ -233,7 +233,7 @@ test('getByLabelText supports aria-labelledby', async () => {
233233
);
234234
});
235235

236-
test('getByLabelText supports nested aria-labelledby', async () => {
236+
test('getByLabelText supports nested aria-labelledby', () => {
237237
const screen = render(
238238
<>
239239
<View nativeID="label">

Diff for: src/queries/__tests__/make-queries.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Text, TextInput, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
describe('printing element tree', () => {
6-
test('includes element tree on error with less-helpful props stripped', async () => {
6+
test('includes element tree on error with less-helpful props stripped', () => {
77
const { getByText } = render(<Text onPress={() => null}>Some text</Text>);
88

99
expect(() => getByText(/foo/)).toThrowErrorMatchingInlineSnapshot(`
@@ -15,7 +15,7 @@ describe('printing element tree', () => {
1515
`);
1616
});
1717

18-
test('prints helpful props but not others', async () => {
18+
test('prints helpful props but not others', () => {
1919
const { getByText } = render(
2020
<View
2121
key="this is filtered"

Diff for: src/render-act.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export function renderWithAct(
1010
): ReactTestRenderer {
1111
let renderer: ReactTestRenderer;
1212

13-
TestRenderer.act(() => {
13+
// This will be called synchronously.
14+
void TestRenderer.act(() => {
1415
renderer = TestRenderer.create(component, options);
1516
});
1617

Diff for: src/render.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function buildRenderResult(
103103
const instance = renderer.root;
104104

105105
const unmount = () => {
106-
act(() => {
106+
void act(() => {
107107
renderer.unmount();
108108
});
109109
};
@@ -144,7 +144,7 @@ function updateWithAct(
144144
wrap: (innerElement: React.ReactElement) => React.ReactElement
145145
) {
146146
return function (component: React.ReactElement) {
147-
act(() => {
147+
void act(() => {
148148
renderer.update(wrap(component));
149149
});
150150
};

Diff for: src/user-event/__tests__/clear.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('clear()', () => {
114114
});
115115

116116
const user = userEvent.setup();
117-
user.clear(textInput);
117+
await user.clear(textInput);
118118

119119
expect(textInput.props.value).toBe('Hello!');
120120
});
@@ -126,7 +126,7 @@ describe('clear()', () => {
126126
});
127127

128128
const user = userEvent.setup();
129-
user.clear(textInput);
129+
await user.clear(textInput);
130130

131131
expect(textInput.props.value).toBe('Hello!');
132132
});

Diff for: src/user-event/setup/setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function createInstance(config: UserEventConfig): UserEventInstance {
165165
*/
166166
function wrapAndBindImpl<
167167
Args extends any[],
168-
Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>
168+
Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,
169169
>(instance: UserEventInstance, impl: Impl) {
170170
function method(...args: Args) {
171171
return wrapAsync(() =>

Diff for: src/user-event/utils/dispatch-event.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export function dispatchEvent(
1818
return;
1919
}
2020

21-
act(() => {
21+
// This will be called synchronously.
22+
void act(() => {
2223
handler(event);
2324
});
2425
}

Diff for: src/wait-for-element-to-be-removed.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default async function waitForElementToBeRemoved<T>(
2525
);
2626
}
2727

28-
return waitFor(() => {
28+
return await waitFor(() => {
2929
let result;
3030
try {
3131
result = expectation();

Diff for: src/wait-for.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function waitForInternal<T>(
190190
});
191191
}
192192

193-
export default async function waitFor<T>(
193+
export default function waitFor<T>(
194194
expectation: () => T,
195195
options?: WaitForOptions
196196
): Promise<T> {

0 commit comments

Comments
 (0)