From 4db78a847ddf06ac2330ac1f4121c6446b7f5253 Mon Sep 17 00:00:00 2001 From: Cora Grant Date: Fri, 20 Dec 2024 12:58:44 -0500 Subject: [PATCH] deps: update to TypeScript 5 The ESLint plugin now catches a few more errors; fix those too. --- assets/jest.config.js | 2 +- assets/package-lock.json | 258 ++++++++++++++++-- assets/package.json | 4 +- assets/src/apps/admin.tsx | 2 +- assets/src/apps/v2/bus_eink.tsx | 2 +- assets/src/apps/v2/bus_shelter.tsx | 2 +- assets/src/apps/v2/busway.tsx | 2 +- assets/src/apps/v2/dup.tsx | 2 +- assets/src/apps/v2/elevator.tsx | 2 +- assets/src/apps/v2/gl_eink.tsx | 2 +- assets/src/apps/v2/pre_fare.tsx | 2 +- assets/src/components/admin/inspector.tsx | 2 +- .../v2/eink/overnight_departures.tsx | 4 +- assets/tsconfig.json | 2 +- assets/webpack.config.js | 2 +- 15 files changed, 257 insertions(+), 33 deletions(-) diff --git a/assets/jest.config.js b/assets/jest.config.js index 3dbe742a6..6f2a452f8 100644 --- a/assets/jest.config.js +++ b/assets/jest.config.js @@ -1,6 +1,6 @@ // https://jestjs.io/docs/configuration -/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable @typescript-eslint/no-require-imports */ /* global require, module */ const requireJSON5 = require("require-json5"); diff --git a/assets/package-lock.json b/assets/package-lock.json index a3e21d2ce..f7e8fd731 100644 --- a/assets/package-lock.json +++ b/assets/package-lock.json @@ -70,8 +70,8 @@ "terser-webpack-plugin": "^4.2.3", "ts-jest": "^29.1.2", "ts-loader": "^8.3.0", - "typescript": "^4.3.5", - "typescript-eslint": "^7.8.0", + "typescript": "^5.7.2", + "typescript-eslint": "^8.18.1", "webpack": "^4.46.0", "webpack-cli": "^4.7.2", "whatwg-fetch": "^3.6.20" @@ -4520,6 +4520,8 @@ "version": "7.8.0", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "7.8.0", @@ -4554,6 +4556,8 @@ "version": "7.6.0", "dev": true, "license": "ISC", + "optional": true, + "peer": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -4568,6 +4572,8 @@ "version": "7.8.0", "dev": true, "license": "BSD-2-Clause", + "optional": true, + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "7.8.0", "@typescript-eslint/types": "7.8.0", @@ -4611,6 +4617,8 @@ "version": "7.8.0", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@typescript-eslint/typescript-estree": "7.8.0", "@typescript-eslint/utils": "7.8.0", @@ -15801,40 +15809,258 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "4.9.5", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, - "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/typescript-eslint": { - "version": "7.8.0", + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.1.tgz", + "integrity": "sha512-Mlaw6yxuaDEPQvb/2Qwu3/TfgeBHy9iTJ3mTwe7OvpPmF6KPQjVOfGyEJpPv6Ez2C34OODChhXrzYw/9phI0MQ==", "dev": true, - "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "7.8.0", - "@typescript-eslint/parser": "7.8.0", - "@typescript-eslint/utils": "7.8.0" + "@typescript-eslint/eslint-plugin": "8.18.1", + "@typescript-eslint/parser": "8.18.1", + "@typescript-eslint/utils": "8.18.1" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^8.56.0" + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.1.tgz", + "integrity": "sha512-Ncvsq5CT3Gvh+uJG0Lwlho6suwDfUXH0HztslDf5I+F2wAFAZMRwYLEorumpKLzmO2suAXZ/td1tBg4NZIi9CQ==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.18.1", + "@typescript-eslint/type-utils": "8.18.1", + "@typescript-eslint/utils": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/parser": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.1.tgz", + "integrity": "sha512-rBnTWHCdbYM2lh7hjyXqxk70wvon3p2FyaniZuey5TrcGBpfhVp0OxOa6gxr9Q9YhZFKyfbEnxc24ZnVbbUkCA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "8.18.1", + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/typescript-estree": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/scope-manager": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.1.tgz", + "integrity": "sha512-HxfHo2b090M5s2+/9Z3gkBhI6xBH8OJCFjH9MhQ+nnoZqxU3wNxkLT+VWXWSFWc3UF3Z+CfPAyqdCTdoXtDPCQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/type-utils": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.1.tgz", + "integrity": "sha512-jAhTdK/Qx2NJPNOTxXpMwlOiSymtR2j283TtPqXkKBdH8OAMmhiUfP0kJjc/qSE51Xrq02Gj9NY7MwK+UxVwHQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "8.18.1", + "@typescript-eslint/utils": "8.18.1", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/types": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.1.tgz", + "integrity": "sha512-7uoAUsCj66qdNQNpH2G8MyTFlgerum8ubf21s3TSM3XmKXuIn+H2Sifh/ES2nPOPiYSRJWAk0fDkW0APBWcpfw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.1.tgz", + "integrity": "sha512-z8U21WI5txzl2XYOW7i9hJhxoKKNG1kcU4RzyNvKrdZDmbjkmLBo8bgeiOJmA06kizLI76/CCBAAGlTlEeUfyg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/utils": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.1.tgz", + "integrity": "sha512-8vikiIj2ebrC4WRdcAdDcmnu9Q/MXXwg+STf40BVfT8exDqBCUPdypvzcUPxEqRGKg9ALagZ0UWcYCtn+4W2iQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.18.1", + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/typescript-estree": "8.18.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.1.tgz", + "integrity": "sha512-Vj0WLm5/ZsD013YeUKn+K0y8p1M0jPpxOkKdbD1wB0ns53a5piVY02zjf072TblEweAbcYiFiPoSMF3kp+VhhQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.18.1", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/typescript-eslint/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typescript-eslint/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/typescript-eslint/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/typescript-eslint/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/unbox-primitive": { diff --git a/assets/package.json b/assets/package.json index e2372b20d..0d5161d22 100644 --- a/assets/package.json +++ b/assets/package.json @@ -82,8 +82,8 @@ "terser-webpack-plugin": "^4.2.3", "ts-jest": "^29.1.2", "ts-loader": "^8.3.0", - "typescript": "^4.3.5", - "typescript-eslint": "^7.8.0", + "typescript": "^5.7.2", + "typescript-eslint": "^8.18.1", "webpack": "^4.46.0", "webpack-cli": "^4.7.2", "whatwg-fetch": "^3.6.20" diff --git a/assets/src/apps/admin.tsx b/assets/src/apps/admin.tsx index 06a9f91d8..f2038ae08 100644 --- a/assets/src/apps/admin.tsx +++ b/assets/src/apps/admin.tsx @@ -1,4 +1,4 @@ -require("../../css/admin.scss"); +import "../../css/admin.scss"; import React, { ComponentType } from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/bus_eink.tsx b/assets/src/apps/v2/bus_eink.tsx index 8c5f8e30c..9dd78525d 100644 --- a/assets/src/apps/v2/bus_eink.tsx +++ b/assets/src/apps/v2/bus_eink.tsx @@ -4,7 +4,7 @@ initSentry("bus_eink_v2"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/bus_eink_v2.scss"); +import "../../../css/bus_eink_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/bus_shelter.tsx b/assets/src/apps/v2/bus_shelter.tsx index f3ee9f739..d825e6afc 100644 --- a/assets/src/apps/v2/bus_shelter.tsx +++ b/assets/src/apps/v2/bus_shelter.tsx @@ -4,7 +4,7 @@ initSentry("bus_shelter"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/bus_shelter_v2.scss"); +import "../../../css/bus_shelter_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/busway.tsx b/assets/src/apps/v2/busway.tsx index 19c56e991..000f3bcfa 100644 --- a/assets/src/apps/v2/busway.tsx +++ b/assets/src/apps/v2/busway.tsx @@ -4,7 +4,7 @@ initSentry("busway_v2"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/busway_v2.scss"); +import "../../../css/busway_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/dup.tsx b/assets/src/apps/v2/dup.tsx index bda667488..59ab2f2ed 100644 --- a/assets/src/apps/v2/dup.tsx +++ b/assets/src/apps/v2/dup.tsx @@ -4,7 +4,7 @@ initSentry("dup_v2"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/dup_v2.scss"); +import "../../../css/dup_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/elevator.tsx b/assets/src/apps/v2/elevator.tsx index b30ae34c6..cbe1b3583 100644 --- a/assets/src/apps/v2/elevator.tsx +++ b/assets/src/apps/v2/elevator.tsx @@ -4,7 +4,7 @@ initSentry("elevator"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/elevator_v2.scss"); +import "../../../css/elevator_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/gl_eink.tsx b/assets/src/apps/v2/gl_eink.tsx index 643bc850c..5810d27b5 100644 --- a/assets/src/apps/v2/gl_eink.tsx +++ b/assets/src/apps/v2/gl_eink.tsx @@ -4,7 +4,7 @@ initSentry("gl_eink_v2"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/gl_eink_v2.scss"); +import "../../../css/gl_eink_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/apps/v2/pre_fare.tsx b/assets/src/apps/v2/pre_fare.tsx index eff2567e0..d68c08bd9 100644 --- a/assets/src/apps/v2/pre_fare.tsx +++ b/assets/src/apps/v2/pre_fare.tsx @@ -4,7 +4,7 @@ initSentry("pre_fare"); import initFullstory from "Util/fullstory"; initFullstory(); -require("../../../css/pre_fare_v2.scss"); +import "../../../css/pre_fare_v2.scss"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/assets/src/components/admin/inspector.tsx b/assets/src/components/admin/inspector.tsx index aa2fb9567..f2f2c93fc 100644 --- a/assets/src/components/admin/inspector.tsx +++ b/assets/src/components/admin/inspector.tsx @@ -67,7 +67,7 @@ const Inspector: ComponentType = () => { const sendToFrame = (message: Message) => { const frameWindow = frameRef.current?.contentWindow; - frameWindow && sendMessage(frameWindow, message); + if (frameWindow) sendMessage(frameWindow, message); }; const [zoom, setZoom] = useState(1.0); diff --git a/assets/src/components/v2/eink/overnight_departures.tsx b/assets/src/components/v2/eink/overnight_departures.tsx index c68f3387b..368c5ec11 100644 --- a/assets/src/components/v2/eink/overnight_departures.tsx +++ b/assets/src/components/v2/eink/overnight_departures.tsx @@ -2,9 +2,7 @@ import moment from "moment"; import React, { ComponentType } from "react"; import { imagePath } from "Util/util"; -interface Props {} - -const OvernightDepartures: ComponentType = () => { +const OvernightDepartures: ComponentType = () => { const currentTime = moment().tz("America/New_York").format("h:mm"); return ( diff --git a/assets/tsconfig.json b/assets/tsconfig.json index 8b6156bd5..9aa1ac876 100644 --- a/assets/tsconfig.json +++ b/assets/tsconfig.json @@ -3,7 +3,7 @@ "exclude": ["node_modules"], "compilerOptions": { /* Basic Options */ - "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, + "target": "es2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, "module": "es2015" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, "lib": [ "dom", diff --git a/assets/webpack.config.js b/assets/webpack.config.js index f2c7f6da2..d04e7066e 100644 --- a/assets/webpack.config.js +++ b/assets/webpack.config.js @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable @typescript-eslint/no-require-imports */ /* global require, module, __dirname */ const path = require("path");