Skip to content

Commit

Permalink
web: audit and update package.json and associated test harness, with …
Browse files Browse the repository at this point in the history
…upgrade to WebdriverIO 9 (#11596)

* Just cleaning up.

* web: removing sonarjs from yet another branch.

* web: everything except the tests are up-to-date.  There was a lot, it turns out, we simply weren't using.

* web: update package.json to support WebdriverIO 9

This commit:

- Upgrades to WebdriverIO 9.1.2
- Resets our `devDependencies` collection to remove all imports that we either were not using or
  were duplicates of existing dependencies:
  - *Babel*, of all things
  - Storybook addon css user preferences, now native to Storybook 8
  - SonarJS, *again*, sigh.
  - React

- Fixes a bug where ESLint would report missing features in our build scripts
- Fixes a bug where Wdio might not reach a headless browser before timeout
- Replaces Rollup's CSSLit with Vite's CSSLit, which actually works without hacks, for testing.
- Moves the package-lock scanner to its own script, with better reporting and tool verification,
  which also cleans up the package.lock file a little.

* Prettier just havin' all the opinions.
  • Loading branch information
kensternberg-authentik authored Oct 3, 2024
1 parent 5d65fa2 commit dec8cfb
Show file tree
Hide file tree
Showing 14 changed files with 9,562 additions and 20,008 deletions.
2 changes: 1 addition & 1 deletion web/.storybook/css-import-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const rawCssImportMaps = [
'import PFNotificationDrawer from "@patternfly/patternfly/components/NotificationDrawer/notification-drawer.css";',
'import PFPage from "@patternfly/patternfly/components/Page/page.css";',
'import PFPagination from "@patternfly/patternfly/components/Pagination/pagination.css";',
'import PFProgress from "@patternfly/patternfly/components/Progress/progress.css";',
'import PFProgressStepper from "@patternfly/patternfly/components/ProgressStepper/progress-stepper.css";',
'import PFRadio from "@patternfly/patternfly/components/Radio/radio.css";',
'import PFSelect from "@patternfly/patternfly/components/Select/select.css";',
Expand All @@ -62,7 +63,6 @@ const rawCssImportMaps = [
'import PFSwitch from "@patternfly/patternfly/components/Switch/switch.css";',
'import PFTable from "@patternfly/patternfly/components/Table/table.css";',
'import PFTabs from "@patternfly/patternfly/components/Tabs/tabs.css";',
'import PFText from "@patternfly/patternfly/utilities/Text/text.css";',
'import PFTitle from "@patternfly/patternfly/components/Title/title.css";',
'import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css";',
'import PFToolbar from "@patternfly/patternfly/components/Toolbar/toolbar.css";',
Expand Down
1 change: 0 additions & 1 deletion web/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const config: StorybookConfig = {
"@storybook/addon-controls",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@jeysal/storybook-addon-css-user-preferences",
"storybook-addon-mock",
],
staticDirs: [
Expand Down
1 change: 1 addition & 0 deletions web/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default [
},
globals: {
...globals.nodeBuiltin,
...globals.node,
},
},
files: ["scripts/*.mjs", "*.ts", "*.mjs"],
Expand Down
25,387 changes: 8,850 additions & 16,537 deletions web/package-lock.json

Large diffs are not rendered by default.

43 changes: 11 additions & 32 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@patternfly/elements": "^4.0.2",
"@patternfly/patternfly": "^4.224.2",
"@sentry/browser": "^8.32.0",
"@spotlightjs/spotlight": "^2.4.2",
"@webcomponents/webcomponentsjs": "^2.8.0",
"base64-js": "^1.5.1",
"chart.js": "^4.4.4",
Expand All @@ -41,53 +42,36 @@
"yaml": "^2.5.1"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.24.7",
"@babel/plugin-transform-private-methods": "^7.25.4",
"@babel/plugin-transform-private-property-in-object": "^7.24.7",
"@babel/plugin-transform-runtime": "^7.25.4",
"@babel/preset-env": "^7.25.4",
"@babel/preset-typescript": "^7.24.7",
"@changesets/cli": "^2.27.8",
"@custom-elements-manifest/analyzer": "^0.10.2",
"@eslint/js": "^9.11.1",
"@genesiscommunitysuccess/custom-elements-lsp": "^5.0.3",
"@hcaptcha/types": "^1.0.4",
"@jeysal/storybook-addon-css-user-preferences": "^0.2.0",
"@lit/localize-tools": "^0.8.0",
"@rollup/plugin-replace": "^6.0.1",
"@spotlightjs/spotlight": "^2.4.2",
"@storybook/addon-essentials": "^8.3.4",
"@storybook/addon-links": "^8.3.4",
"@storybook/api": "^7.6.17",
"@storybook/blocks": "^8.0.8",
"@storybook/blocks": "^8.3.4",
"@storybook/builder-vite": "^8.3.4",
"@storybook/manager-api": "^8.3.4",
"@storybook/web-components": "^8.3.4",
"@storybook/web-components-vite": "^8.3.4",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/chart.js": "^2.9.41",
"@types/codemirror": "5.60.15",
"@types/codemirror": "^5.60.15",
"@types/eslint__js": "^8.42.3",
"@types/grecaptcha": "^3.0.9",
"@types/guacamole-common-js": "1.5.2",
"@types/guacamole-common-js": "^1.5.2",
"@types/mocha": "^10.0.8",
"@types/node": "^22.7.4",
"@types/showdown": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"@wdio/browser-runner": "^9.1.2",
"@wdio/cli": "^9.1.2",
"@wdio/mocha-framework": "^9.1.2",
"@wdio/spec-reporter": "^9.1.2",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-tsconfig-paths": "^1.0.3",
"chokidar": "^4.0.1",
"cross-env": "^7.0.3",
"esbuild": "^0.24.0",
"eslint": "^9.11.1",
"eslint-plugin-lit": "^1.14.0",
"eslint-plugin-sonarjs": "^2.0.3",
"eslint-plugin-wc": "^2.1.0",
"eslint-plugin-lit": "^1.15.0",
"eslint-plugin-wc": "^2.1.1",
"github-slugger": "^2.0.0",
"glob": "^11.0.0",
"globals": "^15.10.0",
Expand All @@ -96,21 +80,16 @@
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",
"pseudolocale": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.3.1",
"rollup-plugin-modify": "^3.0.0",
"rollup-plugin-postcss-lit": "^2.1.0",
"storybook": "^8.1.11",
"storybook": "^8.3.4",
"storybook-addon-mock": "^5.0.0",
"syncpack": "^13.0.0",
"ts-lit-plugin": "^2.0.2",
"ts-node": "^10.9.2",
"tslib": "^2.7.0",
"turnstile-types": "^1.2.3",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"vite-plugin-lit-css": "^2.0.0",
"vite-tsconfig-paths": "^5.0.1",
"wdio-wait-for": "^3.0.11",
"wireit": "^0.14.9"
},
"engines": {
Expand Down Expand Up @@ -263,7 +242,7 @@
"lint:lockfile": {
"__comment": "The lockfile-lint package does not have an option to ensure resolved hashes are set everywhere",
"shell": true,
"command": "[ -z \"$(jq -r '.packages | to_entries[] | select((.key | contains(\"node_modules\")) and (.value | has(\"resolved\") | not)) | .key' < package-lock.json)\" ]"
"command": "sh ./scripts/lint-lockfile.sh package-lock.json"
},
"lint:lockfiles": {
"dependencies": [
Expand Down
67 changes: 0 additions & 67 deletions web/scripts/eslint-nightmare.mjs

This file was deleted.

94 changes: 0 additions & 94 deletions web/scripts/eslint-precommit.mjs

This file was deleted.

6 changes: 0 additions & 6 deletions web/scripts/eslint.nightmare.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import eslint from "@eslint/js";
import tsparser from "@typescript-eslint/parser";
import litconf from "eslint-plugin-lit";
import sonar from "eslint-plugin-sonarjs";
import wcconf from "eslint-plugin-wc";
import globals from "globals";
import tseslint from "typescript-eslint";

const MAX_DEPTH = 4;
const MAX_NESTED_CALLBACKS = 4;
const MAX_PARAMS = 5;
const MAX_COGNITIVE_COMPLEXITY = 9;

const rules = {
"accessor-pairs": "error",
Expand Down Expand Up @@ -128,9 +126,6 @@ const rules = {

"no-unused-vars": "off",
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
"sonarjs/cognitive-complexity": ["off", MAX_COGNITIVE_COMPLEXITY],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": [
"error",
Expand Down Expand Up @@ -167,7 +162,6 @@ export default [
wcconf.configs["flat/recommended"],
litconf.configs["flat/recommended"],
...tseslint.configs.recommended,
sonar.configs.recommended,
{
languageOptions: {
parser: tsparser,
Expand Down
5 changes: 0 additions & 5 deletions web/scripts/eslint.precommit.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import eslint from "@eslint/js";
import tsparser from "@typescript-eslint/parser";
import litconf from "eslint-plugin-lit";
import sonar from "eslint-plugin-sonarjs";
import wcconf from "eslint-plugin-wc";
import globals from "globals";
import tseslint from "typescript-eslint";
Expand Down Expand Up @@ -30,7 +29,6 @@ export default [
wcconf.configs["flat/recommended"],
litconf.configs["flat/recommended"],
...tseslint.configs.recommended,
sonar.configs.recommended,
{
languageOptions: {
parser: tsparser,
Expand All @@ -43,9 +41,6 @@ export default [
rules: {
"no-unused-vars": "off",
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
"sonarjs/cognitive-complexity": ["off", 9],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": [
"error",
Expand Down
21 changes: 21 additions & 0 deletions web/scripts/lint-lockfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

if ! command -v jq >/dev/null 2>&1 ; then
echo "This check requires the jq program be installed."
echo "To install jq, visit"
echo " https://jqlang.github.io/jq/"
exit 1
fi

CMD=$(jq -r '.packages | to_entries[] | select((.key | contains("node_modules")) and (.value | has("resolved") | not)) | .key' < "$1")

if [ -n "$CMD" ]; then
echo "ERROR package-lock.json entries missing 'resolved' field:"
echo ""
# Shellcheck erroneously believes that shell string substitution can be used here, but that
# feature lacks a "start of line" discriminator.
# shellcheck disable=SC2001
echo "$CMD" | sed 's/^/ /g'
echo ""
exit 1
fi
Loading

0 comments on commit dec8cfb

Please sign in to comment.