Skip to content

Commit 15d6209

Browse files
chore: Bump Eslint to v9 (#256)
1 parent f2b4f2a commit 15d6209

File tree

82 files changed

+647
-552
lines changed

Some content is hidden

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

82 files changed

+647
-552
lines changed

.eslintrc.js

-84
This file was deleted.

.storybook/main.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ const config: StorybookConfig = {
4747
webpackFinal: (webpackConfig) => {
4848
// Remove any svg loader already set and use @svgr/webpack to load svgs on Storybook
4949
const svgWebpackRule = webpackConfig.module?.rules?.find((rule) => {
50-
if (rule != null && typeof rule !== 'string' && (rule as RuleSetRule)?.test instanceof RegExp) {
51-
return (rule as Record<string, any>).test?.test('.svg');
50+
if (rule != null && typeof rule !== 'string' && (rule as RuleSetRule).test instanceof RegExp) {
51+
const testRegExp = (rule as RuleSetRule).test as RegExp;
52+
return testRegExp.test('.svg');
5253
}
54+
55+
return undefined;
5356
});
5457

5558
if (typeof svgWebpackRule !== 'string') {

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010
### Changed
1111

1212
- Update minor and patch NPM dependencies
13+
- Update `eslint` to v9
1314

1415
## [1.0.54] - 2024-11-11
1516

eslint.config.js

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
const globals = require('globals');
2+
3+
const eslint = require('@eslint/js');
4+
const tsEslint = require('typescript-eslint');
5+
6+
const importPlugin = require('eslint-plugin-import');
7+
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y');
8+
const reactPlugin = require('eslint-plugin-react');
9+
const reactHooksPlugin = require('eslint-plugin-react-hooks');
10+
const storybookPlugin = require('eslint-plugin-storybook');
11+
const tailwindPlugin = require('eslint-plugin-tailwindcss');
12+
const testingLibraryPlugin = require('eslint-plugin-testing-library');
13+
14+
const tsConfig = require('./tsconfig.json');
15+
16+
const config = tsEslint.config(
17+
// Default rules
18+
eslint.configs.recommended,
19+
importPlugin.flatConfigs.recommended,
20+
importPlugin.flatConfigs.typescript,
21+
jsxA11yPlugin.flatConfigs.recommended,
22+
reactPlugin.configs.flat.recommended,
23+
reactPlugin.configs.flat['jsx-runtime'],
24+
...storybookPlugin.configs['flat/recommended'],
25+
...tailwindPlugin.configs['flat/recommended'],
26+
...tsEslint.configs.recommendedTypeChecked,
27+
...tsEslint.configs.strictTypeChecked,
28+
...tsEslint.configs.stylisticTypeChecked,
29+
{
30+
languageOptions: {
31+
globals: {
32+
...globals.node,
33+
},
34+
parserOptions: {
35+
projectService: true,
36+
tsconfigRootDir: __dirname,
37+
ecmaFeatures: {
38+
jsx: true,
39+
},
40+
},
41+
},
42+
settings: {
43+
react: {
44+
version: 'detect',
45+
},
46+
'import/resolver': {
47+
typescript: true,
48+
node: true,
49+
},
50+
tailwindcss: {
51+
callees: ['classnames', 'classNames'],
52+
},
53+
},
54+
plugins: {
55+
'react-hooks': reactHooksPlugin,
56+
},
57+
},
58+
{
59+
ignores: tsConfig.exclude,
60+
},
61+
{
62+
rules: {
63+
'no-console': 'warn',
64+
curly: 'warn',
65+
'prefer-template': 'warn',
66+
'no-useless-concat': 'warn',
67+
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'always' }],
68+
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
69+
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
70+
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
71+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
72+
'@typescript-eslint/no-non-null-assertion': 'off',
73+
'import/no-cycle': 'warn',
74+
'react/prop-types': 'off',
75+
'react/jsx-boolean-value': ['warn', 'always'],
76+
'react/self-closing-comp': 'warn',
77+
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
78+
...reactHooksPlugin.configs.recommended.rules,
79+
},
80+
},
81+
// Rules for JavaScript files
82+
{
83+
files: ['**/*.js'],
84+
...tsEslint.configs.disableTypeChecked,
85+
rules: {
86+
...tsEslint.configs.disableTypeChecked.rules,
87+
'@typescript-eslint/no-require-imports': 'off',
88+
},
89+
},
90+
// Rules for test files
91+
{
92+
files: ['**/*.test.ts', '**/*.test.tsx'],
93+
...testingLibraryPlugin.configs['flat/react'],
94+
rules: {
95+
...testingLibraryPlugin.configs['flat/react'].rules,
96+
'@typescript-eslint/unbound-method': 'off',
97+
},
98+
},
99+
// Rules for Storybook files
100+
{
101+
files: ['**/*.stories.tsx'],
102+
rules: {
103+
'react-hooks/rules-of-hooks': 'off',
104+
},
105+
},
106+
);
107+
108+
module.exports = config;

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@
113113
"@types/luxon": "^3.4.2",
114114
"@types/react-dom": "^18.3.1",
115115
"@types/sanitize-html": "^2.13.0",
116-
"@typescript-eslint/eslint-plugin": "^8.14.0",
117-
"@typescript-eslint/parser": "^8.14.0",
118116
"autoprefixer": "^10.4.20",
119117
"cross-env": "^7.0.3",
120-
"eslint": "^8.57.0",
118+
"eslint": "^9.14.0",
119+
"eslint-import-resolver-typescript": "^3.6.3",
121120
"eslint-plugin-import": "^2.31.0",
122121
"eslint-plugin-jsx-a11y": "^6.10.2",
123122
"eslint-plugin-react": "^7.37.2",
@@ -144,6 +143,7 @@
144143
"tailwindcss": "^3.4.14",
145144
"ts-jest": "^29.2.5",
146145
"typescript": "^5.6.3",
146+
"typescript-eslint": "^8.13.0",
147147
"viem": "^2.21.44",
148148
"wagmi": "^2.12.29"
149149
},

src/core/assets/copy/coreCopy.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const coreCopy = {
1919
},
2020
dataListPagination: {
2121
more: 'More',
22-
outOf: ({ total, entityLabel }: { total: number; entityLabel: string }) => `of ${total} ${entityLabel}`,
22+
outOf: ({ total, entityLabel }: { total: number; entityLabel: string }) =>
23+
`of ${total.toString()} ${entityLabel}`,
2324
},
2425
inputNumberMax: {
2526
max: 'Max',

src/core/components/accordion/accordionContainer/accordionContainer.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const meta: Meta<typeof Accordion.Container> = {
1515
type Story = StoryObj<typeof Accordion.Container>;
1616

1717
const DefaultChildComponent = (childCount: number, forceMount?: true) =>
18-
[...Array(childCount)].map((_, index) => (
19-
<Accordion.Item key={`item-${index}`} value={`item-${index}`}>
18+
[...Array<number>(childCount)].map((_, index) => (
19+
<Accordion.Item key={`item-${index.toString()}`} value={`item-${index.toString()}`}>
2020
<Accordion.ItemHeader>Item {index + 1} Header</Accordion.ItemHeader>
2121
<Accordion.ItemContent forceMount={forceMount}>
2222
<div className="flex h-24 w-full items-center justify-center border border-dashed border-info-300 bg-info-100">

src/core/components/accordion/accordionContainer/accordionContainer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const AccordionContainer = forwardRef<HTMLDivElement, IAccordionContainer
3333

3434
const accordionContainerClasses = classNames('grow bg-neutral-0', className);
3535

36-
if (isMulti === true) {
36+
if (isMulti) {
3737
return (
3838
<RadixAccordionRoot
3939
className={accordionContainerClasses}

src/core/components/avatars/avatar/avatar.test.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ describe('<Avatar /> component', () => {
1515

1616
beforeAll(() => {
1717
(window.Image as unknown) = class MockImage {
18-
onload: () => void = () => {};
19-
src: string = '';
18+
onload = jest.fn();
19+
src = '';
2020
constructor() {
2121
setTimeout(() => {
2222
this.onload();
@@ -39,14 +39,14 @@ describe('<Avatar /> component', () => {
3939
expect(screen.queryByRole('img')).not.toBeInTheDocument();
4040
});
4141

42-
it('does not render fallback when valid image provided', async () => {
42+
it('does not render fallback when valid image provided', () => {
4343
const fallbackContent = 'fallback content';
4444
render(createTestComponent({ fallback: fallbackContent, src: 'img.jpg' }));
4545

4646
expect(screen.queryByText(fallbackContent)).not.toBeInTheDocument();
4747
});
4848

49-
it('renders loading animation while image is loading', async () => {
49+
it('renders loading animation while image is loading', () => {
5050
render(createTestComponent({ src: 'img.jpg' }));
5151

5252
const fallback = screen.getByTestId('fallback');

src/core/components/button/button.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const OnlyIcon: Story = {
4242
export const Link: Story = {
4343
args: {
4444
children: 'Link label',
45-
onClick: () => alert('click'),
4645
href: 'https://www.google.com',
4746
target: '_blank',
4847
},

src/core/components/button/button.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, IButtonP
238238
});
239239

240240
const iconSize = sizeToIconSize[size][buttonContext];
241-
const iconResponsiveSize = Object.keys(responsiveSize ?? {}).reduce<ResponsiveAttribute<IconSize>>(
241+
const iconResponsiveSize = Object.keys(responsiveSize).reduce<ResponsiveAttribute<IconSize>>(
242242
(current, breakpoint) => ({
243243
...current,
244244
[breakpoint]: sizeToIconSize[responsiveSize[breakpoint as Breakpoint]!][buttonContext],
@@ -247,7 +247,7 @@ export const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, IButtonP
247247
);
248248

249249
const spinnerSize = sizeToSpinnerSize[size];
250-
const spinnerResponsiveSize = Object.keys(responsiveSize ?? {}).reduce<ResponsiveAttribute<SpinnerSize>>(
250+
const spinnerResponsiveSize = Object.keys(responsiveSize).reduce<ResponsiveAttribute<SpinnerSize>>(
251251
(current, breakpoint) => ({
252252
...current,
253253
[breakpoint]: sizeToSpinnerSize[responsiveSize[breakpoint as Breakpoint]!],

src/core/components/cards/cardCollapsible/cardCollapsible.test.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { render, screen } from '@testing-library/react';
22
import { CardCollapsible, type ICardCollapsibleProps } from './cardCollapsible';
33

4-
global.ResizeObserver = class {
5-
observe() {}
6-
unobserve() {}
7-
disconnect() {}
8-
};
9-
104
describe('<CardCollapsible /> component', () => {
115
const createTestComponent = (props?: Partial<ICardCollapsibleProps>) => {
126
const completeProps = { ...props };

src/core/components/cards/cardSummary/cardSummary.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const Default: Story = {
2222
args: {
2323
value: '5',
2424
description: 'Proposals created',
25-
action: { label: 'Proposal', onClick: () => alert('Click') },
25+
action: { label: 'Proposal' },
2626
icon: IconType.APP_PROPOSALS,
2727
},
2828
};
@@ -34,7 +34,7 @@ export const HorizontalLayout: Story = {
3434
args: {
3535
value: '22',
3636
description: 'Members',
37-
action: { label: 'Delegate', onClick: () => alert('Click') },
37+
action: { label: 'Delegate' },
3838
icon: IconType.APP_MEMBERS,
3939
isStacked: false,
4040
},

src/core/components/collapsible/collapsible.test.tsx

-15
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,6 @@ describe('<Collapsible /> component', () => {
1010
return <Collapsible {...completeProps} />;
1111
};
1212

13-
let originalResizeObserver: typeof global.ResizeObserver;
14-
15-
beforeAll(() => {
16-
originalResizeObserver = global.ResizeObserver;
17-
global.ResizeObserver = class {
18-
observe() {}
19-
unobserve() {}
20-
disconnect() {}
21-
};
22-
});
23-
24-
afterAll(() => {
25-
global.ResizeObserver = originalResizeObserver;
26-
});
27-
2813
beforeEach(() => {
2914
jest.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockReturnValue(500);
3015
});

0 commit comments

Comments
 (0)