Skip to content

Commit

Permalink
Merge pull request #1088 from marekdedic/strict-tsconfig
Browse files Browse the repository at this point in the history
Stricter tsconfig
  • Loading branch information
marekdedic authored Sep 13, 2024
2 parents 9c4babd + 6b132a4 commit b0b4aea
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ document
linkContainer.appendChild(newLi);

const newAnchor = document.createElement("a");
newAnchor.dataset.imagelightbox = "i";
newAnchor.dataset["imagelightbox"] = "i";
newAnchor.href = "images/demo4.jpg";
newLi.appendChild(newAnchor);

Expand Down
4 changes: 2 additions & 2 deletions src/lib/ImageView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export function ImageView(
containerElement.classList.add("ilb-image-container");
let isVideoPreloaded: boolean | undefined = undefined;

const isVideo = image.dataset.ilb2Video !== undefined;
const isVideo = image.dataset["ilb2Video"] !== undefined;
if (isVideo) {
[imageElement, isVideoPreloaded] = videoCache.element(
image.dataset.ilb2VideoId!,
image.dataset["ilb2VideoId"]!,
);
}
containerElement.appendChild(imageElement);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/PreloadedVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ export function PreloadedVideo(
image: HTMLAnchorElement,
videoOptions: VideoOptions,
): PreloadedVideo {
let tempId = image.dataset.ilb2Id;
let tempId = image.dataset["ilb2Id"];
if (tempId === undefined) {
// Random id
tempId = `a${(((1 + Math.random()) * 0x10000) | 0).toString(16)}`;
}
image.dataset.ilb2VideoId = tempId;
image.dataset["ilb2VideoId"] = tempId;
const videoId = tempId;

const videoElement = document.createElement("video");
videoElement.setAttribute("id", "ilb-image");
videoElement.preload = "metadata";
videoElement.dataset.ilb2VideoId = videoId;
videoElement.dataset["ilb2VideoId"] = videoId;
let isLoaded = false;
let autoplay = false;
let height: number | undefined = undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function State(
const image = targetImages[currentImage!];
if (options.caption) {
setCaption(
image.dataset.ilb2Caption ??
image.dataset["ilb2Caption"] ??
image.getElementsByTagName("img").item(0)?.alt ??
"",
options.animationSpeed,
Expand Down Expand Up @@ -283,7 +283,7 @@ export function State(
(element): boolean =>
element.tagName.toLowerCase() === "a" &&
(new RegExp(`.(${options.allowedTypes})$`, "i").test(element.href) ||
element.dataset.ilb2Video !== undefined),
element.dataset["ilb2Video"] !== undefined),
);
videoCache.add(validImages);
targetImages.push(...validImages);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/VideoCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function VideoCache(): VideoCache {

function add(elements: Array<HTMLAnchorElement>): void {
for (const image of elements) {
const videoOptions = image.dataset.ilb2Video;
const videoOptions = image.dataset["ilb2Video"];
if (videoOptions === undefined) {
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function pushToHistory(
set: string | undefined,
images: Array<HTMLAnchorElement>,
): void {
const newIndex = images[index].dataset.ilb2Id ?? index.toString();
const newIndex = images[index].dataset["ilb2Id"] ?? index.toString();
let newQuery = addQueryField(
document.location.search,
"imageLightboxIndex",
Expand Down Expand Up @@ -53,7 +53,7 @@ export function openHistory(
if (id === undefined) {
return;
}
let newIndex = images.findIndex((image) => image.dataset.ilb2Id === id);
let newIndex = images.findIndex((image) => image.dataset["ilb2Id"] === id);
if (newIndex < 0) {
newIndex = parseInt(id, 10);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ export function popHistory(
return;
}
let newIndex = images.findIndex(
(e: HTMLElement) => e.dataset.ilb2Id === newId,
(e: HTMLElement) => e.dataset["ilb2Id"] === newId,
);
if (newIndex < 0) {
newIndex = parseInt(newId, 10);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/imagelightbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ImageLightbox {
};
this.s = State(
opts,
images.length > 0 ? (images[0].dataset.imagelightbox ?? "") : "",
images.length > 0 ? (images[0].dataset["imagelightbox"] ?? "") : "",
Array.from(images),
);

Expand Down
13 changes: 10 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{
"compilerOptions": {
"module": "es6",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": "es6",
"moduleResolution": "node",

"skipLibCheck": true,

"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"skipLibCheck": true,
"strict": true
}
}

0 comments on commit b0b4aea

Please sign in to comment.