diff --git a/eslint.config.js b/eslint.config.js index 7c1985c6..c89ebca8 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,6 @@ -import js from "@eslint/js"; import eslintComments from "@eslint-community/eslint-plugin-eslint-comments"; import commentsConfig from "@eslint-community/eslint-plugin-eslint-comments/configs"; +import js from "@eslint/js"; import compat from "eslint-plugin-compat"; import perfectionist from "eslint-plugin-perfectionist"; import playwright from "eslint-plugin-playwright"; @@ -80,7 +80,10 @@ export default tseslint.config( "error", "@typescript-eslint/no-unnecessary-qualifier": "error", "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/no-use-before-define": "error", + "@typescript-eslint/no-use-before-define": [ + "error", + { functions: false }, + ], "@typescript-eslint/no-useless-empty-export": "error", "@typescript-eslint/parameter-properties": "error", "@typescript-eslint/prefer-enum-initializers": "error", diff --git a/package-lock.json b/package-lock.json index f4e21af9..0e9cf508 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "eslint": "^9.9.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-compat": "^6.0.0", - "eslint-plugin-perfectionist": "^3.2.0", + "eslint-plugin-perfectionist": "^4.0.3", "eslint-plugin-playwright": "^2.0.0", "eslint-plugin-prefer-arrow-functions": "^3.4.0", "eslint-plugin-prettier": "^5.2.1", @@ -3204,47 +3204,129 @@ } }, "node_modules/eslint-plugin-perfectionist": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-3.9.1.tgz", - "integrity": "sha512-9WRzf6XaAxF4Oi5t/3TqKP5zUjERhasHmLFHin2Yw6ZAp/EP/EVA2dr3BhQrrHWCm5SzTMZf0FcjDnBkO2xFkA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-4.0.3.tgz", + "integrity": "sha512-CyafnreF6boy4lf1XaF72U8NbkwrfjU/mOf1y6doaDMS9zGXhUU1DSk+ZPf/rVwCf1PL1m+rhHqFs+IcB8kDmA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "^8.9.0", - "@typescript-eslint/utils": "^8.9.0", - "minimatch": "^9.0.5", - "natural-compare-lite": "^1.4.0" + "@typescript-eslint/types": "^8.15.0", + "@typescript-eslint/utils": "^8.15.0", + "natural-orderby": "^5.0.0" }, "engines": { "node": "^18.0.0 || >=20.0.0" }, "peerDependencies": { - "astro-eslint-parser": "^1.0.2", - "eslint": ">=8.0.0", - "svelte": ">=3.0.0", - "svelte-eslint-parser": "^0.41.1", - "vue-eslint-parser": ">=9.0.0" + "eslint": ">=8.0.0" + } + }, + "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/scope-manager": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.15.0.tgz", + "integrity": "sha512-QRGy8ADi4J7ii95xz4UoiymmmMd/zuy9azCaamnZ3FM8T5fZcex8UfJcjkiEZjJSztKfEBe3dZ5T/5RHAmw2mA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.15.0", + "@typescript-eslint/visitor-keys": "8.15.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/types": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.15.0.tgz", + "integrity": "sha512-n3Gt8Y/KyJNe0S3yDCD2RVKrHBC4gTUcLTebVBXacPy091E6tNspFLKRXlk3hwT4G55nfr1n2AdFqi/XMxzmPQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.15.0.tgz", + "integrity": "sha512-1eMp2JgNec/niZsR7ioFBlsh/Fk0oJbhaqO0jRyQBMgkz7RrFfkqF9lYYmBoGBaSiLnu8TAPQTwoTUiSTUW9dg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.15.0", + "@typescript-eslint/visitor-keys": "8.15.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" }, "peerDependenciesMeta": { - "astro-eslint-parser": { - "optional": true - }, - "svelte": { - "optional": true - }, - "svelte-eslint-parser": { + "typescript": { "optional": true - }, - "vue-eslint-parser": { + } + } + }, + "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/utils": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.15.0.tgz", + "integrity": "sha512-k82RI9yGhr0QM3Dnq+egEpz9qB6Un+WLYhmoNcvl8ltMEededhh7otBVVIDDsEEttauwdY/hQoSsOv13lxrFzQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.15.0", + "@typescript-eslint/types": "8.15.0", + "@typescript-eslint/typescript-estree": "8.15.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { "optional": true } } }, + "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.15.0.tgz", + "integrity": "sha512-h8vYOulWec9LhpwfAdZf2bjr8xIp0KNKnpgqSz0qqYYKAW/QZKw3ktRndbiAtUz4acH4QLQavwZBYCc0wulA/Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.15.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/eslint-plugin-perfectionist/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } @@ -3254,7 +3336,6 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, - "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -5071,12 +5152,14 @@ "dev": true, "license": "MIT" }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "node_modules/natural-orderby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/natural-orderby/-/natural-orderby-5.0.0.tgz", + "integrity": "sha512-kKHJhxwpR/Okycz4HhQKKlhWe4ASEfPgkSWNmKFHd7+ezuQlxkA5cM3+XkBPvm1gmHen3w53qsYAv+8GwRrBlg==", "dev": true, - "license": "MIT" + "engines": { + "node": ">=18" + } }, "node_modules/nice-try": { "version": "1.0.5", diff --git a/package.json b/package.json index 50434e30..5962bda8 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "eslint": "^9.9.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-compat": "^6.0.0", - "eslint-plugin-perfectionist": "^3.2.0", + "eslint-plugin-perfectionist": "^4.0.3", "eslint-plugin-playwright": "^2.0.0", "eslint-plugin-prefer-arrow-functions": "^3.4.0", "eslint-plugin-prettier": "^5.2.1", diff --git a/src/lib/State.ts b/src/lib/State.ts index 015d43a7..c2af8094 100644 --- a/src/lib/State.ts +++ b/src/lib/State.ts @@ -105,11 +105,9 @@ export function State( function transitionInNewImage(): void { currentImageView?.transitionIn( removeActivityIndicatorFromDOM, - /* eslint-disable @typescript-eslint/no-use-before-define -- Cyclical dependencies */ previous, next, close, - /* eslint-enable */ ); } diff --git a/src/lib/container.ts b/src/lib/container.ts index e9def7e8..f13ee992 100644 --- a/src/lib/container.ts +++ b/src/lib/container.ts @@ -31,8 +31,8 @@ export function darkenOverlay(): void { container.classList.add("ilb-overlay"); } -export function transitionOutContainer(): void { - container.style.opacity = "0"; +export function getContainer(): HTMLDivElement { + return container; } export function removeContainerFromDOM(): void { @@ -45,6 +45,6 @@ export function removeContainerFromDOM(): void { document.body.classList.remove("ilb-body"); } -export function getContainer(): HTMLDivElement { - return container; +export function transitionOutContainer(): void { + container.style.opacity = "0"; } diff --git a/src/lib/history.ts b/src/lib/history.ts index dd2f0368..f7f594e8 100644 --- a/src/lib/history.ts +++ b/src/lib/history.ts @@ -6,41 +6,6 @@ interface HistoryState { imageLightboxSet?: string; } -export function pushQuitToHistory(): void { - let newQuery = removeQueryField( - document.location.search, - "imageLightboxIndex", - ); - newQuery = removeQueryField(newQuery, "imageLightboxSet"); - window.history.pushState({}, "", document.location.pathname + newQuery); -} - -export function pushToHistory( - index: number, - set: string | undefined, - images: Array, -): void { - const newIndex = images[index].dataset["ilb2Id"] ?? index.toString(); - let newQuery = addQueryField( - document.location.search, - "imageLightboxIndex", - newIndex, - ); - const newHistoryState: HistoryState = { - imageLightboxIndex: newIndex, - imageLightboxSet: "", - }; - if (set !== undefined) { - newHistoryState.imageLightboxSet = set; - newQuery = addQueryField(newQuery, "imageLightboxSet", set); - } - window.history.pushState( - newHistoryState, - "", - document.location.pathname + newQuery, - ); -} - export function openHistory( set: string | undefined, images: Array, @@ -109,3 +74,38 @@ export function popHistory( true, ); } + +export function pushQuitToHistory(): void { + let newQuery = removeQueryField( + document.location.search, + "imageLightboxIndex", + ); + newQuery = removeQueryField(newQuery, "imageLightboxSet"); + window.history.pushState({}, "", document.location.pathname + newQuery); +} + +export function pushToHistory( + index: number, + set: string | undefined, + images: Array, +): void { + const newIndex = images[index].dataset["ilb2Id"] ?? index.toString(); + let newQuery = addQueryField( + document.location.search, + "imageLightboxIndex", + newIndex, + ); + const newHistoryState: HistoryState = { + imageLightboxIndex: newIndex, + imageLightboxSet: "", + }; + if (set !== undefined) { + newHistoryState.imageLightboxSet = set; + newQuery = addQueryField(newQuery, "imageLightboxSet", set); + } + window.history.pushState( + newHistoryState, + "", + document.location.pathname + newQuery, + ); +} diff --git a/src/lib/navigation.ts b/src/lib/navigation.ts index 4b8aa4a7..ccccd765 100644 --- a/src/lib/navigation.ts +++ b/src/lib/navigation.ts @@ -40,15 +40,6 @@ export function addNavigationItems( } } -export function changeNavigationCurrent(currentIndex: number): void { - for (let i = 0; i < navigation.children.length; i++) { - navigation.children.item(i)?.classList.remove("ilb-navigation-active"); - } - navigation.children - .item(currentIndex) - ?.classList.add("ilb-navigation-active"); -} - export function addNavigationToDOM( images: Array, currentIndexFn: () => number | null, @@ -70,3 +61,12 @@ export function addNavigationToDOM( e.stopPropagation(); }); } + +export function changeNavigationCurrent(currentIndex: number): void { + for (let i = 0; i < navigation.children.length; i++) { + navigation.children.item(i)?.classList.remove("ilb-navigation-active"); + } + navigation.children + .item(currentIndex) + ?.classList.add("ilb-navigation-active"); +}