Switch to recommended stylistic rules

This commit is contained in:
Kristjan ESPERANTO 2024-12-09 01:02:58 +01:00
parent 6db5efe2c8
commit 90a7651f40
2 changed files with 17 additions and 30 deletions

View file

@ -22,18 +22,17 @@ Module.register('MMM-pages', {
/**
* Apply any styles, if we have any.
*/
getStyles () {
getStyles() {
return ['pages.css'];
},
/**
* Modulo that also works with negative numbers.
*
* @param {number} x The dividend
* @param {number} n The divisor
*/
mod (x, n) {
mod(x, n) {
return ((x % n) + n) % n;
},
@ -41,7 +40,7 @@ Module.register('MMM-pages', {
* Pseudo-constructor for our module. Makes sure that values aren't negative,
* and sets the default current page to 0.
*/
start () {
start() {
// Clamp homePage value to [0, num pages).
if (this.config.homePage >= this.config.modules.length || this.config.homePage < 0) {
this.config.homePage = 0;
@ -88,7 +87,7 @@ Module.register('MMM-pages', {
* @param {string} notification the notification ID
* @param {number|string} payload the page to change to/by
*/
notificationReceived (notification, payload) {
notificationReceived(notification, payload) {
switch (notification) {
case 'PAGE_CHANGED':
Log.log(`[MMM-pages] received a notification to change to page ${payload} of type ${typeof payload}.`);
@ -150,7 +149,7 @@ Module.register('MMM-pages', {
* @param {number} fallback the fallback value to use. Accepts negative
* numbers.
*/
changePageBy (amt, fallback) {
changePageBy(amt, fallback) {
if (typeof amt !== 'number' && typeof fallback === 'undefined') {
Log.warn(`[MMM-pages] ${amt} is not a number!`);
}
@ -172,7 +171,7 @@ Module.register('MMM-pages', {
* Handles hiding the current page's elements and showing the next page's
* elements.
*/
updatePages () {
updatePages() {
// Update if there's at least one page.
if (this.config.modules.length !== 0) {
this.animatePageChange();
@ -191,8 +190,8 @@ Module.register('MMM-pages', {
* @param {string} [targetPageName] the name of the hiddenPage we want to show.
* Optional and only used when we want to switch to a hidden page
*/
animatePageChange (targetPageName) {
let lockStringObj = {lockString: this.identifier};
animatePageChange(targetPageName) {
let lockStringObj = { lockString: this.identifier };
if (!this.config.useLockString) {
// Passing in an undefined object is equivalent to not passing it in at
// all, effectively providing only one arg to the hide and show calls
@ -213,13 +212,13 @@ Module.register('MMM-pages', {
MM.getModules()
.exceptWithClass(modulesToShow)
.enumerate((module) => module.hide(animationTime, lockStringObj));
.enumerate(module => module.hide(animationTime, lockStringObj));
// Shows all modules meant to be on the current page, after a small delay.
setTimeout(() => {
MM.getModules()
.withClass(modulesToShow)
.enumerate((module) => module.show(animationTime, lockStringObj));
.enumerate(module => module.show(animationTime, lockStringObj));
}, animationTime);
},
@ -228,7 +227,7 @@ Module.register('MMM-pages', {
*
* @param {number} delay the delay, in milliseconds.
*/
resetTimerWithDelay (delay) {
resetTimerWithDelay(delay) {
if (this.config.rotationTime > 0) {
// This timer is the auto rotate function.
clearInterval(this.timer);
@ -272,7 +271,7 @@ Module.register('MMM-pages', {
*
* @param {boolean} isRotating the parameter, if you want to pause or resume.
*/
setRotation (isRotating) {
setRotation(isRotating) {
const stateBaseString = isRotating ? 'resum' : 'paus';
if (isRotating === this.rotationPaused) {
Log.warn(`[MMM-pages] was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`);
@ -293,7 +292,7 @@ Module.register('MMM-pages', {
*
* @param {string} name the name of the hiddenPage we want to show
*/
showHiddenPage (name) {
showHiddenPage(name) {
// Only proceed if the named hidden page actually exists
if (name in this.config.hiddenPages) {
this.animatePageChange(name);

View file

@ -3,6 +3,8 @@ import eslintPluginStylistic from '@stylistic/eslint-plugin';
import globals from 'globals';
const config = [
eslintPluginJs.configs.recommended,
eslintPluginStylistic.configs['recommended-flat'],
{
files: ['**/*.js', '**/*.mjs'],
},
@ -16,24 +18,10 @@ const config = [
Module: 'readonly',
},
},
plugins: {
...eslintPluginStylistic.configs['all-flat'].plugins,
},
rules: {
...eslintPluginJs.configs.recommended.rules,
...eslintPluginStylistic.configs['all-flat'].rules,
'@stylistic/array-element-newline': 'off',
'@stylistic/brace-style': ['error', '1tbs', {allowSingleLine: true}],
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
'@stylistic/comma-dangle': ['error', 'only-multiline'],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/function-call-argument-newline': 'off',
'@stylistic/indent': ['error', 2],
'@stylistic/padded-blocks': 'off',
'@stylistic/quote-props': ['error', 'consistent-as-needed'],
'@stylistic/quotes': ['error', 'single'],
'@stylistic/multiline-comment-style': 'off',
'@stylistic/multiline-ternary': 'off',
'@stylistic/no-extra-parens': 'off',
'@stylistic/semi': ['error', 'always'],
'object-shorthand': ['error', 'always']
},
}