From 797c5f551b1bb6ddb139704eb9e8953c3bc1a8c8 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:59:43 +0100 Subject: Fix build errors & lint a bit --- .gitignore | 4 ++++ eslint.config.js | 28 ---------------------------- eslint.config.ts | 28 ++++++++++++++++++++++++++++ package-lock.json | 37 +++++++++++++++++++++++++++++++++---- package.json | 4 +++- src/pages/Estimates.tsx | 24 +++++++++++++----------- src/pages/Map.tsx | 10 ++++------ tsconfig.app.tsbuildinfo | 1 + tsconfig.node.tsbuildinfo | 1 + 9 files changed, 87 insertions(+), 50 deletions(-) delete mode 100644 eslint.config.js create mode 100644 eslint.config.ts create mode 100644 tsconfig.app.tsbuildinfo create mode 100644 tsconfig.node.tsbuildinfo diff --git a/.gitignore b/.gitignore index 9b862f1..f71b400 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Typescript incremental build +.tsbuildinfo +*.tsbuildinfo + # Logs logs *.log diff --git a/eslint.config.js b/eslint.config.js deleted file mode 100644 index 092408a..0000000 --- a/eslint.config.js +++ /dev/null @@ -1,28 +0,0 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' - -export default tseslint.config( - { ignores: ['dist'] }, - { - extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - }, - plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, - }, -) diff --git a/eslint.config.ts b/eslint.config.ts new file mode 100644 index 0000000..092408a --- /dev/null +++ b/eslint.config.ts @@ -0,0 +1,28 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, + }, +) diff --git a/package-lock.json b/package-lock.json index 81fe11b..50040cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,8 @@ }, "devDependencies": { "@eslint/js": "^9.9.0", - "@types/node": "^22.13.8", + "@types/leaflet": "^1.9.16", + "@types/node": "^22.13.9", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "@vitejs/plugin-react-swc": "^3.8.0", @@ -27,6 +28,7 @@ "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.19", "globals": "^15.15.0", + "jiti": "^2.4.2", "typescript": "^5.7.3", "typescript-eslint": "^8.25.0", "vite": "^6.2.0" @@ -1220,6 +1222,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1227,10 +1236,20 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/leaflet": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.16.tgz", + "integrity": "sha512-wzZoyySUxkgMZ0ihJ7IaUIblG8Rdc8AbbZKLneyn+QjYsj5q1QU7TEKYqwTr10BGSzY5LI7tJk9Ifo+mEjdFRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/node": { - "version": "22.13.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.8.tgz", - "integrity": "sha512-G3EfaZS+iOGYWLLRCEAXdWK9my08oHNZ+FHluRiggIYJPOXzhOiDgpVCUHaUvyIC5/fj7C/p637jdzC666AOKQ==", + "version": "22.13.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.9.tgz", + "integrity": "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw==", "dev": true, "license": "MIT", "dependencies": { @@ -2180,6 +2199,16 @@ "dev": true, "license": "ISC" }, + "node_modules/jiti": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", + "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", diff --git a/package.json b/package.json index 37765a7..8f7258f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ }, "devDependencies": { "@eslint/js": "^9.9.0", - "@types/node": "^22.13.8", + "@types/leaflet": "^1.9.16", + "@types/node": "^22.13.9", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "@vitejs/plugin-react-swc": "^3.8.0", @@ -32,6 +33,7 @@ "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.19", "globals": "^15.15.0", + "jiti": "^2.4.2", "typescript": "^5.7.3", "typescript-eslint": "^8.25.0", "vite": "^6.2.0" diff --git a/src/pages/Estimates.tsx b/src/pages/Estimates.tsx index 3f002be..a445300 100644 --- a/src/pages/Estimates.tsx +++ b/src/pages/Estimates.tsx @@ -1,5 +1,5 @@ -import { useEffect, useState } from "react"; -import { Link, useParams } from "react-router"; +import { JSX, useEffect, useState } from "react"; +import { useParams } from "react-router"; import { StopDataProvider } from "../data/StopDataProvider"; import LineIcon from "../components/LineIcon"; import { Star } from 'lucide-react'; @@ -20,31 +20,33 @@ interface StopDetails { }[] } +const sdp = new StopDataProvider(); + +const loadData = async (stopId: string) => { + const resp = await fetch(`/api/GetStopEstimates?id=${stopId}`); + return await resp.json(); +}; + export function Estimates(): JSX.Element { - const sdp = new StopDataProvider(); const [data, setData] = useState(null); const [dataDate, setDataDate] = useState(null); const [favourited, setFavourited] = useState(false); const params = useParams(); - const loadData = () => { - fetch(`/api/GetStopEstimates?id=${params.stopId}`) - .then(r => r.json()) + useEffect(() => { + loadData(params.stopId!) .then((body: StopDetails) => { setData(body); setDataDate(new Date()); - }); - }; + }) - useEffect(() => { - loadData(); sdp.pushRecent(parseInt(params.stopId ?? "")); setFavourited( sdp.isFavourite(parseInt(params.stopId ?? "")) ); - }, []); + }, [params.stopId]); const absoluteArrivalTime = (minutes: number) => { const now = new Date() diff --git a/src/pages/Map.tsx b/src/pages/Map.tsx index 4d89ae0..9b960be 100644 --- a/src/pages/Map.tsx +++ b/src/pages/Map.tsx @@ -6,17 +6,15 @@ import 'react-leaflet-markercluster/styles' import { useEffect, useState } from 'react'; import LineIcon from '../components/LineIcon'; import { Link } from 'react-router'; -import { MapContainer } from "react-leaflet/MapContainer"; -import { TileLayer } from "react-leaflet/TileLayer"; -import { Marker } from "react-leaflet/Marker"; -import { Popup } from "react-leaflet/Popup"; +import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet"; import MarkerClusterGroup from "react-leaflet-markercluster"; +import { LatLngTuple } from "leaflet"; const sdp = new StopDataProvider(); export function StopMap() { const [stops, setStops] = useState([]); - const position = [42.229188855975046, -8.72246955783102] + const position: LatLngTuple = [42.229188855975046, -8.72246955783102] useEffect(() => { sdp.getStops().then((stops) => { setStops(stops); }); @@ -30,7 +28,7 @@ export function StopMap() { /> {stops.map((stop) => ( - + {stop.name}
diff --git a/tsconfig.app.tsbuildinfo b/tsconfig.app.tsbuildinfo new file mode 100644 index 0000000..e324880 --- /dev/null +++ b/tsconfig.app.tsbuildinfo @@ -0,0 +1 @@ +{"root":["./src/layout.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/components/lineicon.tsx","./src/components/stopitem.tsx","./src/data/stopdataprovider.ts","./src/pages/about.tsx","./src/pages/estimates.tsx","./src/pages/map.tsx","./src/pages/stoplist.tsx"],"version":"5.7.3"} \ No newline at end of file diff --git a/tsconfig.node.tsbuildinfo b/tsconfig.node.tsbuildinfo new file mode 100644 index 0000000..0440098 --- /dev/null +++ b/tsconfig.node.tsbuildinfo @@ -0,0 +1 @@ +{"root":["./vite.config.ts"],"version":"5.7.3"} \ No newline at end of file -- cgit v1.3