Skip to content

Commit

Permalink
#1866 eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Dec 17, 2024
1 parent 30099a4 commit 29caa15
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { BrowserDetect } from "./browser-detect";
import DetectAutomaticRotation, { testAutoOrientationImageURL } from "./detect-automatic-rotation";

class ImageClass {
constructor() {
setTimeout(() => {
(this as unknown as { onload: () => void }).onload(); // simulate success
}, 1);
}
}

describe("select", () => {
describe("removeSidebarSelection", () => {
jest.mock("../style/images/detect-automatic-rotation.jpg");

it("returns true if both arguments are null or undefined", async () => {
// Fake onLoad Trigger
// @see: https://stackoverflow.com/a/59118461
(global as any).Image = class {
constructor() {
setTimeout(() => {
(this as any).onload(); // simulate success
}, 1);
}
};

(global as unknown as { Image: typeof ImageClass }).Image = ImageClass;

expect(testAutoOrientationImageURL).toContain("data:image");

const result = await DetectAutomaticRotation();
Expand Down
2 changes: 1 addition & 1 deletion starsky/starsky/clientapp/src/shared/fetch/fetch-xml.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IConnectionDefault } from "../../interfaces/IConnectionDefault";

function isParseError(parsedDocument: any) {
function isParseError(parsedDocument: Document) {
// parser and parsererrorNS could be cached on startup for efficiency
const parser = new DOMParser(),
errorneousParse = parser.parseFromString("<", "text/xml"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class LeafletEmptyImageUrlGridLayer extends GridLayer {
// Fired when a tile is removed (e.g. when a tile goes off the screen).
this.fire("tileunload", {
tile: tile.el,
coords: (this as any)._keyToTileCoords(key)
coords: (this as unknown as { _keyToTileCoords: (key: string) => void })._keyToTileCoords(key)
});
}

Expand All @@ -59,10 +59,10 @@ export class LeafletEmptyImageUrlGridLayer extends GridLayer {
el: HTMLElement;
loaded?: Date | number;
retain?: boolean;
getAttribute?: any;
getAttribute?: (name: string) => string | null;
}
) {
if (!this._map || tile.getAttribute("src") === "empty-image.gif") {
if (!this._map || (tile.getAttribute && tile.getAttribute("src") === "empty-image.gif")) {
return;
} // Replace emptyImageUrl

Expand All @@ -84,13 +84,16 @@ export class LeafletEmptyImageUrlGridLayer extends GridLayer {
}
tile.loaded = +new Date();

if ((this._map as any)._fadeAnimated) {
if ((this._map as unknown as { _fadeAnimated: boolean })._fadeAnimated) {
L.DomUtil.setOpacity(tile.el, 0);
L.Util.cancelAnimFrame((this as any)._fadeFrame);
(this as any)._fadeFrame = L.Util.requestAnimFrame((this as any)._updateOpacity, this);
L.Util.cancelAnimFrame((this as unknown as { _fadeFrame: number })._fadeFrame);
(this as unknown as { _fadeFrame: number })._fadeFrame = L.Util.requestAnimFrame(
(this as unknown as { _updateOpacity: (timestamp: number) => void })._updateOpacity,
this
);
} else {
tile.active = true;
(this as any)._pruneTiles();
(this as unknown as { _pruneTiles: () => void })._pruneTiles();
}

if (!err) {
Expand All @@ -104,18 +107,24 @@ export class LeafletEmptyImageUrlGridLayer extends GridLayer {
});
}

if ((this as any)._noTilesToLoad()) {
(this as any)._loading = false;
if ((this as unknown as { _noTilesToLoad: () => boolean })._noTilesToLoad()) {
(this as unknown as { _loading: boolean })._loading = false;
// @event load: Event
// Fired when the grid layer loaded all visible tiles.
this.fire("load");

if (L.Browser.ielt9 || !(this as any)._map._fadeAnimated) {
L.Util.requestAnimFrame((this as any)._pruneTiles, this);
if (
L.Browser.ielt9 ||
!(this as unknown as { _map: { _fadeAnimated: boolean } })._map._fadeAnimated
) {
L.Util.requestAnimFrame((this as unknown as { _pruneTiles: () => void })._pruneTiles, this);
} else {
// Wait a bit more than 0.2 secs (the duration of the tile fade-in)
// to trigger a pruning.
setTimeout(L.Util.bind((this as any)._pruneTiles, this), 250);
setTimeout(
L.Util.bind((this as unknown as { _pruneTiles: () => void })._pruneTiles, this),
250
);
}
}
}
Expand Down

0 comments on commit 29caa15

Please sign in to comment.