diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1df67008..d60b79d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: npx @biomejs/biome check . - name: Set up cargo cache uses: Swatinem/rust-cache@378c8285a4eaf12899d11bea686a763e906956af - run: cargo fmt --all -- --check diff --git a/sqlpage/apexcharts.js b/sqlpage/apexcharts.js index bb30b054..2e616186 100644 --- a/sqlpage/apexcharts.js +++ b/sqlpage/apexcharts.js @@ -1,6 +1,6 @@ /* !include https://cdn.jsdelivr.net/npm/apexcharts@4.0.0/dist/apexcharts.min.js */ -sqlpage_chart = (function () { +sqlpage_chart = (() => { function sqlpage_chart() { for (const c of document.querySelectorAll("[data-pre-init=chart]")) { @@ -160,7 +160,7 @@ sqlpage_chart = (function () { fillSeriesColor: false, custom: (data.type === 'bubble' || data.type === 'scatter') ? bubbleTooltip : undefined, y: { - formatter: function (value) { + formatter: (value) => { if (is_timeseries && data.type === 'rangeBar') { const d = new Date(value); if (d.getHours() === 0 && d.getMinutes() === 0) return d.toLocaleDateString(); diff --git a/sqlpage/sqlpage.js b/sqlpage/sqlpage.js index 039ea256..289644d6 100644 --- a/sqlpage/sqlpage.js +++ b/sqlpage/sqlpage.js @@ -32,7 +32,7 @@ function table_search_sort(el) { el, sort_keys: sort_buttons.map(b => { const sort_key = el.getElementsByClassName(b.dataset.sort)[0]?.textContent; - return { num: parseFloat(sort_key), str: sort_key }; + return { num: Number.parseFloat(sort_key), str: sort_key }; }) })); function onSearch() { @@ -96,7 +96,7 @@ function sqlpage_map() { onLeafletLoad(); } function parseCoords(coords) { - return coords && coords.split(",").map(c => parseFloat(c)); + return coords && coords.split(",").map(c => Number.parseFloat(c)); } function onLeafletLoad() { is_leaflet_loaded = true; @@ -107,7 +107,7 @@ function sqlpage_map() { const attribution = m.dataset.attribution; const map = L.map(m, { attributionControl: !!attribution }); const zoom = m.dataset.zoom; - let center = parseCoords(m.dataset.center); + const center = parseCoords(m.dataset.center); if (tile_source) L.tileLayer(tile_source, { attribution, maxZoom }).addTo(map); map._sqlpage_markers = []; for (const marker_elem of m.getElementsByClassName("marker")) { @@ -155,7 +155,7 @@ function sqlpage_map() { return L.marker(coords, options); } function createGeoJSONMarker(marker_elem, options) { - let geojson = JSON.parse(marker_elem.dataset.geojson); + const geojson = JSON.parse(marker_elem.dataset.geojson); if (options.color) { options.color = get_tabler_color(options.color) || options.color; } @@ -193,7 +193,7 @@ function get_tabler_color(name) { } function load_scripts() { - let addjs = document.querySelectorAll("[data-sqlpage-js]"); + const addjs = document.querySelectorAll("[data-sqlpage-js]"); const existing_scripts = new Set([...document.querySelectorAll("script")].map(s => s.src)); for (const el of addjs) { const js = new URL(el.dataset.sqlpageJs, window.location.href).href; diff --git a/tests/end-to-end/official-site.spec.ts b/tests/end-to-end/official-site.spec.ts index d5c3c6e9..89e5406c 100644 --- a/tests/end-to-end/official-site.spec.ts +++ b/tests/end-to-end/official-site.spec.ts @@ -99,21 +99,21 @@ test('table sorting', async ({ page }) => { // Test numeric sorting on id column await tableSection.getByRole('button', { name: 'id' }).click(); let ids = await tableSection.locator('td.id').allInnerTexts(); - let numericIds = ids.map(id => parseInt(id)); + let numericIds = ids.map(id => Number.parseInt(id)); const sortedIds = [...numericIds].sort((a, b) => a - b); expect(numericIds).toEqual(sortedIds); // Test reverse sorting await tableSection.getByRole('button', { name: 'id' }).click(); ids = await tableSection.locator('td.id').allInnerTexts(); - numericIds = ids.map(id => parseInt(id)); + numericIds = ids.map(id => Number.parseInt(id)); const reverseSortedIds = [...numericIds].sort((a, b) => b - a); expect(numericIds).toEqual(reverseSortedIds); // Test amount in stock column sorting await tableSection.getByRole('button', { name: 'Amount in stock' }).click(); - let amounts = await tableSection.locator('td.Amount').allInnerTexts(); - let numericAmounts = amounts.map(amount => parseInt(amount)); + const amounts = await tableSection.locator('td.Amount').allInnerTexts(); + const numericAmounts = amounts.map(amount => Number.parseInt(amount)); const sortedAmounts = [...numericAmounts].sort((a, b) => a - b); expect(numericAmounts).toEqual(sortedAmounts); });