Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): Update dependencies 2024-09-16 #1612

Merged
merged 22 commits into from
Sep 17, 2024
Merged

Conversation

dgdavid
Copy link
Contributor

@dgdavid dgdavid commented Sep 16, 2024

Update web dependencies to their latest versions via npm update and npm install package-name@latest when needed.

Show/hide `npm outdated` output before proposed changes
Package                                    Current        Wanted   Latest  Location                                           Depended by
@babel/core                                 7.24.5        7.25.2   7.25.2  node_modules/@babel/core                           web
@babel/eslint-parser                        7.24.5        7.25.1   7.25.1  node_modules/@babel/eslint-parser                  web
@babel/preset-env                           7.24.5        7.25.4   7.25.4  node_modules/@babel/preset-env                     web
@babel/preset-react                         7.24.1        7.24.7   7.24.7  node_modules/@babel/preset-react                   web
@cspell/dict-css                            4.0.12        4.0.13   4.0.13  node_modules/@cspell/dict-css                      web
@cspell/dict-en-common-misspellings          2.0.0         2.0.4    2.0.4  node_modules/@cspell/dict-en-common-misspellings   web
@cspell/dict-fullstack                       3.1.5         3.2.0    3.2.0  node_modules/@cspell/dict-fullstack                web
@icons-pack/react-simple-icons               9.4.1         9.7.0   10.0.0  node_modules/@icons-pack/react-simple-icons        web
@material-symbols/svg-400                   0.17.4        0.17.4   0.23.0  node_modules/@material-symbols/svg-400             web
@patternfly/patternfly                       5.3.1         5.4.0    5.4.0  node_modules/@patternfly/patternfly                web
@patternfly/react-core                       5.3.3         5.4.0    5.4.0  node_modules/@patternfly/react-core                web
@patternfly/react-table                      5.3.3         5.4.0    5.4.0  node_modules/@patternfly/react-table               web
@pmmmwh/react-refresh-webpack-plugin        0.5.13        0.5.15   0.5.15  node_modules/@pmmmwh/react-refresh-webpack-plugin  web
@tanstack/react-query                       5.49.2        5.56.2   5.56.2  node_modules/@tanstack/react-query                 web
@testing-library/jest-dom                    6.4.5         6.5.0    6.5.0  node_modules/@testing-library/jest-dom             web
@testing-library/react                      15.0.7        15.0.7   16.0.1  node_modules/@testing-library/react                web
@types/jest                                29.5.12       29.5.13  29.5.13  node_modules/@types/jest                           web
@typescript-eslint/eslint-plugin             7.8.0        7.18.0    8.5.0  node_modules/@typescript-eslint/eslint-plugin      web
@typescript-eslint/parser                    7.8.0        7.18.0    8.5.0  node_modules/@typescript-eslint/parser             web
ajv                                         8.13.0        8.17.1   8.17.1  node_modules/ajv                                   web
axios                                        1.7.3         1.7.7    1.7.7  node_modules/axios                                 web
cspell                                       8.8.0        8.14.2   8.14.2  node_modules/cspell                                web
css-loader                                   7.1.1         7.1.2    7.1.2  node_modules/css-loader                            web
css-minimizer-webpack-plugin                 6.0.0         6.0.0    7.0.0  node_modules/css-minimizer-webpack-plugin          web
eslint                                      8.57.0        8.57.0   9.10.0  node_modules/eslint                                web
eslint-plugin-i18next                        6.0.3         6.1.0    6.1.0  node_modules/eslint-plugin-i18next                 web
eslint-plugin-import                        2.29.1        2.30.0   2.30.0  node_modules/eslint-plugin-import                  web
eslint-plugin-n                             16.6.2        16.6.2  17.10.2  node_modules/eslint-plugin-n                       web
eslint-plugin-promise                        6.1.1         6.6.0    7.1.0  node_modules/eslint-plugin-promise                 web
eslint-plugin-react                         7.34.1        7.36.1   7.36.1  node_modules/eslint-plugin-react                   web
eslint-webpack-plugin                        4.1.0         4.2.0    4.2.0  node_modules/eslint-webpack-plugin                 web
fast-sort                                    3.4.0         3.4.1    3.4.1  node_modules/fast-sort                             web
mini-css-extract-plugin                      2.9.0         2.9.1    2.9.1  node_modules/mini-css-extract-plugin               web
po2json                               1.0.0-beta-3  1.0.0-beta-3    0.4.5  node_modules/po2json                               web
prettier                                     3.3.2         3.3.3    3.3.3  node_modules/prettier                              web
qunit                                       2.20.1        2.22.0   2.22.0  node_modules/qunit                                 web
react-router-dom                            6.23.0        6.26.2   6.26.2  node_modules/react-router-dom                      web
sass                                        1.77.0        1.78.0   1.78.0  node_modules/sass                                  web
sass-loader                                 14.2.1        14.2.1   16.0.1  node_modules/sass-loader                           web
stylelint                                   16.5.0        16.9.0   16.9.0  node_modules/stylelint                             web
stylelint-config-standard                   36.0.0        36.0.1   36.0.1  node_modules/stylelint-config-standard             web
stylelint-prettier                           5.0.0         5.0.2    5.0.2  node_modules/stylelint-prettier                    web
stylelint-webpack-plugin                     5.0.0         5.0.1    5.0.1  node_modules/stylelint-webpack-plugin              web
ts-jest                                     29.2.2        29.2.5   29.2.5  node_modules/ts-jest                               web
typedoc                                    0.25.13       0.25.13   0.26.7  node_modules/typedoc                               web
typedoc-plugin-external-module-map           2.0.1         2.1.0    2.1.0  node_modules/typedoc-plugin-external-module-map    web
typedoc-plugin-merge-modules                 5.1.0         5.1.0    6.0.0  node_modules/typedoc-plugin-merge-modules          web
typedoc-plugin-missing-exports               2.2.0         2.3.0    3.0.0  node_modules/typedoc-plugin-missing-exports        web
typescript                                   5.4.5         5.6.2    5.6.2  node_modules/typescript                            web
webpack                                     5.91.0        5.94.0   5.94.0  node_modules/webpack                               web
webpack-dev-server                           5.0.4         5.1.0    5.1.0  node_modules/webpack-dev-server                    web

Additional notes

  • ESLint has been updated to the latest v9. To do so, eslint-config-standard plugins were replaced by neostandard. See b447bc2 and 5433c00

  • Now, the ESLint configuration lives at eslint.config.mjs. See ESLint migration guide https://eslint.org/docs/latest/use/migrate-to-9.0.0

  • Linters check now (?) TypeScript files

  • A lot of linters complaints has been fixed. See commit by commit if interested.

  • As a result of the migration, two icons were removed. One of them was actually not in use. To know more see a5c43a0

Special mention for 89214a7

As you can see in linked commit, the useVolumeTemplates query hook has changed significantly when fixing linters complaints. It was using a hook conditionally, breaking the Do not call Hooks after a conditional return statement. rule of hooks.

Although the change was done following the TanStack Query documentation, it has been manually tested too in order to check that everything works as expected when useProductParams returns undefined. And, apparently, it works: the Add filesystem button became disable, as can be seen in following screenshots.

useProductParams() -> { mountPoints: [...], ... } useProductParams() -> undefined
Screenshot from 2024-09-17 09-00-38 Screenshot from 2024-09-17 09-00-54

A quote

the ESLint plugin ecosystem is getting harder and harder to maintain,
and things get worse during major version upgrades — read in a comment at eslint-pluign-import


Previous update: #1184

Because eslint-config-standard still not being compatible with eslint >
9 version. The idea is to use eslint-neostandard instead, see

  * https://github.com/neostandard/neostandard
  * standard/eslint-config-standard#410 (comment)
Which comes from the cockpit-starter-kit (see
#127) but it is actually not
needed since Agama does not use flowtype's annotation.

What is more, it isn't a cockpit-starter-kit dependency anymoer, see
cockpit-project/starter-kit@ab04f35
Which has implied,

* Drop eslint-plugin-import in favor of eslint-plugin-import-x

  Since the eslint-plugin-import support for ESLint 9 is kind of a
  blocker for such an update at this moment. See import-js/eslint-plugin-import#2948

* Update eslint-plugin-react-hooks to an RC version

  For moving this update on without waiting until the support reach the
  @latest version. See facebook/react#30932 (comment)

As commented at
import-js/eslint-plugin-import#2948 (comment),

>  the ESLint plugin ecosystem is getting harder and harder to maintain,
>  and things get worse during major version upgrades.
Because standard does not support ESLint 9 yet because a governance
issue, see standard/standard#1948 (comment)
Forcing the new "load-partial-extension" rule to "always"
Which breaks a rule of hooks and makes ESLint complaint.

> web/src/queries/storage.ts 162:19  error  React Hook
> "useSuspenseQueries" is called conditionally. React Hooks must be called
> in the exact same order in every component render. Did you accidentally
> call a React Hook after an early return?  react-hooks/rules-of-hooks

Fixed it by depending on a previous query as explained at
https://tanstack.com/query/v5/docs/framework/react/guides/dependent-queries#usequeries-dependent-query
Related to @typescript-eslint/no-explicit-any complaints fixes at
e063e1a
@dgdavid dgdavid merged commit 1ca19ac into master Sep 17, 2024
2 checks passed
@dgdavid dgdavid deleted the update-deps-20240914 branch September 17, 2024 08:06
@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
dgdavid added a commit that referenced this pull request Sep 24, 2024
## Problem

Yesterday we found that production build was failing at OBS because type
checking. See #1623.

There were some _valid_ complaints because of wrong reference and
missing @testing-library/dom dependency overlooked during latest
migration to latest dependencies versions
#1612 However, the build was
failing with a bunch of unexpected errors that were not thrown neither
on CI nor in our development environments.

```
[tsl] ERROR in /agama/web/src/components/users/UsersPage.tsx(35,8)
      TS2741: Property 'children' is missing in type '{}' but required in type '{ [x: string]: any; hasGutter?: boolean; children: any; }'.
```

Unexpected because claimed children were actually there, but as nested
JSX nodes instead of _regular_ `prop`. Remember,

> When you nest content inside a JSX tag, the parent component will
receive that content in a prop called children.
> 
>
https://react.dev/learn/passing-props-to-a-component#passing-jsx-as-children

This made us suspect about
[`@types/react`](https://www.npmjs.com/package/@types/react) where a
type definition hinting TypeScript about such an _special_ prop is
expected. However, since we have no clue about those React advanced
types and were in a hurry, we took the shortcut to temporary disable the
type checking in order to get the production build working again.

Further investigation shows we were on the right track since the issue
only occurs when `@types/react` isn't present. The OBS build is using
`--legacy-peer-deps`, which does an slightly different dependencies
installation.

```diff
diff --git a/web/package-lock.json b/web/package-lock.json
index aef5ecc90..45f319bc2 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -5200,15 +5200,6 @@
         "@types/node": "*"
       }
     },
-    "node_modules/@types/prop-types": {
-      "version": "15.7.12",
-      "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz",
-      "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==",
-      "dev": true,
-      "license": "MIT",
-      "optional": true,
-      "peer": true
-    },
     "node_modules/@types/qs": {
       "version": "6.9.16",
       "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.16.tgz",
@@ -5223,31 +5214,6 @@
       "dev": true,
       "license": "MIT"
     },
-    "node_modules/@types/react": {
-      "version": "18.3.5",
-      "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.5.tgz",
-      "integrity": "sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==",
-      "dev": true,
-      "license": "MIT",
-      "optional": true,
-      "peer": true,
-      "dependencies": {
-        "@types/prop-types": "*",
-        "csstype": "^3.0.2"
-      }
-    },
-    "node_modules/@types/react-dom": {
-      "version": "18.3.0",
-      "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz",
-      "integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==",
-      "dev": true,
-      "license": "MIT",
-      "optional": true,
-      "peer": true,
-      "dependencies": {
-        "@types/react": "*"
-      }
-    },
     "node_modules/@types/retry": {
       "version": "0.12.2",
       "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.2.tgz",
@@ -8461,15 +8427,6 @@
         "node": ">=14"
       }
     },
-    "node_modules/csstype": {
-      "version": "3.1.3",
-      "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
-      "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
-      "dev": true,
-      "license": "MIT",
-      "optional": true,
-      "peer": true
-    },
     "node_modules/data-urls": {
       "version": "4.0.0",
       "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-4.0.0.tgz",
```

Now, we were able to reproduce the issue faced at OBS.

## Solution

The fix is quite simple and clear: to explicitly add the `@types/react`
dev dependency. But this PR adds `@types/react-dom` too, to avoid
similar silly build issues.

## Testing

To make sure this is the right fix, below tests has been performed
against `master` branch after restoring the type checking for production
build ([`transpileOnlye: development` at webpack config
file](https://github.com/openSUSE/agama/blob/37733ab42b9f438ee7893775fd57b9cf05d392bb/web/webpack.config.js#L176)).

* `NODE_ENV=production npm run build` does not fail (because
`@types/react` dep is present)
* Remove `node_modules` and run an `npm install --legacy-peer-deps`: the
`NODE_ENV=production npm run build` fails (because `@types/react` is not
present)
* Add `@types/react` dev dep explicitly (`npm install -D @types/react`)
* Remove `node_modules` and run an `npm install --legacy-peer-deps`
again: the `NODE_ENV=production npm run build` ends successfully.

## Open questions

* Should CI been updated for using the same `npm install` flags than OBS
in an attempt to try catching these issues soon?
* A bit unrelated with this: should we try to go ahead without
`babel-loader`? It still there after start using TypeScript because

> ts-loader works very well in combination with
[babel](https://babeljs.io/) and
[babel-loader](https://github.com/babel/babel-loader).
   > 
   > https://github.com/TypeStrong/ts-loader?tab=readme-ov-file#babel

But maybe we could re-evaluate if we actually need both or could use
`ts-loader` only instead. If so, please be aware of
https://github.com/TypeStrong/ts-loader?tab=readme-ov-file#faster-builds
and https://github.com/TypeStrong/fork-ts-checker-webpack-plugin
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.

2 participants