refactor: get rid of negated-conditions and add no-negated-condition rule to ESLint config

This commit is contained in:
Kristjan ESPERANTO 2025-06-11 19:57:54 +02:00
parent 41958b543a
commit 7f248f5d2e
No known key found for this signature in database
2 changed files with 8 additions and 7 deletions

View file

@ -172,7 +172,7 @@ Module.register('MMM-pages', {
*/ */
updatePages() { updatePages() {
// Update if there's at least one page. // Update if there's at least one page.
if (this.config.modules.length !== 0) { if (this.config.modules.length > 0) {
this.animatePageChange(); this.animatePageChange();
if (!this.rotationPaused) { if (!this.rotationPaused) {
this.resetTimerWithDelay(0); this.resetTimerWithDelay(0);
@ -202,10 +202,10 @@ Module.register('MMM-pages', {
const self = this; const self = this;
let modulesToShow; let modulesToShow;
if (typeof targetPageName !== 'undefined') { if (typeof targetPageName === 'undefined') {
modulesToShow = this.config.hiddenPages[targetPageName];
} else {
modulesToShow = this.config.fixed.concat(this.config.modules[this.curPage]); modulesToShow = this.config.fixed.concat(this.config.modules[this.curPage]);
} else {
modulesToShow = this.config.hiddenPages[targetPageName];
} }
const animationTime = self.config.animationTime / 2; 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!`); Log.warn(`[MMM-pages] was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`);
} else { } else {
Log.log(`[MMM-pages] ${stateBaseString}ing rotation`); Log.log(`[MMM-pages] ${stateBaseString}ing rotation`);
if (!isRotating) { if (isRotating) {
this.resetTimerWithDelay(this.rotationDelay);
} else {
clearInterval(this.timer); clearInterval(this.timer);
clearInterval(this.delayTimer); clearInterval(this.delayTimer);
} else {
this.resetTimerWithDelay(this.rotationDelay);
} }
this.rotationPaused = isRotating; this.rotationPaused = isRotating;
} }

View file

@ -24,6 +24,7 @@ export default defineConfig([
'@stylistic/comma-dangle': ['error', 'only-multiline'], '@stylistic/comma-dangle': ['error', 'only-multiline'],
'@stylistic/max-statements-per-line': ['error', { max: 2 }], '@stylistic/max-statements-per-line': ['error', { max: 2 }],
'@stylistic/semi': ['error', 'always'], '@stylistic/semi': ['error', 'always'],
'no-negated-condition': 'error'
} }
}, },
{ {