From ed7612bd894fe303589471f7c3c500109ba0971e Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Fri, 7 Sep 2018 22:02:04 +0700 Subject: [PATCH] Fix .eslintrc.json for client-side JS files I can't remember why I extended the config with "eslint:recommended" instead of "standard" back then. I know I wanted to force an older ecmaversion, but even then it would still work just fine with standard. I've fixed it now to use standard. I've also applied auto-fix to dashboard.js and home.js, which fixed some stray or missing whitespaces, as well as the indenting of case's inside switch statement. --- public/js/.eslintrc.json | 19 +--------- public/js/dashboard.js | 77 +++++++++++++++++++--------------------- public/js/home.js | 13 ++++--- 3 files changed, 44 insertions(+), 65 deletions(-) diff --git a/public/js/.eslintrc.json b/public/js/.eslintrc.json index 7819f9e..c427cf4 100644 --- a/public/js/.eslintrc.json +++ b/public/js/.eslintrc.json @@ -7,33 +7,16 @@ "browser": true }, "extends": [ - "eslint:recommended" + "standard" ], "rules": { "curly": [ "error", "all" ], - "no-console": 0, - "semi": [ - "error", - "never" - ], - "space-before-function-paren": [ - "error", - { - "anonymous": "always", - "named": "never", - "asyncArrow": "always" - } - ], "quotes": [ "error", "single" - ], - "indent": [ - "error", - 2 ] } } diff --git a/public/js/dashboard.js b/public/js/dashboard.js index f6ccdac..590bfb6 100644 --- a/public/js/dashboard.js +++ b/public/js/dashboard.js @@ -141,43 +141,43 @@ page.domClick = function (event) { var action = element.dataset.action switch (action) { - case 'page-prev': - if (page.currentView.pageNum === 0) { - return swal('Can\'t do that!', 'This is already the first page!', 'warning') - } - return page.getUploads(page.currentView.album, page.currentView.pageNum - 1, element) - case 'page-next': - return page.getUploads(page.currentView.album, page.currentView.pageNum + 1, element) - case 'view-list': - return page.setFilesView('list', element) - case 'view-thumbs': - return page.setFilesView('thumbs', element) - case 'clear-selection': - return page.clearSelection() - case 'add-selected-files-to-album': - return page.addSelectedFilesToAlbum() - case 'bulk-delete': - return page.deleteSelectedFiles() - case 'select-file': - return page.selectFile(element, event) - case 'add-to-album': - return page.addSingleFileToAlbum(id) - case 'delete-file': - return page.deleteFile(id) - case 'select-all-files': - return page.selectAllFiles(element) - case 'display-thumbnail': - return page.displayThumbnail(id) - case 'delete-file-by-names': - return page.deleteFileByNames() - case 'submit-album': - return page.submitAlbum(element) - case 'edit-album': - return page.editAlbum(id) - case 'delete-album': - return page.deleteAlbum(id) - case 'get-new-token': - return page.getNewToken(element) + case 'page-prev': + if (page.currentView.pageNum === 0) { + return swal('Can\'t do that!', 'This is already the first page!', 'warning') + } + return page.getUploads(page.currentView.album, page.currentView.pageNum - 1, element) + case 'page-next': + return page.getUploads(page.currentView.album, page.currentView.pageNum + 1, element) + case 'view-list': + return page.setFilesView('list', element) + case 'view-thumbs': + return page.setFilesView('thumbs', element) + case 'clear-selection': + return page.clearSelection() + case 'add-selected-files-to-album': + return page.addSelectedFilesToAlbum() + case 'bulk-delete': + return page.deleteSelectedFiles() + case 'select-file': + return page.selectFile(element, event) + case 'add-to-album': + return page.addSingleFileToAlbum(id) + case 'delete-file': + return page.deleteFile(id) + case 'select-all-files': + return page.selectAllFiles(element) + case 'display-thumbnail': + return page.displayThumbnail(id) + case 'delete-file-by-names': + return page.deleteFileByNames() + case 'submit-album': + return page.submitAlbum(element) + case 'edit-album': + return page.editAlbum(id) + case 'delete-album': + return page.deleteAlbum(id) + case 'get-new-token': + return page.getNewToken(element) } } @@ -1246,7 +1246,6 @@ page.setFileLength = function (fileLength, element) { page.changeToken = function () { axios.get('api/tokens') .then(function (response) { - if (response.data.success === false) { if (response.data.description === 'No token provided') { return page.verifyToken(page.token) @@ -1275,7 +1274,6 @@ page.changeToken = function () { ' \n' + ' \n' + '' - }) .catch(function (error) { console.log(error) @@ -1385,7 +1383,6 @@ page.sendNewPassword = function (pass, element) { page.isLoading(element, false) return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error') }) - } page.setActiveMenu = function (activeItem) { diff --git a/public/js/home.js b/public/js/home.js index 0cb7fd6..ef57a13 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -25,7 +25,8 @@ var imageExtensions = ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png'] page.checkIfPublic = function () { axios.get('api/check') - .then(function (response) { page.private = response.data.private + .then(function (response) { + page.private = response.data.private page.enableUserAccounts = response.data.enableUserAccounts page.maxFileSize = response.data.maxFileSize page.chunkSize = response.data.chunkSize @@ -38,7 +39,6 @@ page.checkIfPublic = function () { button.innerText = 'Error occurred. Reload the page?' return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error') }) - } page.preparePage = function () { @@ -302,12 +302,12 @@ page.uploadUrls = function (button) { if (button.classList.contains('is-loading')) { return } button.classList.add('is-loading') - function done(error) { + function done (error) { if (error) { swal('An error occurred!', error, 'error') } button.classList.remove('is-loading') } - function run() { + function run () { var albumid = page.album var previewsContainer = tabDiv.getElementsByClassName('uploads')[0] var urls = document.getElementById('urls').value @@ -333,12 +333,12 @@ page.uploadUrls = function (button) { } }) - function post(i) { + function post (i) { if (i === files.length) { return done() } var file = files[i] - function posted(result) { + function posted (result) { file.previewElement.querySelector('.progress').style.display = 'none' if (result.success) { page.updateTemplate(file, result.files[0]) @@ -477,7 +477,6 @@ page.createAlbum = function () { return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error') }) }) - } // Handle image paste event