From 7f248f5d2e23514d81dbcde983c53264977fc347 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Wed, 11 Jun 2025 19:57:54 +0200 Subject: [PATCH] refactor: get rid of negated-conditions and add `no-negated-condition` rule to ESLint config --- MMM-pages.js | 14 +++++++------- eslint.config.mjs | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MMM-pages.js b/MMM-pages.js index 86d6e05..f4b7565 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -172,7 +172,7 @@ Module.register('MMM-pages', { */ updatePages() { // Update if there's at least one page. - if (this.config.modules.length !== 0) { + if (this.config.modules.length > 0) { this.animatePageChange(); if (!this.rotationPaused) { this.resetTimerWithDelay(0); @@ -202,10 +202,10 @@ Module.register('MMM-pages', { const self = this; let modulesToShow; - if (typeof targetPageName !== 'undefined') { - modulesToShow = this.config.hiddenPages[targetPageName]; - } else { + if (typeof targetPageName === 'undefined') { modulesToShow = this.config.fixed.concat(this.config.modules[this.curPage]); + } else { + modulesToShow = this.config.hiddenPages[targetPageName]; } const animationTime = self.config.animationTime / 2; @@ -280,11 +280,11 @@ Module.register('MMM-pages', { Log.warn(`[MMM-pages] was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`); } else { Log.log(`[MMM-pages] ${stateBaseString}ing rotation`); - if (!isRotating) { + if (isRotating) { + this.resetTimerWithDelay(this.rotationDelay); + } else { clearInterval(this.timer); clearInterval(this.delayTimer); - } else { - this.resetTimerWithDelay(this.rotationDelay); } this.rotationPaused = isRotating; } diff --git a/eslint.config.mjs b/eslint.config.mjs index bffc722..e4b70f6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -24,6 +24,7 @@ export default defineConfig([ '@stylistic/comma-dangle': ['error', 'only-multiline'], '@stylistic/max-statements-per-line': ['error', { max: 2 }], '@stylistic/semi': ['error', 'always'], + 'no-negated-condition': 'error' } }, {