Skip to content

Commit

Permalink
Update eslint configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtiomTr committed Aug 25, 2024
1 parent 8a19318 commit aefcf8f
Show file tree
Hide file tree
Showing 27 changed files with 2,658 additions and 641 deletions.
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
},
"devDependencies": {
"@changesets/cli": "^2.26.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.0",
"@types/jest": "^29.2.0",
"clean-publish": "^4.0.1",
"danger": "^11.2.4",
"prettier": "^2.8.4",
"prettier": "^3.3.3",
"syncpack": "^8.2.4",
"turbo": "^2.0.14",
"typescript": "^5.0.4"
Expand Down
2 changes: 0 additions & 2 deletions packages/client/.eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions packages/client/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import config from '@sirse-dev/eslint-config';

export default [
{
ignores: [
'**/node_modules',
'**/dist',
'**/*.config.js',
'**/*.test.js',
'**/*.test.ts',
'**/stories',
'**/test',
'**/prepared-package',
],
},
...config,
];
3 changes: 2 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"scripts": {
"build": "aqu build && rimraf ./prepared-package && clean-publish",
"postpublish": "rimraf ./prepared-package",
"prepublishOnly": "pnpm build"
"prepublishOnly": "pnpm build",
"lint": "eslint **/*.{ts,tsx}"
},
"dependencies": {
"@rchat/shared": "workspace:*"
Expand Down
2 changes: 0 additions & 2 deletions packages/material/.eslintignore

This file was deleted.

22 changes: 22 additions & 0 deletions packages/material/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import config from '@sirse-dev/eslint-config';

export default [
{
ignores: [
'**/node_modules',
'**/dist',
'**/*.config.js',
'**/*.test.js',
'**/*.test.ts',
'**/stories',
'**/test',
'**/prepared-package',
],
},
...config,
{
rules: {
'@typescript-eslint/no-empty-object-type': 'off',
},
},
];
2 changes: 1 addition & 1 deletion packages/material/src/AccountAvatar/AccountAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AccountAvatarRoot = styled<InternalAccountAvatarProps, typeof Avatar>(Avat
const getInitials = (username: string): string | undefined => {
const words = username
.split(/\s+/g)
.map((value) => value.replace(/[^\p{L}]/gu, ''))
.map((value) => value.replaceAll(/[^\p{L}]/gu, ''))
.filter(Boolean);

if (words.length === 0) {
Expand Down
6 changes: 3 additions & 3 deletions packages/material/src/MessageBox/MessageTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ export const MessageTime = createMuiComponent<InternalMessageTimeProps, typeof T
const [formattedTime, updateTimeout] = formatTime(time);

setFormattedTime(formattedTime);
if (updateTimeout !== undefined) {
timeoutId = setTimeout(updateTime, updateTimeout);
} else {
if (updateTimeout === undefined) {
timeoutId = undefined;
} else {
timeoutId = setTimeout(updateTime, updateTimeout);
}
};
updateTime();
Expand Down
1 change: 0 additions & 1 deletion packages/material/src/styles/defaultTheme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
import createTheme from '@mui/material/styles/createTheme';

declare module '@mui/material' {
Expand Down
4 changes: 0 additions & 4 deletions packages/react/.eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions packages/react/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import config from '@sirse-dev/eslint-config';

export default [
{
ignores: [
'**/node_modules',
'**/dist',
'**/*.config.js',
'**/*.test.js',
'**/*.test.ts',
'**/stories',
'**/test',
'**/prepared-package',
],
},
...config,
];
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@babel/core": "^7.18.2",
"@rchat/client": "workspace:^0.11.9",
"@sirse-dev/eslint-config": "^1.0.6",
"@sirse-dev/eslint-config": "^5.0.0",
"@size-limit/preset-small-lib": "^7.0.8",
"@storybook/addon-actions": "^6.5.9",
"@storybook/addon-essentials": "^6.5.9",
Expand All @@ -51,13 +51,13 @@
"@types/react-dom": "^18.0.5",
"aqu": "0.4.3",
"babel-loader": "^8.2.5",
"eslint": "^8.18.0",
"eslint": "^9.9.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.4.3",
"jest-watch-typeahead": "^2.2.0",
"mock-socket": "^9.1.5",
"np": "^7.6.1",
"prettier": "^2.6.2",
"prettier": "^3.3.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/EndlessList/useEndlessList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const useEndlessList = <T,>({
};

const jumpKey = focusedItemKey ?? getKey(items[Math.floor(items.length / 2)]);
const convertedItems = [...items.map(valueToEndlessListItem(getKey, jumpKey))];
const convertedItems = items.map(valueToEndlessListItem(getKey, jumpKey));

let pivotIndex = visibleItems.findIndex((item) => keys.has(item.itemKey));

Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/internal/smoothScrollToCenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export const smoothScrollToCenter = async (
}
};

if (startPos !== scrollEndValue) {
window.requestAnimationFrame(scroll);
} else {
if (startPos === scrollEndValue) {
resolve();
} else {
window.requestAnimationFrame(scroll);
}
});
};
17 changes: 17 additions & 0 deletions packages/server/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import config from '@sirse-dev/eslint-config';

export default [
{
ignores: [
'**/node_modules',
'**/dist',
'**/*.config.js',
'**/*.test.js',
'**/*.test.ts',
'**/stories',
'**/test',
'**/prepared-package',
],
},
...config,
];
3 changes: 2 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"test:watch": "pnpm run test --watch",
"build": "aqu build && rimraf ./prepared-package && clean-publish",
"postpublish": "rimraf ./prepared-package",
"prepublishOnly": "pnpm build"
"prepublishOnly": "pnpm build",
"lint": "eslint **/*.{ts,tsx}"
},
"dependencies": {
"@isaacs/ttlcache": "^1.2.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/server/src/ChatServer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChatService } from './ChatService';
import type { ExtendedError } from 'socket.io/dist/namespace';
import { ChatServerType, ChatSocketType, ConnectionInfo } from '@rchat/shared';
import { ChatService } from './ChatService';
import { RoomManager } from './RoomManager';
import type { ExtendedError } from 'socket.io/dist/namespace';

export class ChatServer<TMessageType> {
protected readonly roomManager;
Expand Down Expand Up @@ -46,15 +46,15 @@ export class ChatServer<TMessageType> {
broadcastChannel.emit('receiveMessage', savedMessage, roomIdentifier);

return true;
} catch (error) {
} catch {
console.error('Failed to send message');
socket.emit('receiveError', roomIdentifier);

return false;
}
}

private async authentication(socket: ChatSocketType<TMessageType>, next: (err?: ExtendedError) => void) {
private async authentication(socket: ChatSocketType<TMessageType>, next: (error?: ExtendedError) => void) {
try {
const connectionInfo = await this.service.fetchConnectionInfo(socket.request);

Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/RoomManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TTLCache from '@isaacs/ttlcache';
import { ChatServerType, ChatSocketType, ConnectionInfo } from '@rchat/shared';

import LRUCache from 'lru-cache';
import TTLCache from '@isaacs/ttlcache';

const TTL_LONG = 60 * 60 * 1000; // persist active channels for one hour in memory.
const TTL_SHORT = 2 * 60 * 1000; // persist preheated channels for 2 minutes.
Expand Down Expand Up @@ -121,7 +121,7 @@ export class RoomManager<TMessageType> {
let participants: Set<string> | undefined;
try {
participants = await this.getRoomParticipants(socket, roomIdentifier);
} catch (error) {
} catch {
console.error('Preheating room failed: cannot get room participants');
}

Expand Down
2 changes: 0 additions & 2 deletions packages/shared/.eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions packages/shared/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import config from '@sirse-dev/eslint-config';

export default [
{
ignores: [
'**/node_modules',
'**/dist',
'**/*.config.js',
'**/*.test.js',
'**/*.test.ts',
'**/stories',
'**/test',
'**/prepared-package',
],
},
...config,
];
3 changes: 2 additions & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"scripts": {
"build": "aqu build && rimraf ./prepared-package && clean-publish",
"postpublish": "rimraf ./prepared-package",
"prepublishOnly": "pnpm build"
"prepublishOnly": "pnpm build",
"lint": "eslint **/*.{ts,tsx}"
},
"devDependencies": {
"@babel/core": "^7.18.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/TypedSocketIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import type { Socket as ClientSocket } from 'socket.io-client';
export type ChatSocketType<TMessageType> = Socket<
ChatSocketEmitMap<TMessageType>,
ChatSocketListenMap<TMessageType>,
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
{},
ConnectionInfo
>;

export type ChatServerType<TMessageType> = Server<
ChatSocketEmitMap<TMessageType>,
ChatSocketListenMap<TMessageType>,
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
{},
ConnectionInfo
>;
Expand Down
2 changes: 0 additions & 2 deletions packages/test-utils/.eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions packages/test-utils/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import config from '@sirse-dev/eslint-config';

export default [
{
ignores: [
'**/node_modules',
'**/dist',
'**/*.config.js',
'**/*.test.js',
'**/*.test.ts',
'**/stories',
'**/test',
'**/prepared-package',
],
},
...config,
];
Loading

0 comments on commit aefcf8f

Please sign in to comment.