Skip to content

Commit

Permalink
Typescript refactor (#2685)
Browse files Browse the repository at this point in the history
* deps: install typescript

* Use typescript for the prerendered html

* Type a few common user components

* Use redux-toolkit

* Add a type declaration to base selector functions

* Add typed useDispatch and useSelector

* Remove default values from reducer action parameters

* Typed useStore hook

* Use the typed redux hooks everywhere

* Move all constants files to ts

* Use typescript files for active overlay

* Use redux slice features for active overlay

* Add types for config reducer

* Add types to the booth/history state

* Add types to the chat messages reducer

* Add types to small reducers

* Add types to the playlists reducer

* Partially convert WebSocket interactions to typescript

* Add types to more reducers

* Add types to dialogs

* Use typescript types in the SearchBar

* deps: update typescript

* Add types to chat components

* async fn

* Assert some types to make it pass

* Declare useTranslator()

* Work on types in media list

* Use swr for the history list

* Add types to more media list components

* Remove room history from redux state

* Do not eagerly load active playlist

* Move search request into the panel component

* Add types to ConnectionIndicator

* Move room history fetching implementation to a shared hook

* Use SWR for playlist state in mobile drawer

* a few types

* Use RTK slice for booth state

* support different types in MediaList

* Make the overlay types work

* Fix AddToPlaylistAction types

* make a BaseRowProps type...

* Add return type to addMediaMenu

* Use a redux slice for chat messages

* Refetch /now after the page was hidden

* Fix import in <Motd/>

* Fix lint

* use deepmerge instead of structuredClone

* Move settings state to a redux slice

* Use swr for YouTube imports

* Fix mutation in playlists reducer

* move suspense boundary

* Add types to form components

* Add types to media sources

* Add types to entry class

* Add types to the room user list

* Add types to waitlist

* Remove rowProps support from media list

* Fix settings

* Write soundcloud player with hooks

* Fix settings test

* Fix chat reducer tests

* Fix booth reducer test

* Add types to MediaSearchStore

* Fix soundcloud player props

* Type most chat actions?

* lint

* fix url

* Use createAsyncThunk for login

* uwFetch

* lint <video/>

* Delete unused action constants

* Move chat notifications into extraReducers

* pkg: add typecheck npm script

* Fix login

* Use advance.type

* remove LOAD_VOTES

* Move theme state to a redux slice

* Move waitlist state to a redux slice

* Move import/search panel state into playlists reducer

* add type for json-api errors

* Write users reducer as a redux slice

* Delete unused action type constants

* Move username changes to an async thunk

* Write initState as an async thunk

* use flattened media type in chat notif…

* fix getting socket token from initState

* move socket action handlers to a listener middleware

* break some recursive types

* handle undefined

* deps: update

* markdown.tsx

* Use createAsyncThunk for updating MOTD

* update tests to new reducers

* remove eager loadPlaylist call when selecting a playlist

* Remove jest-fetch-mock

* use vitest

* fixup! use vitest

* deps: install vitest coverage tool

* handle moderator waitlist moves

* Move active import source type selector into the reducer file

* Reduce cyclical imports

* use eslint-plugin-vitest

* toEqual → toBe where possible

* include jsx tests in vitest

* move add media menu state to a slice

* Move addToPlaylistMenu selectors into the reducer file

* move most settings code into the reducer

* fix types in AddToPlaylistAction

* Hardcode media source reducer for now

* import vi

* use async thunk for importing playlist from youtube

* Fix imports

* Rewrite playlists reducer as a redux slice

* createPlaylist as an async thunk

* deps: update vite

* fix playlist reducer types

* update getMediaSource() type

* deps: add explicit jsdom dependency

* port addMedia to an async thunk

* fix new playlist item type

* build: remove custom babel config

* remove old search actions

* line length

* remove obsolete user actions

* lint uwave.tsx

* deps: update stylelint config

* deps: update p-map

* deps: update rimraf

* build: allow for-of

* build: lint passes

* deps: update vitest

* deps: update escape-string-regexp

* fix preview player size

* Fix some media source types

* fix one settings crash

* make notification settings work

* deps: update get-port

* deps: update vitest

* deps: update vitest

* deps: update eslint-plugin-jest-dom

* deps: npm update

* deps: update emojibase-data

* Remove obsolete `@nest` from CSS files

* deps: update dependencies

* deps: update vitest

* deps: update clsx

* deps: update vite to v5

* deps: update react-virtual

* deps: update testing deps

* Fix type checking

* 2.0.0-alpha.25

* Bubble up errors during load

* Use size from playlist metadata in panels

Fixes the load trigger.

This doesn't fully do it. The underlying problem is that the `media`
array for a playlist may not be populated in prod.

* Address some crashes in playlist items

* 2.0.0-alpha.26

* Remove serverEmotes config reducer leftovers

* 2.0.0-alpha.27

* Fix closing settings manager

* Handle user having no active playlist

* Fix merging currently playing media object

* Typecheck indexed access, fixing some playlist state bugs

* deps: update u-wave-parse-chat-markup to support deduped emote names

* 2.0.0-alpha.28

* Untyped action 💀

* youtube: allow keyboard control of preview player

* deps: update jsdom

* Lint fixes
  • Loading branch information
goto-bus-stop authored Dec 2, 2023
1 parent 6c91f53 commit 724edd2
Show file tree
Hide file tree
Showing 349 changed files with 12,854 additions and 17,228 deletions.
63 changes: 55 additions & 8 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
'use strict';

module.exports = {
extends: ['airbnb', 'airbnb/hooks'],
extends: ['airbnb', 'airbnb/hooks', 'plugin:import/typescript'],

plugins: ['compat', 'react-hooks'],
parserOptions: {
ecmaVersion: 2022,
ecmaFeatures: {
// Ideally this would only be done for .jsx files, but eslint-plugin-import
// has trouble with the overrides?
jsx: true,
},
},

rules: {
'arrow-body-style': 'off',
'no-underscore-dangle': ['error', { allow: ['_id'] }],
// Modify eslint-config-airbnb's rule to allow ForOfStatement
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],

'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'import/extensions': ['error', 'ignorePackages', {
js: 'never',
mjs: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
}],
// Not true anymore
'react/react-in-jsx-scope': 'off',
'react/no-unused-prop-types': ['error', { skipShapeProps: true }],
'react/forbid-prop-types': 'off',
'react/jsx-props-no-spreading': 'off',
Expand All @@ -27,6 +48,13 @@ module.exports = {
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
}],
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],

'jsx-a11y/control-has-associated-label': [
'warn',
require('eslint-config-airbnb/rules/react-a11y')
.rules['jsx-a11y/control-has-associated-label'][1],
],
},

settings: {
Expand All @@ -47,6 +75,25 @@ module.exports = {
},

overrides: [
{
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended'],
},

{
files: ['src/reducers/*'],
rules: {
// Reducers use default params differently
'default-param-last': 'off',
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: ['state'],
}],
},
},

{
files: ['src/**/*.{js,jsx}'],
rules: {
Expand All @@ -65,8 +112,8 @@ module.exports = {
},
{
files: ['**/__tests__/**/*.{js,jsx}'],
plugins: ['eslint-plugin-jest', 'eslint-plugin-jest-dom', 'eslint-plugin-testing-library'],
extends: ['plugin:jest/recommended', 'plugin:jest-dom/recommended', 'plugin:testing-library/react'],
plugins: ['eslint-plugin-vitest', 'eslint-plugin-jest-dom', 'eslint-plugin-testing-library'],
extends: ['plugin:vitest/recommended', 'plugin:jest-dom/recommended', 'plugin:testing-library/react'],
env: {
jest: true,
},
Expand Down
124 changes: 0 additions & 124 deletions babel.config.cjs

This file was deleted.

12 changes: 0 additions & 12 deletions jest.config.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "u-wave-web",
"version": "2.0.0-alpha.24",
"version": "2.0.0-alpha.28",
"description": "Web client for üWave servers.",
"author": "Renée Kooi <[email protected]>",
"license": "MIT",
Expand Down
Loading

0 comments on commit 724edd2

Please sign in to comment.