Skip to content

Commit f5637e2

Browse files
authored
FE-458: Update to eslint-config 2.12.0 (#1774)
* chore(deps): update to eslint-config 2.12.0 * chore(deps): fix various lint violations * chore(deps): fix various test issues * chore(deps): fix remaining test issues * chore(deps): fix typecheck issues * chore(deps): tighten lint rules and fix violations
1 parent 9e3934d commit f5637e2

File tree

95 files changed

+1948
-1316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1948
-1316
lines changed

packages/big-design-icons/src/types/styled.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { ThemeInterface } from '@bigcommerce/big-design-theme';
22
import 'styled-components';
33

44
declare module 'styled-components' {
5-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
5+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
66
export interface DefaultTheme extends ThemeInterface {}
77
}

packages/big-design-patterns/src/components/Page/spec.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ test('renders with background', () => {
4848
};
4949

5050
const { container } = render(<Page background={backgroundProps}>Page content</Page>);
51+
// eslint-disable-next-line testing-library/no-node-access
5152
const firstChild = container.firstElementChild;
5253

5354
if (!firstChild) {
@@ -68,6 +69,7 @@ test('renders with default background styles', () => {
6869
};
6970

7071
const { container } = render(<Page background={backgroundProps}>Page content</Page>);
72+
// eslint-disable-next-line testing-library/no-node-access
7173
const firstChild = container.firstElementChild;
7274

7375
if (!firstChild) {
@@ -86,6 +88,7 @@ test('renders without background by default', () => {
8688
render(<Page>Page content</Page>);
8789

8890
const { container } = render(<Page>Page content</Page>);
91+
// eslint-disable-next-line testing-library/no-node-access
8992
const firstChild = container.firstElementChild;
9093

9194
if (!firstChild) {

packages/big-design-patterns/src/utils/warning/spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('warning', () => {
3636
isProduction: true,
3737
}));
3838

39-
// eslint-disable-next-line @typescript-eslint/no-var-requires
39+
// eslint-disable-next-line @typescript-eslint/no-require-imports
4040
const { warning: prodWarning } = require('./warning');
4141
const mockWarn = jest.fn();
4242

packages/big-design-patterns/src/utils/warning/warning.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export const warning = (message: string): void => {
2727
try {
2828
throw Error(text);
2929
// eslint-disable-next-line no-empty
30-
} catch (x) {}
30+
} catch {}
3131
}
3232
};

packages/big-design-theme/src/styled/styled.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import 'styled-components';
33
import { ThemeInterface } from '..';
44

55
declare module 'styled-components' {
6-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
6+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
77
export interface DefaultTheme extends ThemeInterface {}
88
}

packages/big-design/.eslintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,23 @@
22
module.exports = {
33
root: true,
44
extends: [require.resolve('@bigcommerce/configs/eslint/base.js')],
5+
rules: {
6+
// Disable testing-library rules that conflict with styled-components testing
7+
// The big-design library extensively tests styled-components which requires
8+
// direct DOM access to verify styles, making these rules impractical to follow
9+
'testing-library/no-node-access': 'off',
10+
'testing-library/no-container': 'off',
11+
'testing-library/prefer-screen-queries': 'off',
12+
// Disable specific rules that are too strict for this codebase
13+
'@typescript-eslint/no-unsafe-member-access': 'off',
14+
},
15+
overrides: [
16+
{
17+
files: ['**/*.spec.tsx', '**/*.spec.ts', '**/*.test.tsx', '**/*.test.ts'],
18+
rules: {
19+
// Allow unused variables in test files (often kept for debugging)
20+
'@typescript-eslint/no-unused-vars': 'off',
21+
},
22+
},
23+
],
524
};

packages/big-design/src/components/Alert/spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test('renders header', () => {
8383
const heading = screen.getByRole('heading', { name: /header/i });
8484

8585
expect(alert).toMatchSnapshot();
86-
expect(heading).toBeDefined();
86+
expect(heading).toBeInTheDocument();
8787
});
8888

8989
test('uses the header as an accessibility label for the alert', () => {
@@ -99,7 +99,7 @@ test('renders close button', () => {
9999
const button = screen.getByRole('button');
100100

101101
expect(alert).toMatchSnapshot();
102-
expect(button).toBeDefined();
102+
expect(button).toBeInTheDocument();
103103
});
104104

105105
test('trigger onClose', async () => {

packages/big-design/src/components/AnchorNav/spec.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
1+
import { fireEvent, render, screen } from '@testing-library/react';
22
import React from 'react';
33
import { act } from 'react-dom/test-utils';
44
import { useInView } from 'react-intersection-observer';
@@ -26,7 +26,6 @@ describe('AnchorNav Component', () => {
2626
});
2727

2828
afterEach(() => {
29-
cleanup();
3029
history.replaceState(null, '', '#');
3130
jest.clearAllMocks();
3231
jest.useRealTimers();
@@ -62,7 +61,7 @@ describe('AnchorNav Component', () => {
6261
expect(section1El?.scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth' });
6362
expect(replaceStateSpy).toHaveBeenCalledWith(null, '', '#section1');
6463
expect(navLink1).toHaveClass('active');
65-
expect(navLink1.getAttribute('aria-current')).toBe('true');
64+
expect(navLink1).toHaveAttribute('aria-current', 'true');
6665
});
6766

6867
it('activates a section based on the observer inView value', () => {
@@ -80,7 +79,7 @@ describe('AnchorNav Component', () => {
8079
const navLink2 = screen.getByText('Section 2');
8180

8281
expect(navLink2).toHaveClass('active');
83-
expect(navLink2.getAttribute('aria-current')).toBe('true');
82+
expect(navLink2).toHaveAttribute('aria-current', 'true');
8483
});
8584

8685
it('scrolls to the section corresponding to the initial URL hash on load', () => {

packages/big-design/src/components/Badge/spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ test("doesn't render if label prop is invalid", () => {
6161
// @ts-expect-error ignoring since label={Component} is not a valid prop
6262
const { container } = render(<Badge label={<p>Label</p>} />);
6363

64-
expect(container.firstChild).toBeNull();
64+
expect(container).toBeEmptyDOMElement();
6565
});

packages/big-design/src/components/Box/Box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface BoxProps
1010
DisplayProps,
1111
MarginProps,
1212
PaddingProps {
13-
as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
13+
as?: keyof React.JSX.IntrinsicElements | React.ComponentType<any>;
1414
backgroundColor?: keyof Colors;
1515
shadow?: keyof Shadow;
1616
border?: keyof Border;

0 commit comments

Comments
 (0)