Skip to content

Commit

Permalink
add linting and formatting in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Nov 5, 2024
1 parent f82bfbc commit ebf19aa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sqlpage/apexcharts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* !include https://cdn.jsdelivr.net/npm/[email protected]/dist/apexcharts.min.js */

sqlpage_chart = (function () {
sqlpage_chart = (() => {

function sqlpage_chart() {
for (const c of document.querySelectorAll("[data-pre-init=chart]")) {
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions sqlpage/sqlpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand All @@ -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")) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions tests/end-to-end/official-site.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit ebf19aa

Please sign in to comment.