Skip to content

Commit 83b6ced

Browse files
committed
chore: fix all lint issues with new versions and update rules
1 parent 45e7abc commit 83b6ced

File tree

172 files changed

+1485
-866
lines changed

Some content is hidden

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

172 files changed

+1485
-866
lines changed

package/.eslintrc.json

Lines changed: 0 additions & 146 deletions
This file was deleted.

package/eslint.config.mjs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import tsEslint from 'typescript-eslint';
1818
* the new config. All globals which were previously set to true are now readonly.
1919
*/
2020
const reactNativeGlobals = Object.keys(eslintReactNativeConfig.globals).reduce((acc, key) => {
21-
if (eslintReactNativeConfig.globals[key]) {
22-
acc[key] = 'readonly';
23-
}
21+
acc[key] = 'readonly';
2422
return acc;
2523
}, {});
2624

@@ -51,13 +49,11 @@ export default tsEslint.config(
5149
],
5250
},
5351
{
52+
name: 'default',
5453
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
5554
languageOptions: {
5655
ecmaVersion: 2020,
57-
globals: {
58-
...reactNativeGlobals,
59-
console: 'readonly',
60-
},
56+
globals: reactNativeGlobals,
6157
parser: tsEslint.parser,
6258
parserOptions: {
6359
ecmaFeatures: {
@@ -79,7 +75,6 @@ export default tsEslint.config(
7975
},
8076
settings: {
8177
'import/resolver': {
82-
// 'babel-module': {},
8378
node: {
8479
extensions: ['.js', '.jsx', '.ts', '.tsx'],
8580
paths: ['src'],
@@ -163,7 +158,9 @@ export default tsEslint.config(
163158
'warn',
164159
{ ignoreRestSiblings: false, caughtErrors: 'none' },
165160
],
161+
'@typescript-eslint/no-unused-expressions': 'off',
166162
'@typescript-eslint/no-var-requires': 0,
163+
'@typescript-eslint/no-require-imports': 'off',
167164
'react-hooks/exhaustive-deps': 1,
168165
'react-native/no-inline-styles': 0,
169166
'babel/no-invalid-this': 0,
@@ -173,20 +170,24 @@ export default tsEslint.config(
173170
},
174171
{
175172
name: 'jest',
176-
files: ['src/**/__tests__/**'],
173+
files: ['src/**/__tests__/**', '**/*.test.*', 'src/mock-builders/**'],
177174
plugins: { jest: eslintPluginJest },
178175
languageOptions: {
179-
globals: eslintPluginJest.environments.globals.globals,
176+
globals: {
177+
...eslintPluginJest.environments.globals.globals,
178+
jest: 'readonly',
179+
},
180180
},
181181
rules: {
182+
'react-hooks/rules-of-hooks': 'off',
182183
'jest/expect-expect': 'off',
183184
'jest/no-conditional-expect': 'off',
184185
'jest/prefer-inline-snapshots': 'off',
185186
'jest/lowercase-name': 'off',
186187
'jest/prefer-expect-assertions': 'off',
187188
'jest/no-hooks': 'off',
188189
'jest/no-if': 'off',
189-
'jest/prefer-spy-on': 'warn',
190+
'jest/prefer-spy-on': 'off',
190191
},
191192
},
192193
);

package/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"build-translations": "i18next",
2727
"copy-translations": "echo '\u001b[34mℹ\u001b[0m Copying translation files to \u001b[34mlib/typescript/i18n\u001b[0m' && cp -R -f ./src/i18n ./lib/typescript/i18n && echo '\u001b[32m✓\u001b[0m Done Copying Translations'",
2828
"eslint": "eslint 'src/**/*.{js,md,ts,jsx,tsx}' --max-warnings 0",
29-
"lint": "prettier --ignore-path ../.prettierignore --list-different 'src/**/*.{js,ts,tsx,md,json}' .eslintrc.json ../.prettierrc babel.config.js && eslint 'src/**/*.{js,ts,tsx,md}' --max-warnings 0 && yarn run validate-translations",
30-
"lint-fix": "prettier --ignore-path ../.prettierignore --write 'src/**/*.{js,ts,tsx,md,json}' .eslintrc.json ../.prettierrc babel.config.js && eslint --fix 'src/**/*.{js,ts,tsx,md}' --max-warnings 0",
29+
"lint": "prettier --ignore-path ../.prettierignore --list-different 'src/**/*.{js,ts,tsx,md,json}' eslint.config.mjs ../.prettierrc babel.config.js && eslint 'src/**/*.{js,ts,tsx,md}' --max-warnings 0 && yarn run validate-translations",
30+
"lint-fix": "prettier --ignore-path ../.prettierignore --write 'src/**/*.{js,ts,tsx,md,json}' eslint.config.mjs ../.prettierrc babel.config.js && eslint --fix 'src/**/*.{js,ts,tsx,md}' --max-warnings 0",
3131
"prepare": "yarn run build",
3232
"prepare-distribution": "cd examples/SampleApp && npm version patch && react-native-version && git add ./ && git commit -m 'Bump build version' --no-verify",
33-
"prettier": "prettier --list-different '**/*.{js,ts,tsx,md,json}' .eslintrc.json ../.prettierrc babel.config.js",
34-
"prettier-fix": "prettier --write '**/*.{js,ts,tsx,md,json}' .eslintrc.json ../.prettierrc babel.config.js",
33+
"prettier": "prettier --list-different '**/*.{js,ts,tsx,md,json}' eslint.config.mjs ../.prettierrc babel.config.js",
34+
"prettier-fix": "prettier --write '**/*.{js,ts,tsx,md,json}' eslint.config.mjs ../.prettierrc babel.config.js",
3535
"test:coverage": "yarn test:unit --coverage",
3636
"test:unit": "TZ=UTC jest",
3737
"validate-translations": "node bin/validate-translations.js",

package/src/__tests__/offline-support/offline-feature.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-underscore-dangle */
2-
/* eslint-disable jest/no-export */
2+
33
import React from 'react';
44
import { Text, View } from 'react-native';
55

@@ -53,7 +53,9 @@ const ChannelPreviewComponent = ({ channel, setActiveChannel }) => (
5353

5454
const ChannelListComponent = (props) => {
5555
const { channels, onSelect } = useChannelsContext();
56-
if (!channels) return null;
56+
if (!channels) {
57+
return null;
58+
}
5759

5860
return (
5961
<View testID='channel-list'>
@@ -92,7 +94,7 @@ export const Generic = () => {
9294
it('should NOT create tables on first load if offline feature is disabled', async () => {
9395
render(
9496
<Chat client={chatClient}>
95-
<View testID='test-child'></View>
97+
<View testID='test-child' />
9698
</Chat>,
9799
);
98100
await waitFor(() => expect(screen.getByTestId('test-child')).toBeTruthy());
@@ -294,7 +296,7 @@ export const Generic = () => {
294296
it('should create tables on first load if offline feature is enabled', async () => {
295297
render(
296298
<Chat client={chatClient} enableOfflineSupport>
297-
<View testID='test-child'></View>
299+
<View testID='test-child' />
298300
</Chat>,
299301
);
300302

package/src/__tests__/offline-support/optimistic-update.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable jest/no-export */
2-
/* eslint-disable no-underscore-dangle */
31
import React, { useContext, useEffect, useState } from 'react';
42
import { View } from 'react-native';
53

@@ -137,9 +135,11 @@ export const OptimisticUpdates = () => {
137135
};
138136

139137
call();
140-
}, []);
138+
}, [callback, ctx]);
141139

142-
if (!ready) return null;
140+
if (!ready) {
141+
return null;
142+
}
143143

144144
return children;
145145
};
@@ -364,8 +364,8 @@ export const OptimisticUpdates = () => {
364364
expect(pendingTasksRows.length).toBe(2);
365365
});
366366

367-
chatClient.deleteMessage = jest.fn();
368-
channel.sendReaction = jest.fn();
367+
jest.spyOn(chatClient, 'deleteMessage').mockImplementation();
368+
jest.spyOn(channel, 'sendReaction').mockImplementation();
369369

370370
act(() => dispatchConnectionChangedEvent(chatClient, true));
371371

package/src/components/Attachment/Attachment.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,19 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
123123
prevAttachment.image_url === nextAttachment.image_url &&
124124
prevAttachment.thumb_url === nextAttachment.thumb_url &&
125125
prevAttachment.type === nextAttachment.type;
126-
if (!attachmentEqual) return false;
126+
if (!attachmentEqual) {
127+
return false;
128+
}
127129

128130
if (isAttachmentEqual) {
129131
return isAttachmentEqual(prevAttachment, nextAttachment);
130132
}
131133

132134
const messageThemeEqual =
133135
JSON.stringify(prevMyMessageTheme) === JSON.stringify(nextMyMessageTheme);
134-
if (!messageThemeEqual) return false;
136+
if (!messageThemeEqual) {
137+
return false;
138+
}
135139

136140
return true;
137141
};

package/src/components/Attachment/Card.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
298298

299299
const messageThemeEqual =
300300
JSON.stringify(prevMyMessageTheme) === JSON.stringify(nextMyMessageTheme);
301-
if (!messageThemeEqual) return false;
301+
if (!messageThemeEqual) {
302+
return false;
303+
}
302304

303305
return true;
304306
};

package/src/components/Attachment/FileAttachment.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ export const FileAttachment = <
183183
};
184184

185185
export const getFileSizeDisplayText = (size?: number | string) => {
186-
if (!size) return;
186+
if (!size) {
187+
return;
188+
}
187189
if (typeof size === 'string') {
188190
size = parseFloat(size);
189191
}

package/src/components/Attachment/FileAttachmentGroup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ export const FileAttachmentGroup = <
178178

179179
const files = propFiles || contextFiles;
180180

181-
if (!files.length) return null;
181+
if (!files.length) {
182+
return null;
183+
}
182184

183185
return (
184186
<MemoizedFileAttachmentGroup

package/src/components/Attachment/FileIcon.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,14 @@ for (const type of videoFileTypes) {
417417
}
418418

419419
function mimeTypeToIcon(mimeType?: string): React.ComponentType<IconProps> {
420-
if (!mimeType) return GenericFile;
420+
if (!mimeType) {
421+
return GenericFile;
422+
}
421423

422424
const Icon = mimeTypeToIconMap[mimeType];
423-
if (Icon) return Icon;
425+
if (Icon) {
426+
return Icon;
427+
}
424428

425429
return GenericFile;
426430
}

0 commit comments

Comments
 (0)