Add eslint and prettier to frontend

And format files
This commit is contained in:
2023-09-01 01:05:06 -04:00
parent 1d6f98c6bb
commit ac12ca0fd9
8 changed files with 59 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
// import CSS so it gets named with a content hash that busts caches
import "../css/styles.css";
import '../css/styles.css';
import "./localTimeController";
import './localTimeController';

View File

@@ -1,24 +1,30 @@
function convertTimeElements() {
function convertTimeElements(): void {
const timeElements = document.querySelectorAll('time.local-time');
timeElements.forEach((element) => {
const utcString = element.getAttribute("datetime");
if (utcString) {
const utcString = element.getAttribute('datetime');
if (utcString !== null) {
const utcTime = new Date(utcString);
element.textContent = utcTime.toLocaleDateString(window.navigator.language, {
year: "numeric",
month: "long",
day: "numeric",
});
element.textContent = utcTime.toLocaleDateString(
window.navigator.language,
{
year: 'numeric',
month: 'long',
day: 'numeric',
}
);
} else {
console.error("Missing datetime attribute on time.local-time element", element);
console.error(
'Missing datetime attribute on time.local-time element',
element
);
}
});
}
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener('DOMContentLoaded', function () {
convertTimeElements();
});
document.body.addEventListener('htmx:afterSwap', function() {
document.body.addEventListener('htmx:afterSwap', function () {
convertTimeElements();
});