From 41157245bbd05cb15209d9b57cd408ac8e70e1ac Mon Sep 17 00:00:00 2001 From: Sheya Bernstein Date: Wed, 28 Feb 2024 21:23:41 +0000 Subject: [PATCH] prettier --- .github/workflows/{format-code.yml => lint.yml} | 7 +++---- .github/workflows/stale.yml | 2 +- MMM-pihole-stats.js | 6 +++--- node_helper.js | 14 +++++++++----- package.json | 8 +++++++- 5 files changed, 23 insertions(+), 14 deletions(-) rename .github/workflows/{format-code.yml => lint.yml} (60%) diff --git a/.github/workflows/format-code.yml b/.github/workflows/lint.yml similarity index 60% rename from .github/workflows/format-code.yml rename to .github/workflows/lint.yml index 9bfcd75..0465a20 100644 --- a/.github/workflows/format-code.yml +++ b/.github/workflows/lint.yml @@ -5,9 +5,8 @@ on: jobs: format: - name: Format Code + name: Lint runs-on: ubuntu-latest - if: "!contains(github.actor, 'actions-user')" steps: - name: Checkout Repository @@ -15,7 +14,7 @@ jobs: with: ref: ${{ github.head_ref }} - - name: Format Code with Prettier + - name: Lint with Prettier uses: creyD/prettier_action@v4.3 with: - prettier_options: --write --tab-width 4 **/*.{js,md} + prettier_options: --check --tab-width 4 **/*.{js,md} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index f9e2662..8c26706 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,4 @@ -name: 'Close stale issues and PRs' +name: "Close stale issues and PRs" on: schedule: - cron: "0 0 * * *" diff --git a/MMM-pihole-stats.js b/MMM-pihole-stats.js index dd5e9ea..1d9955e 100644 --- a/MMM-pihole-stats.js +++ b/MMM-pihole-stats.js @@ -20,7 +20,7 @@ Module.register("MMM-pihole-stats", { floatingPoints: 2, retryDelay: 1000 * 30, - initialLoadDelay: 0, + initialLoadDelay: 0 }, formatInt(n) { @@ -124,7 +124,7 @@ Module.register("MMM-pihole-stats", { Log.info(`${this.name}: Getting data`); this.sendSocketNotification("GET_PIHOLE", { - config: this.config, + config: this.config }); }, @@ -172,5 +172,5 @@ Module.register("MMM-pihole-stats", { } this.top_sources = data.top_sources || []; - }, + } }); diff --git a/node_helper.js b/node_helper.js index 3e5f0e7..d1b5bff 100644 --- a/node_helper.js +++ b/node_helper.js @@ -21,13 +21,13 @@ module.exports = NodeHelper.create({ if (config.showSources && config.sourcesCount > 0) { if (config.showSources && !config.apiToken) { Log.error( - `${this.name}: Can't load sources because the apiKey is not set.`, + `${this.name}: Can't load sources because the apiKey is not set.` ); } else { this.getPiholeData( config, { getQuerySources: config.sourcesCount }, - "PIHOLE_SOURCES", + "PIHOLE_SOURCES" ); } } @@ -77,11 +77,15 @@ module.exports = NodeHelper.create({ self.sendSocketNotification(notification, data); } else { Log.error( - `${this.name}: Expected JSON but received ${response.headers.get("content-type")}`, + `${ + this.name + }: Expected JSON but received ${response.headers.get( + "content-type" + )}` ); } } catch (error) { - Log.error(`${this.name}: ${error}`), + Log.error(`${this.name}: ${error}`); } - }, + } }); diff --git a/package.json b/package.json index 6ca1358..92214da 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "version": "1.0.0", "description": "Pi-hole stats module for MagicMirror².", "main": "MMM-pihole-stats.js", + "scripts": { + "format": "prettier --write --tab-width 4 **/*.{js,md}" + }, "repository": { "type": "git", "url": "git+https://github.com/sheyabernstein/MMM-pihole-stats.git" @@ -17,5 +20,8 @@ "bugs": { "url": "https://github.com/sheyabernstein/MMM-pihole-stats/issues" }, - "homepage": "https://github.com/sheyabernstein/MMM-pihole-stats#readme" + "homepage": "https://github.com/sheyabernstein/MMM-pihole-stats#readme", + "devDependencies": { + "prettier": "^2.8.8" + } }