From c51a3270da1f6af796b7d23fa4b434ccf11818e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sun, 10 Mar 2024 20:52:56 -0700 Subject: [PATCH] GitHub Actions: Add basic ESLinter checks --- .github/workflows/linters.yml | 6 ++++-- internal/ui/static/js/.eslintrc.json | 9 +++++++++ internal/ui/static/js/app.js | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 internal/ui/static/js/.eslintrc.json diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ad1f029b..de1c1c6c 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -13,11 +13,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install jshint + - name: Install linters run: | - sudo npm install -g jshint@2.13.6 + sudo npm install -g jshint@2.13.6 eslint@8.57.0 - name: Run jshint run: jshint internal/ui/static/js/*.js + - name: Run ESLint + run: eslint internal/ui/static/js/*.js golangci: name: Golang Linter diff --git a/internal/ui/static/js/.eslintrc.json b/internal/ui/static/js/.eslintrc.json new file mode 100644 index 00000000..03bfd5b9 --- /dev/null +++ b/internal/ui/static/js/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "env": { + "browser": true, + "es2017": true + }, + "rules": { + "indent": ["error", 4] + } +} \ No newline at end of file diff --git a/internal/ui/static/js/app.js b/internal/ui/static/js/app.js index 0909562e..809c5c22 100644 --- a/internal/ui/static/js/app.js +++ b/internal/ui/static/js/app.js @@ -40,9 +40,9 @@ function checkMenuToggleModeByLayout() { logoElement.setAttribute("tabindex", "0"); logoElement.setAttribute("aria-label", logoToggleButtonLabel); if (navMenuElementIsExpanded) { - logoElement.setAttribute("aria-expanded", "true"); + logoElement.setAttribute("aria-expanded", "true"); } else { - logoElement.setAttribute("aria-expanded", "false"); + logoElement.setAttribute("aria-expanded", "false"); } homePageLinkElement.setAttribute("tabindex", "-1"); } else { @@ -175,12 +175,12 @@ function handleEntryStatus(item, element, setToRead) { } if (isListView() && currentEntry.classList.contains('current-item')) { switch (item) { - case "previous": - goToListItem(-1); - break; - case "next": - goToListItem(1); - break; + case "previous": + goToListItem(-1); + break; + case "next": + goToListItem(1); + break; } } } @@ -246,7 +246,7 @@ function handleRefreshAllFeeds() { function updateEntriesStatus(entryIDs, status, callback) { let url = document.body.dataset.entriesStatusUrl; let request = new RequestBuilder(url); - request.withBody({entry_ids: entryIDs, status: status}); + request.withBody({ entry_ids: entryIDs, status: status }); request.withCallback((resp) => { resp.json().then(count => { if (callback) { @@ -358,8 +358,8 @@ function handleFetchOriginalContent() { let request = new RequestBuilder(element.dataset.fetchContentUrl); request.withCallback((response) => { - element.textContent = ''; - element.appendChild(previousElement); + element.textContent = ''; + element.appendChild(previousElement); response.json().then((data) => { if (data.hasOwnProperty("content") && data.hasOwnProperty("reading_time")) { @@ -675,7 +675,7 @@ function handlePlayerProgressionSave(playerElement) { ) { playerElement.dataset.lastPosition = currentPositionInSeconds.toString(); let request = new RequestBuilder(playerElement.dataset.saveUrl); - request.withBody({progression: currentPositionInSeconds}); + request.withBody({ progression: currentPositionInSeconds }); request.execute(); } }