From 4520129f9f58653f9e523a95092f937d35246782 Mon Sep 17 00:00:00 2001 From: Ayo Date: Thu, 2 Apr 2026 19:39:18 +0200 Subject: [PATCH] chore: add more stylistic rules & run formatter --- eslint.config.js | 20 +++++++++++++++++--- scripts/release.js | 2 +- src/mnswpr.js | 6 +++++- src/modules/leader-board/leader-board.js | 8 +++++--- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index b021568..dbdbb9e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -26,14 +26,28 @@ export default defineConfig([ }, { files: ['**/*.{js,mjs,cjs}'], - plugins: { js, '@stylistic': stylistic}, + plugins: { + js, '@stylistic': stylistic + }, extends: ['js/recommended'], - languageOptions: { globals: globals.browser }, + languageOptions: { + globals: globals.browser + }, rules: { '@stylistic/indent': ['error', 2], '@stylistic/quotes': ['error', 'single'], '@stylistic/semi': ['error', 'never'], - '@stylistic/comma-dangle': ['error', 'never'] + '@stylistic/comma-dangle': ['error', 'never'] , + '@stylistic/block-spacing': 'error', + '@stylistic/array-bracket-spacing': ['error', 'never'], + '@stylistic/object-curly-spacing': ['error', 'always'], + '@stylistic/key-spacing': ['error', { + 'beforeColon': false + }], + '@stylistic/array-bracket-newline': ['error', 'consistent'], + '@stylistic/object-curly-newline': ['error', { + 'consistent': true + }] } }, globalIgnores(['dist']) diff --git a/scripts/release.js b/scripts/release.js index 0ff8075..97bb6ad 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -1,5 +1,5 @@ // forked from https://github.com/elk-zone/elk/blob/main/scripts/release.ts -import {simpleGit } from 'simple-git' +import { simpleGit } from 'simple-git' const git = simpleGit() const hash = await git.revparse(['main']) diff --git a/src/mnswpr.js b/src/mnswpr.js index 9050f95..65ccefc 100644 --- a/src/mnswpr.js +++ b/src/mnswpr.js @@ -175,7 +175,11 @@ export const Minesweeper = function(appId) { const okButton = document.createElement('button') okButton.innerText = 'Okay' - const setting = {rows: rowsInput.value, cols: colsInput.value, bombs: bombsInput.value} + const setting = { + rows: rowsInput.value, + cols: colsInput.value, + bombs: bombsInput.value + } okButton.onmousedown = () => updateSetting('custom-action', setting) inputElements.forEach(input => { diff --git a/src/modules/leader-board/leader-board.js b/src/modules/leader-board/leader-board.js index 45c211d..08aa232 100644 --- a/src/modules/leader-board/leader-board.js +++ b/src/modules/leader-board/leader-board.js @@ -4,7 +4,9 @@ import { LoadingService } from '../loading/loading' import { LoggerService } from '../logger/logger' import { initializeApp } from 'firebase/app' -import { getFirestore, doc, getDocs, getDoc, setDoc, collection, query, orderBy, limit } from 'firebase/firestore/lite' +import { + getFirestore, doc, getDocs, getDoc, setDoc, collection, query, orderBy, limit +} from 'firebase/firestore/lite' export class LeaderBoardService { @@ -136,11 +138,11 @@ export class LeaderBoardService { async send(game, key) { const sessionId = new Date().toDateString().replace(/\s/g, '_') const gameId = new Date().toTimeString().replace(/\s/g, '_') - const data = {} + const data = { } data[gameId] = game const sessionRef = doc(this.store, 'mw-all', this.user.browserId, 'games', sessionId) - await setDoc(sessionRef, data, {merge: true}) + await setDoc(sessionRef, data, { merge: true }) if (this.configuration && game.status === this.configuration.passingStatus && game[key] < this.lastPlace) { let name = window.prompt(this.configuration.message)