Skip to content

Modernise UI code and tooling - #218

Open
noClaps wants to merge 40 commits into
discuitnet:mainfrom
noClaps:update-tooling
Open

noClaps wants to merge 40 commits into
discuitnet:mainfrom
noClaps:update-tooling

Conversation

@noClaps

@noClaps noClaps commented Nov 4, 2026 •

Copy link
Copy Markdown
  • Replaced npm with pnpm. With the latest version of pnpm, it can also manage the Node runtime, so you don't need to separately download Node, it'll get automatically downloaded with pnpm install or pnpm ci. I've set it to Node 26.13.0 for now since that's the latest version of Node, but this can be changed to LTS if needed.
  • Replaced ESLint with Oxlint. I just used the migration tools to bump the ESLint 8 config to ESLint 10, then migrated that to Oxlint. I think some lints were lost along the way, but given that linting isn't actually run in CI, I don't think that makes much difference. It's much faster though, and fewer deps. Oxlint did raise some warnings/errors that are probably worth fixing.
  • Replaced Prettier with Oxfmt. I used the Oxlint migration tool and didn't do anything else.
  • Updated Vite, @vitejs/plugin-react, and TypeScript to their latest versions. This makes them much faster along with cutting down on a bunch of dependencies. A lot of the savings come from Vite v8 which uses the same Oxc parsers as Oxlint, Oxfmt and Knip.
  • Replaced redux-devtools-extension with @redux-devtools/extension. The former is deprecated and the latter is the official replacement.
  • Updated react-markdown, react-helmet-async and react-intersection-observer to their latest versions. I didn't test further than running pnpm build but they didn't seem to have any impact.
  • Fixed the issues raised by pnpx @e18e/cli analyze. Mostly just changing from manual const var = []; for (...) { var.push(...); } style loops to Array.from, Array.map, etc., methods. The rest of the warnings are about dependency versions that we can't control.
  • Replaced the various Redux packages with Redux toolkit.
  • Added linting and formatting step in CI. I don't see the point of having these if they're not being enforced, but I can reverse this change if it's not desired.
  • Fixed the issues raised by Knip. Knip is a tool that catches things like unused exports, files, dependencies, and other things. Removed unused symbols, files and exports, and renamed d.ts to global.d.ts.
  • Updated all dependencies to their latest versions.

The main reason for these changes is to modernise the tooling in the UI code, and remove a bunch of unneeded and outdated dependencies. The UI itself is left intact.

I'd recommend going through this PR commit-by-commit rather than all at once as there are a lot of changes. It should also probably be split up into multiple PRs instead of one giant one.

It doesn't seem like linting is run anywhere anyway, not sure why it's
been set up
Had to amend the ESLint->Oxlint commit, couldn't be bothered to fix the
conflicts in the Prettier->Oxfmt commit
@Codycody31

Copy link
Copy Markdown
Collaborator

@previnder not to be merged yet, but wanted your eyes on this. I'll be working with noClaps to complete the rest of the items left to do, but this should help speed things up, along with bumping the UI deps, which should also introduce some performance improvements during the build.

@noClaps
noClaps marked this pull request as draft November 4, 2026 23:46
@noClaps noClaps changed the title Update tooling Modernise tooling for UI code Nov 4, 2026
@previnder

Copy link
Copy Markdown
Member

I ran this on my side, and the performance improvement is pretty good. One thing I noticed is that pnpm run lint does not run knip if oxlint returns false (which it does right now).

Let's keep the config file in YAML. YAML files are easier to edit by hand than JSON, and the additional dependency is not a major concern.

Discuit uses plain Redux right now, not Redux Toolkit, so I'm not sure if replacing the Redux packages with Redux Toolkit packages would even work. A full migration from Redux to Redux Toolkit, however, would be a massive change.

@noClaps

noClaps commented Nov 8, 2026 •

Copy link
Copy Markdown
Author

One thing I noticed is that pnpm run lint does not run knip if oxlint returns false (which it does right now).

Yeah that's just how && works, I've fixed that.

Let's keep the config file in YAML. YAML files are easier to edit by hand than JSON, and the additional dependency is not a major concern.

Okay sure, removed the todo-list item.

Discuit uses plain Redux right now, not Redux Toolkit, so I'm not sure if replacing the Redux packages with Redux Toolkit packages would even work. A full migration from Redux to Redux Toolkit, however, would be a massive change.

I'm not sure about this, because RTK re-exports everything from Redux, so it's a drop-in replacement in that sense. The larger migration is mainly modernising the code and removing some deprecated features like createStore. I'll try doing the change and see what it entails.


Edit: I tried doing the migration and it ended up being around +700-something -1100-something lines which is small, but not as drop-in as I'd have liked. I can make the change if you'd like, otherwise I can leave it for the future.


Edit 2: Found another way to do the migration. This part

middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({ immutableCheck: false, serializableCheck: false }),

is there because otherwise there are a ton of errors in the console in dev mode. Nothing in prod either way.

Had to add some config to set up Oxlint as the formatter, probably good
to have for future contributors using Zed as well
Most of this was just exported symbols that didn't need to be exported,
and leftover unused symbols. The d.ts file was renamed to global.d.ts,
and some unused files were deleted.
react-router-dom exports all the needed symbols
This is preparation for the React Router v6 upgrade
@noClaps noClaps changed the title Modernise tooling for UI code Modernise UI code and tooling Nov 8, 2026
@previnder

Copy link
Copy Markdown
Member

I think if we are going to migrate to Redux Toolkit in full, it's better to do it in a separate PR so that we can merge this one without a lot of delay.

@noClaps

noClaps commented Nov 9, 2026 •

Copy link
Copy Markdown
Author

Agreed. I talked to @Codycody31 and he said he'd be able to split up the PR as needed. If not, I can just make new PR myself.

Comment thread ui/src/pages/Lists/List.tsx Resolved
React 19 hoists <head> elements by default so this dependency is no
longer needed
This useEffect would fire since post.userGroup and post.publicId were
both listed as dependencies of it, and it would cause the PUT request to
fire. Ideally this should be a handler on the user group checkbox
instead of a useEffect, but that's not a change for me to make.
@noClaps
noClaps marked this pull request as ready for review November 9, 2026 16:39
@noClaps

noClaps commented Nov 9, 2026

Copy link
Copy Markdown
Author

This PR is ready for review from my end. I wasn't able to test the changes with a mod/admin account, but everything appears to work with a regular user account, at least based on my limited testing.

P.S. There should probably be tests for the UI to ensure that things continue working. It would be a lot easier to run pnpm test rather than load up the dev server, click around a bunch and hope I didn't miss anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants