From 5630b85918182cb7e5aa7186aba44c26f3a18426 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 29 Apr 2024 18:20:17 +0200 Subject: [PATCH] Enforce and fix typescript lints --- .eslintignore | 12 ------------ apps/ctrlpad/main.js | 5 +++-- apps/ctrlpad/main.ts | 5 +++-- apps/drained/app.js | 5 +++-- apps/drained/app.ts | 6 +++--- apps/drained/boot.js | 2 +- apps/drained/boot.ts | 2 +- apps/lint_exemptions.js | 12 ------------ 8 files changed, 14 insertions(+), 35 deletions(-) diff --git a/.eslintignore b/.eslintignore index 933dfaf69..1e3abd9ff 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,15 +4,3 @@ apps/gipy/pkg/gps.js # Needs to be ignored because it includes broken JS apps/health/chart.min.js - -# TypeScript -apps/btadv/ -apps/clkinfostopw/ -apps/ctrlpad/ -apps/drained/ -apps/folderlaunch/ -apps/popconlaunch/ -apps/rep/ -apps/widChargingStatus/ -apps/widbtstates/ -apps/widhid/ diff --git a/apps/ctrlpad/main.js b/apps/ctrlpad/main.js index f9614168e..41e62a2d7 100644 --- a/apps/ctrlpad/main.js +++ b/apps/ctrlpad/main.js @@ -126,8 +126,9 @@ { text: "DnD", cb: function (tap) { - var on; - if (on = !!origBuzz) { + var on = false; + if (origBuzz) { + on = true; if (tap) { Bangle.buzz = origBuzz; origBuzz = undefined; diff --git a/apps/ctrlpad/main.ts b/apps/ctrlpad/main.ts index 7f758a3b0..7d99b88f6 100644 --- a/apps/ctrlpad/main.ts +++ b/apps/ctrlpad/main.ts @@ -193,8 +193,9 @@ { text: "DnD", cb: tap => { - let on; - if(on = !!origBuzz){ + let on = false; + if(origBuzz){ + on = true; if(tap){ Bangle.buzz = origBuzz; origBuzz = undefined; diff --git a/apps/drained/app.js b/apps/drained/app.js index c74affea3..11f14713a 100644 --- a/apps/drained/app.js +++ b/apps/drained/app.js @@ -1,6 +1,7 @@ var app = "drained"; -if (typeof drainedInterval !== "undefined") - drainedInterval = clearInterval(drainedInterval); +var globals = global; +if (typeof globals.drainedInterval !== "undefined") + globals.drainedInterval = clearInterval(globals.drainedInterval); Bangle.setLCDBrightness(0); var powerNoop = function () { return false; }; var forceOff = function (name) { diff --git a/apps/drained/app.ts b/apps/drained/app.ts index 499609f5f..9918361e8 100644 --- a/apps/drained/app.ts +++ b/apps/drained/app.ts @@ -1,9 +1,9 @@ const app = "drained"; // from boot.js -declare var drainedInterval: IntervalId | undefined; -if(typeof drainedInterval !== "undefined") - drainedInterval = clearInterval(drainedInterval) as undefined; +const globals: { drainedInterval: IntervalId | undefined } = global as any; +if(typeof globals.drainedInterval !== "undefined") + globals.drainedInterval = clearInterval(globals.drainedInterval) as undefined; // backlight Bangle.setLCDBrightness(0); diff --git a/apps/drained/boot.js b/apps/drained/boot.js index 48c1572bd..3ce74527c 100644 --- a/apps/drained/boot.js +++ b/apps/drained/boot.js @@ -1,6 +1,6 @@ (function () { var _a = require("Storage").readJSON("drained.setting.json", true) || {}, _b = _a.battery, threshold = _b === void 0 ? 5 : _b, _c = _a.interval, interval = _c === void 0 ? 10 : _c, _d = _a.keepStartup, keepStartup = _d === void 0 ? true : _d; - drainedInterval = setInterval(function () { + global.drainedInterval = setInterval(function () { if (Bangle.isCharging()) return; if (E.getBattery() > threshold) diff --git a/apps/drained/boot.ts b/apps/drained/boot.ts index 1fcb0591b..2f5b9322e 100644 --- a/apps/drained/boot.ts +++ b/apps/drained/boot.ts @@ -2,7 +2,7 @@ const { battery: threshold = 5, interval = 10, keepStartup = true }: DrainedSettings = require("Storage").readJSON(`drained.setting.json`, true) || {}; -drainedInterval = setInterval(() => { +(global as any).drainedInterval = setInterval(() => { if(Bangle.isCharging()) return; if(E.getBattery() > threshold) diff --git a/apps/lint_exemptions.js b/apps/lint_exemptions.js index 5821db4c4..18a2919e8 100644 --- a/apps/lint_exemptions.js +++ b/apps/lint_exemptions.js @@ -1137,18 +1137,6 @@ module.exports = { "no-undef" ] }, - "drained/boot.js": { - "hash": "914ea2c47aa6b9502b9dd354d490b2a8b838d4c6fafaa20e206f1f2396d4db40", - "rules": [ - "no-undef" - ] - }, - "drained/app.js": { - "hash": "2b609ca5bf414b0e400e25512bf396a01f8cb0365b4edd02ea1697b51907d36c", - "rules": [ - "no-undef" - ] - }, "dinoClock/app.js": { "hash": "e97566aa4f586ef654e3fc1ec286376352762ed8e0ea2e685a7b3ae687f51552", "rules": [