Skip to content

Commit

Permalink
Merge pull request #183 from TNG/renovate/major-eslint-monorepo
Browse files Browse the repository at this point in the history
fix(deps): update dependency eslint to v9
  • Loading branch information
lukastaegert authored Aug 31, 2024
2 parents 87d9b8f + d5df7a6 commit 6c2dbfa
Show file tree
Hide file tree
Showing 36 changed files with 479 additions and 674 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"*.{js,ts,tsx}": "eslint --cache --fix --ext .js,.ts,.tsx",
"*.{js,ts,tsx}": "eslint --cache --fix",
"*": "prettier --write"
}
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"printWidth": 100,
"plugins": ["prettier-plugin-organize-imports"]
}
6 changes: 5 additions & 1 deletion backend/local/dynamo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export const prepareTable = async () => {
if ((err as AWSError).code === 'ResourceInUseException') {
console.log(`Table "${TableName}" already exists`);
return;
} else if (['UnknownEndpoint', 'ECONNRESET'].includes((err as AWSError).code!)) {
} else if (
(['UnknownEndpoint', 'ECONNRESET'] as (string | undefined)[]).includes(
(err as AWSError).code,
)
) {
console.log('Database not found, retrying...');
} else {
console.error('Error creating table:', JSON.stringify(err, null, 2));
Expand Down
2 changes: 1 addition & 1 deletion backend/local/socket.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Readable } from 'stream';
import * as WebSocket from 'ws';
import { generateId } from '../../shared/generateId';
import { onConnect } from '../onconnect/src/on-connect';
import { onDisconnect } from '../ondisconnect/src/on-disconnect';
import { onMessage } from '../sendmessage/src/on-message';
import { ConfigWithHandler } from '../shared/types';
import { ddb } from './dynamo';
import { Readable } from 'stream';

interface WebsocketWithId extends WebSocket {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion backend/sendmessage/src/reset-votes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { broadcastState } from '../../shared/actions';
import { getConnection } from '../../shared/database/getConnection';
import { getGroup } from '../../shared/database/getGroup';
import { resetGroupVotes } from '../../shared/database/resetGroupVotes';
import { ConfigWithHandler } from '../../shared/types';
import { broadcastState } from '../../shared/actions';

export const resetVotes = async (config: ConfigWithHandler) => {
const connectionItem = await getConnection(config);
Expand Down
2 changes: 1 addition & 1 deletion backend/sendmessage/src/reveal-votes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { broadcastState } from '../../shared/actions';
import { getConnection } from '../../shared/database/getConnection';
import { revealGroupVotes } from '../../shared/database/revealGroupVotes';
import { ConfigWithHandler } from '../../shared/types';
import { broadcastState } from '../../shared/actions';

export const revealVotes = async (config: ConfigWithHandler) => {
const connectionItem = await getConnection(config);
Expand Down
2 changes: 1 addition & 1 deletion backend/sendmessage/src/set-scale.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CardValue } from '../../../shared/cards';
import { broadcastState } from '../../shared/actions';
import { getConnection } from '../../shared/database/getConnection';
import { getGroup } from '../../shared/database/getGroup';
import { resetGroupVotes } from '../../shared/database/resetGroupVotes';
import { ConfigWithHandler } from '../../shared/types';
import { broadcastState } from '../../shared/actions';

export const setScale = async (scale: CardValue[], config: ConfigWithHandler): Promise<void> => {
const connectionItem = await getConnection(config);
Expand Down
2 changes: 1 addition & 1 deletion backend/sendmessage/src/set-vote.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CardValue } from '../../../shared/cards';
import { broadcastState } from '../../shared/actions';
import { getConnection } from '../../shared/database/getConnection';
import { setGroupConnectionVote } from '../../shared/database/setGroupConnectionVote';
import { ConfigWithHandler } from '../../shared/types';
import { broadcastState } from '../../shared/actions';

export const setVote = async (vote: CardValue, config: ConfigWithHandler) => {
const connectionItem = await getConnection(config);
Expand Down
2 changes: 1 addition & 1 deletion backend/shared/database/getGroup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Config, GroupItem } from '../types';
import { getItem } from './getItem';

export const getGroup = async (groupId: string, config: Config): Promise<GroupItem | void> =>
export const getGroup = async (groupId: string, config: Config): Promise<GroupItem | undefined> =>
getItem<GroupItem>('groupId', groupId, config.tableName, config.ddb);
11 changes: 6 additions & 5 deletions backend/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ export interface ConnectionItem {
userId?: string;
}

export interface GroupConnections {
[id: string]: {
export type GroupConnections = Record<
string,
{
connectionId?: string;
vote: CardValue;
};
}
}
>;

export interface GroupItem {
scale: Array<CardValue>;
scale: CardValue[];
ttl: number;
groupId: string;
visible: boolean;
Expand Down
36 changes: 36 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default [
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
ignores: ['**/dist', '**/dist-ssr', '**/build'],
},
{
rules: {
'prettier/prettier': 'error',
},
},
{
files: ['**/prerenderHtml.js'],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['**/*.test.*'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
eslintPluginPrettierRecommended,
];
2 changes: 1 addition & 1 deletion frontend/prerenderHtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import { render } from './dist-ssr/index-ssr.js';
import { minify } from 'html-minifier-terser';
import { render } from './dist-ssr/index-ssr.js';

const htmlUrl = new URL('dist/index.html', import.meta.url);
const ssrMarker = '<!--ssr-outlet-->';
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import classes from './App.module.css';
import { ColorModeProvider } from '../ColorModeProvider/ColorModeProvider';
import { PageSelector } from '../PageSelector/PageSelector';
import { TouchDetector } from '../TouchDetector/TouchDetector';
import { WebSocketProvider } from '../WebSocket/WebSocket';
import { ColorModeProvider } from '../ColorModeProvider/ColorModeProvider';
import classes from './App.module.css';

export const App = () => (
<div class={classes.app}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext } from 'preact';
import { useCallback, useLayoutEffect, useRef, useState } from 'preact/hooks';
import { JSXInternal } from 'preact/src/jsx';
import './ColorModeProvider.module.css';
import { doNothing } from '../../helpers/helpers';
import './ColorModeProvider.module.css';

const COLOR_SWITCH_TIME_MS = 1000;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sharedClasses from '../../styles.module.css';
import { BUTTON_COPY_TO_CLIPBOARD } from '../../constants';
import sharedClasses from '../../styles.module.css';

export const CopyToClipboardButton = () => (
<button
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/Components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CopyToClipboardButton } from '../CopyToClipboardButton/CopyToClipboardButton';
import classes from './Footer.module.css';
import { connectToWebSocket } from '../WebSocket/WebSocket';
import { LABEL_SESSION, LABEL_USERNAME } from '../../constants';
import { CopyToClipboardButton } from '../CopyToClipboardButton/CopyToClipboardButton';
import { LegalNoticeContainer } from '../LegalNoticeContainer/LegalNoticeContainer';
import { connectToWebSocket } from '../WebSocket/WebSocket';
import classes from './Footer.module.css';

export const Footer = connectToWebSocket(({ socket }) => (
<footer class={classes.footer}>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tngLogo from '../../img/tng.svg';
import classes from './Header.module.css';
import { ALT_TNG_LOGO, TNG_URL } from '../../constants';
import tngLogo from '../../img/tng.svg';
import { ColorModeSwitch } from '../ColorModeSwitch/ColorModeSwitch';
import classes from './Header.module.css';

export const Header = () => (
<header class={classes.header}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/IconCoffee/IconCoffee.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sharedClasses from '../../styles.module.css';
import { TOOLTIP_COFFEE } from '../../constants';
import sharedClasses from '../../styles.module.css';

// taken from material icons
export const IconCoffee = () => (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/IconNotVoted/IconNotVoted.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sharedClasses from '../../styles.module.css';
import { TOOLTIP_NOT_VOTED } from '../../constants';
import sharedClasses from '../../styles.module.css';

// taken from material icons
export const IconNotVoted = () => (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/IconObserver/IconObserver.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sharedClasses from '../../styles.module.css';
import { TOOLTIP_OBSERVER } from '../../constants';
import sharedClasses from '../../styles.module.css';

// taken from material icons
export const IconObserver = () => (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/IconVoted/IconVoted.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sharedClasses from '../../styles.module.css';
import { TOOLTIP_VOTED } from '../../constants';
import sharedClasses from '../../styles.module.css';

// taken from material icons
export const IconVoted = () => (
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/Components/ResetButton/ResetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const ResetButton = connectToWebSocket(({ socket }) => {
const locked = useRef<boolean>(true);

const handleClick = () => {
(!locked.current || window.confirm(RESET_VOTES_CONFIRMATION)) && socket.resetVotes();
if (!locked.current || window.confirm(RESET_VOTES_CONFIRMATION)) {
socket.resetVotes();
}
};

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/WebSocket/WebSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const WebSocketProvider = ({ children }: { children: ComponentChildren })
setState({ ...state, votes: { ...state.votes, [loginData.user]: vote } });
};

const setScale = (scale: Array<CardValue>) => {
const setScale = (scale: CardValue[]) => {
socket?.send(getSetScaleRequest(scale));
setState({ ...state, votes: getInitialVotes(state.votes), scale });
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/helpers/compareVotes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VOTE_COFFEE, VOTE_NOTE_VOTED, VOTE_OBSERVER, CardValue } from '../../../shared/cards';
import { CardValue, VOTE_COFFEE, VOTE_NOTE_VOTED, VOTE_OBSERVER } from '../../../shared/cards';
import { compareCardValues, compareVotes } from './compareVotes';
import { UserState } from './getVotingState';

Expand Down
4 changes: 1 addition & 3 deletions frontend/src/helpers/getVotingState.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { VOTE_COFFEE } from '../../../shared/cards';
import { VOTE_OBSERVER } from '../../../shared/cards';
import { VOTE_NOTE_VOTED } from '../../../shared/cards';
import { VOTE_COFFEE, VOTE_NOTE_VOTED, VOTE_OBSERVER } from '../../../shared/cards';
import { SCALES } from '../../../shared/scales';
import { UserState, getVotingState } from './getVotingState';

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/helpers/getVotingState.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CardValue, VOTE_NOTE_VOTED, VOTE_OBSERVER } from '../../../shared/cards';
import { WebSocketApi } from '../types/WebSocket';

export type UserState = {
export interface UserState {
user: string;
vote: CardValue;
voted: boolean;
observer: boolean;
pendingConnection: boolean;
};
}

export const getVotingState = ({
connected,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/requests/websocket-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getSetVoteRequest = (vote: CardValue) =>
},
});

export const getSetScaleRequest = (scale: Array<CardValue>) =>
export const getSetScaleRequest = (scale: CardValue[]) =>
buildRequest({
type: 'set-scale',
payload: {
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/types/WebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ export interface WebSocketApi {
removeUser(user: string): void;
resetVotes(): void;
revealVotes(): void;
setScale(scale: Array<CardValue>): void;
setScale(scale: CardValue[]): void;
setVote(vote: CardValue): void;
state: WebSocketState;
}

export type WebSocketLoginData = { user: string; session: string };
export interface WebSocketLoginData {
user: string;
session: string;
}
Loading

0 comments on commit 6c2dbfa

Please sign in to comment.