Skip to content

Commit

Permalink
Upgrade deps 23-11-2024 (#471)
Browse files Browse the repository at this point in the history
* upgrade next: `npx @next/codemod@canary upgrade latest`

* fix markdown types also by upgrading packages

* change TS target to fix some regex issues ("u"/"s" flag supported when targetting ES2018+). next builds to ES5 anyway

* upgrade some packages and fix errors

* non-major version upgrade of most deps

* downgrade eslint back to 8

* fix eslint

* migrate to next.config.ts

* rework Marquee without SCSS module styles

* upgrade also `typed-scss-modules` to 8

* fix usage of firstRender

---------

Co-authored-by: matushl <[email protected]>
  • Loading branch information
rtrembecky and Matushl authored Nov 23, 2024
1 parent c98409f commit a2cf3c6
Show file tree
Hide file tree
Showing 20 changed files with 3,819 additions and 2,423 deletions.
45 changes: 17 additions & 28 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ESLint config - most of this file is taken from the config on one of Riso's previous projects in Vacuumlabs.
// EDIT: vela kokocin asi. snazme sa pouzivat co najviac extendovanych configov a co najmenej explicitnych rules

// eslint-disable-next-line @typescript-eslint/no-require-imports
const restrictedGlobals = require('confusing-browser-globals')

module.exports = {
Expand Down Expand Up @@ -31,7 +33,8 @@ module.exports = {

// Baseline configurations
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
// 'plugin:@typescript-eslint/strict',

// Disable ESLint rules conflicting with Prettier
'prettier',
Expand All @@ -45,7 +48,7 @@ module.exports = {
'plugin:promise/recommended',

// Detect common patterns that can lead to security issues
'plugin:security/recommended',
'plugin:security/recommended-legacy',

// Run Prettier as an ESLint plugin (not separately after ESLint)
'plugin:prettier/recommended',
Expand All @@ -71,30 +74,9 @@ module.exports = {
// additional React rules not included in recommended set
'react/self-closing-comp': 'error',

// Rules coming @typescript-eslint/recommended, but with level adjusted to warning
'@typescript-eslint/adjacent-overload-signatures': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'warn',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-extra-non-null-assertion': 'warn',
'no-extra-semi': 'off',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-misused-new': 'warn',
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/prefer-namespace-keyword': 'warn',
'@typescript-eslint/triple-slash-reference': 'warn',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', {argsIgnorePattern: '^_', ignoreRestSiblings: true}],
'@typescript-eslint/no-explicit-any': 'warn',

// Use === instead of == for everything, except for comparison with null and other special
// cases.
Expand Down Expand Up @@ -229,7 +211,17 @@ module.exports = {
// Rules specific to TypeScript files
{
files: ['*.ts', '*.tsx'],
extends: ['plugin:import/typescript'],
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
},
extends: [
'plugin:import/typescript',
// TODO: allow for stricter rules
// 'plugin:@typescript-eslint/recommended-type-checked'
// TODO: consider moving this further to strict
// 'plugin:@typescript-eslint/strict-type-checked'
],
rules: {
// Unsupported syntax will be transpiled by TypeScript anyway
'node/no-unsupported-features/es-syntax': 'off',
Expand All @@ -241,9 +233,6 @@ module.exports = {

// Disable const x = require("module") syntax (use imports instead)
'@typescript-eslint/no-var-requires': 'warn',

// Always annotate caught errors with `unknown`, forcing explicit type checking
'@typescript-eslint/no-implicit-any-catch': 'warn',
},
},

Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
23 changes: 20 additions & 3 deletions next.config.js → next.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type import('next').NextConfig */
module.exports = {
import type {NextConfig} from 'next'

const nextConfig: NextConfig = {
// docs: https://nextjs.org/docs/api-reference/next.config.js/redirects
async redirects() {
return [
Expand All @@ -24,7 +25,10 @@ module.exports = {
images: {
remotePatterns: [
{
// TODO: neviem, preco to krici, treba overit, ci funguju obrazky pri ulohach
// @ts-ignore

Check warning on line 29 in next.config.ts

View workflow job for this annotation

GitHub Actions / branch-test

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
protocol: process.env.NEXT_PUBLIC_BE_PROTOCOL,
// @ts-ignore

Check warning on line 31 in next.config.ts

View workflow job for this annotation

GitHub Actions / branch-test

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
hostname: process.env.NEXT_PUBLIC_BE_HOSTNAME,
port: process.env.NEXT_PUBLIC_BE_PORT,
pathname: '/media/**',
Expand All @@ -40,7 +44,7 @@ module.exports = {
// https://react-svgr.com/docs/next/
webpack(config) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'))
const fileLoaderRule = config.module.rules.find((rule: any) => rule.test?.test?.('.svg'))

Check warning on line 47 in next.config.ts

View workflow job for this annotation

GitHub Actions / branch-test

Unexpected any. Specify a different type

config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
Expand All @@ -63,4 +67,17 @@ module.exports = {

return config
},
experimental: {
turbo: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
},
}

// eslint-disable-next-line import/no-default-export
export default nextConfig
106 changes: 55 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"node": ">=16.0.0"
},
"scripts": {
"dev": "next dev",
"dev": "next dev --turbopack",
"start": "next start",
"build": "next build",
"lint": "eslint .",
Expand All @@ -16,66 +16,70 @@
"css-types:watch": "yarn css-types --watch"
},
"dependencies": {
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.12.3",
"@tanstack/react-query": "5.0.0-alpha.26",
"@tanstack/react-query-devtools": "5.0.0-alpha.30",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"axios": "^1.4.0",
"clsx": "^1.2.1",
"katex": "^0.16.7",
"luxon": "^3.3.0",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.16.7",
"@tanstack/react-query": "5.61.0",
"@tanstack/react-query-devtools": "5.61.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.2",
"axios": "^1.7.7",
"clsx": "^2.1.1",
"katex": "^0.16.11",
"luxon": "^3.5.0",
"mathjax-full": "^3.2.2",
"mathjax-react": "^2.0.1",
"next": "^13.4.12",
"react": "^18.2.0",
"react-admin": "^4.16.15",
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106",
"react-admin": "^4.16.20",
"react-cookie": "^4.1.1",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.43.9",
"react-markdown": "^8.0.7",
"rehype-katex": "^6.0.3",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"typescript": "^5.0.4",
"react-dom": "19.0.0-rc-66855b96-20241106",
"react-dropzone": "^14.3.5",
"react-hook-form": "^7.53.2",
"react-markdown": "^9.0.1",
"rehype-katex": "^7.0.1",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"typescript": "^5.7.2",
"unstated-next": "^1.1.0",
"usehooks-ts": "^2.9.1"
"usehooks-ts": "^3.1.0"
},
"devDependencies": {
"@svgr/webpack": "^8.0.1",
"@testing-library/dom": "^9.2.0",
"@types/jest": "^29.5.1",
"@types/katex": "^0",
"@types/luxon": "^3.3.0",
"@types/node": "^20.1.0",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@svgr/webpack": "^8.1.0",
"@testing-library/dom": "^9.3.4",
"@types/jest": "^29.5.14",
"@types/katex": "^0.16.7",
"@types/luxon": "^3.4.2",
"@types/node": "^20.17.7",
"@types/react": "^19.0.0-rc.1",
"@types/react-dom": "^19.0.0-rc.1",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.59.5",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"confusing-browser-globals": "^1.0.11",
"eslint": "^8.40.0",
"eslint-config-next": "^13.4.12",
"eslint-config-prettier": "^8.8.0",
"eslint": "^8.57.1",
"eslint-config-next": "15.0.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-no-secrets": "^1.1.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unicorn": "^47.0.0",
"prettier": "^2.8.8",
"sass": "^1.62.1",
"typed-scss-modules": "^7.1.0"
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-security": "^3.0.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unicorn": "^56.0.1",
"prettier": "^3.3.3",
"sass": "^1.81.0",
"typed-scss-modules": "^8.0.1"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"resolutions": {
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
}
}
6 changes: 3 additions & 3 deletions src/components/Admin/custom/MyEditActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const MyEditActions: FC = () => {
return (
<TopToolbar>
{/* the `to` prop was omitted from ShowButton in recent RA version, but it's still working
and RA doesn't provide better way to do this
eslint-disable-next-line @typescript-eslint/ban-ts-comment
@ts-ignore */}
and RA doesn't provide better way to do this
TODO: try again after RA upgrade */}
{/* @ts-ignore */}

Check warning on line 24 in src/components/Admin/custom/MyEditActions.tsx

View workflow job for this annotation

GitHub Actions / branch-test

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
<ShowButton to={to} />
<ListButton label="Back to list" />
</TopToolbar>
Expand Down
2 changes: 1 addition & 1 deletion src/components/CompetitionPage/CompetitionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const CompetitionPage: FC<CompetitionPageProps> = ({
</Typography>
<Stack direction="row" sx={{gap: {xs: 1, sm: 2}}}>
{event.publication_set.map((publication) => (
<Link variant="button2" key={publication.id} href={`/api/${publication.file}`}>
<Link variant="button2" key={publication.id} href={`/api${publication.file}`}>
{publication.name}
</Link>
))}
Expand Down
67 changes: 0 additions & 67 deletions src/components/Marquee/Marquee.module.scss

This file was deleted.

12 changes: 0 additions & 12 deletions src/components/Marquee/Marquee.module.scss.d.ts

This file was deleted.

Loading

0 comments on commit a2cf3c6

Please sign in to comment.