Skip to content

Commit

Permalink
Dependabot/npm and yarn/callstack/eslint config 14.0.0 (#1526)
Browse files Browse the repository at this point in the history
* 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] <support@github.com>

* 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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
mdjastrzebski and dependabot[bot] committed Nov 13, 2023
1 parent 4549e7b commit aad0849
Show file tree
Hide file tree
Showing 22 changed files with 498 additions and 158 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@babel/preset-flow": "^7.22.15",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.22.15",
"@callstack/eslint-config": "^13.0.1",
"@callstack/eslint-config": "^14.1.0",
"@relmify/jest-serializer-strip-ansi": "^1.0.2",
"@types/jest": "^29.5.5",
"@types/react": "^18.2.21",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/act.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test('fireEvent should trigger useState', () => {
expect(counter.props.children).toEqual('Total count: 1');
});

test('should be able to not await act', async () => {
test('should be able to not await act', () => {
const result = act(() => {});
expect(result).toHaveProperty('then');
});
Expand All @@ -52,5 +52,5 @@ test('should be able to await act', async () => {
});

test('should be able to await act when promise rejects', async () => {
await expect(act(async () => Promise.reject('error'))).rejects.toBe('error');
await expect(act(() => Promise.reject('error'))).rejects.toBe('error');
});
2 changes: 1 addition & 1 deletion src/__tests__/render-hook.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test('allows rerendering', () => {
expect(result.current).toEqual(['right', expect.any(Function)]);
});

test('allows wrapper components', async () => {
test('allows wrapper components', () => {
const Context = React.createContext('default');
function Wrapper({ children }: { children: ReactNode }) {
return <Context.Provider value="provided">{children}</Context.Provider>;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/timer-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setTimeout } from '../helpers/timers';

async function sleep(ms: number): Promise<void> {
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/wait-for-element-to-be-removed.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render, fireEvent, waitForElementToBeRemoved } from '..';
const TestSetup = ({ shouldUseDelay = true }) => {
const [isAdded, setIsAdded] = useState(true);

const removeElement = async () => {
const removeElement = () => {
if (shouldUseDelay) {
setTimeout(() => setIsAdded(false), 300);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/wait-for.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ test.each([

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

Expand Down
3 changes: 2 additions & 1 deletion src/fire-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function findEventHandler(
if (handler && isEventEnabled(element, eventName, touchResponder))
return handler;

// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
if (element.parent === null || element.parent.parent === null) {
return null;
}
Expand Down Expand Up @@ -141,7 +142,7 @@ function fireEvent(
}

let returnValue;
act(() => {
void act(() => {
returnValue = handler(...data);
});

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/__tests__/timers.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jestFakeTimersAreEnabled } from '../timers';
describe('timers', () => {
it('should not mock timers if RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS is set', async () => {
it('should not mock timers if RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS is set', () => {
process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS = 'true';
jest.useFakeTimers();
expect(jestFakeTimersAreEnabled()).toEqual(false);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cleanup } from './pure';
import { flushMicroTasksLegacy } from './flush-micro-tasks';
import { getIsReactActEnvironment, setReactActEnvironment } from './act';

if (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {
if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
// If we're running in a test runner that supports afterEach
// then we'll automatically run cleanup afterEach test
// this ensures that tests run in isolation from each other
Expand Down
8 changes: 4 additions & 4 deletions src/matchers/__tests__/to-have-accessible-name.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('toHaveAccessibleName() handles view with "aria-label" prop', () => {
expect(element).not.toHaveAccessibleName('Other label');
});

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

test('toHaveAccessibleName() handles nested "accessibilityLabelledBy"', async () => {
test('toHaveAccessibleName() handles nested "accessibilityLabelledBy"', () => {
render(
<>
<View nativeID="label">
Expand All @@ -45,7 +45,7 @@ test('toHaveAccessibleName() handles nested "accessibilityLabelledBy"', async ()
expect(element).not.toHaveAccessibleName('Other label');
});

test('toHaveAccessibleName() handles view with nested "accessibilityLabelledBy" with no text', async () => {
test('toHaveAccessibleName() handles view with nested "accessibilityLabelledBy" with no text', () => {
render(
<>
<View nativeID="label">
Expand All @@ -59,7 +59,7 @@ test('toHaveAccessibleName() handles view with nested "accessibilityLabelledBy"
expect(element).not.toHaveAccessibleName();
});

test('toHaveAccessibleName() handles view with "aria-labelledby" prop', async () => {
test('toHaveAccessibleName() handles view with "aria-labelledby" prop', () => {
render(
<View>
<Text nativeID="label">External label</Text>
Expand Down
12 changes: 6 additions & 6 deletions src/queries/__tests__/accessibility-state.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ test('byA11yState queries support hidden option', () => {
`);
});

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

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

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

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

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

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

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

view.findAllByAccessibilityState({ disabled: true });
await view.findAllByAccessibilityState({ disabled: true });
expect(mockCalls[5][0]).toMatchInlineSnapshot(`
"findAllByAccessibilityState(...) is deprecated and will be removed in the future.
Expand Down
12 changes: 6 additions & 6 deletions src/queries/__tests__/accessibility-value.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ test('byA11yValue error messages', () => {
`);
});

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

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

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

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

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

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

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

view.findAllByAccessibilityValue({ min: 10 });
await view.findAllByAccessibilityValue({ min: 10 });
expect(mockCalls[5][0]).toMatchInlineSnapshot(`
"findAllByAccessibilityValue(...) is deprecated and will be removed in the future.
Expand Down
10 changes: 5 additions & 5 deletions src/queries/__tests__/label-text.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ test('byLabelText queries support hidden option', () => {
`);
});

test('getByLabelText supports aria-label', async () => {
test('getByLabelText supports aria-label', () => {
const screen = render(
<>
<View testID="view" aria-label="view-label" />
Expand All @@ -191,7 +191,7 @@ test('getByLabelText supports aria-label', async () => {
);
});

test('getByLabelText supports accessibilityLabelledBy', async () => {
test('getByLabelText supports accessibilityLabelledBy', () => {
const { getByLabelText, getByTestId } = render(
<>
<Text nativeID="label">Label for input</Text>
Expand All @@ -203,7 +203,7 @@ test('getByLabelText supports accessibilityLabelledBy', async () => {
expect(getByLabelText(/input/)).toBe(getByTestId('textInput'));
});

test('getByLabelText supports nested accessibilityLabelledBy', async () => {
test('getByLabelText supports nested accessibilityLabelledBy', () => {
const { getByLabelText, getByTestId } = render(
<>
<View nativeID="label">
Expand All @@ -217,7 +217,7 @@ test('getByLabelText supports nested accessibilityLabelledBy', async () => {
expect(getByLabelText(/input/)).toBe(getByTestId('textInput'));
});

test('getByLabelText supports aria-labelledby', async () => {
test('getByLabelText supports aria-labelledby', () => {
const screen = render(
<>
<Text nativeID="label">Text Label</Text>
Expand All @@ -233,7 +233,7 @@ test('getByLabelText supports aria-labelledby', async () => {
);
});

test('getByLabelText supports nested aria-labelledby', async () => {
test('getByLabelText supports nested aria-labelledby', () => {
const screen = render(
<>
<View nativeID="label">
Expand Down
4 changes: 2 additions & 2 deletions src/queries/__tests__/make-queries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Text, TextInput, View } from 'react-native';
import { render, screen } from '../..';

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

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

test('prints helpful props but not others', async () => {
test('prints helpful props but not others', () => {
const { getByText } = render(
<View
key="this is filtered"
Expand Down
3 changes: 2 additions & 1 deletion src/render-act.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function renderWithAct(
): ReactTestRenderer {
let renderer: ReactTestRenderer;

TestRenderer.act(() => {
// This will be called synchronously.
void TestRenderer.act(() => {
renderer = TestRenderer.create(component, options);
});

Expand Down
4 changes: 2 additions & 2 deletions src/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function buildRenderResult(
const instance = renderer.root;

const unmount = () => {
act(() => {
void act(() => {
renderer.unmount();
});
};
Expand Down Expand Up @@ -144,7 +144,7 @@ function updateWithAct(
wrap: (innerElement: React.ReactElement) => React.ReactElement
) {
return function (component: React.ReactElement) {
act(() => {
void act(() => {
renderer.update(wrap(component));
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/user-event/__tests__/clear.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('clear()', () => {
});

const user = userEvent.setup();
user.clear(textInput);
await user.clear(textInput);

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

const user = userEvent.setup();
user.clear(textInput);
await user.clear(textInput);

expect(textInput.props.value).toBe('Hello!');
});
Expand Down
2 changes: 1 addition & 1 deletion src/user-event/setup/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function createInstance(config: UserEventConfig): UserEventInstance {
*/
function wrapAndBindImpl<
Args extends any[],
Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>
Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,
>(instance: UserEventInstance, impl: Impl) {
function method(...args: Args) {
return wrapAsync(() =>
Expand Down
3 changes: 2 additions & 1 deletion src/user-event/utils/dispatch-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export function dispatchEvent(
return;
}

act(() => {
// This will be called synchronously.
void act(() => {
handler(event);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/wait-for-element-to-be-removed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default async function waitForElementToBeRemoved<T>(
);
}

return waitFor(() => {
return await waitFor(() => {
let result;
try {
result = expectation();
Expand Down
2 changes: 1 addition & 1 deletion src/wait-for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function waitForInternal<T>(
});
}

export default async function waitFor<T>(
export default function waitFor<T>(
expectation: () => T,
options?: WaitForOptions
): Promise<T> {
Expand Down

0 comments on commit aad0849

Please sign in to comment.