diff options
| author | Pitu <[email protected]> | 2020-12-24 23:45:16 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2020-12-24 23:45:16 +0900 |
| commit | fb2c27086f570fec60f4d52dcc9ca80e53186293 (patch) | |
| tree | 4c4fd056c293b8e0de632023ef19fdea95c009fa /src | |
| parent | Merge pull request #228 from Zephyrrus/begone_trailing_commas (diff) | |
| download | host.fuwn.me-fb2c27086f570fec60f4d52dcc9ca80e53186293.tar.xz host.fuwn.me-fb2c27086f570fec60f4d52dcc9ca80e53186293.zip | |
Fix ESLint rules once and for all
Diffstat (limited to 'src')
46 files changed, 237 insertions, 229 deletions
diff --git a/src/api/database/migrations/20190221225812_initialMigration.js b/src/api/database/migrations/20190221225812_initialMigration.js index b755a33..92103c1 100644 --- a/src/api/database/migrations/20190221225812_initialMigration.js +++ b/src/api/database/migrations/20190221225812_initialMigration.js @@ -1,5 +1,5 @@ -exports.up = async (knex) => { - await knex.schema.createTable('users', (table) => { +exports.up = async knex => { + await knex.schema.createTable('users', table => { table.increments(); table.string('username').unique(); table.text('password'); @@ -12,7 +12,7 @@ exports.up = async (knex) => { table.timestamp('editedAt'); }); - await knex.schema.createTable('albums', (table) => { + await knex.schema.createTable('albums', table => { table.increments(); table.integer('userId'); table.string('name'); @@ -24,7 +24,7 @@ exports.up = async (knex) => { table.unique(['userId', 'name']); }); - await knex.schema.createTable('files', (table) => { + await knex.schema.createTable('files', table => { table.increments(); table.integer('userId'); table.string('name'); @@ -38,7 +38,7 @@ exports.up = async (knex) => { table.timestamp('editedAt'); }); - await knex.schema.createTable('links', (table) => { + await knex.schema.createTable('links', table => { table.increments(); table.integer('userId'); table.integer('albumId'); @@ -53,7 +53,7 @@ exports.up = async (knex) => { table.unique(['userId', 'albumId', 'identifier']); }); - await knex.schema.createTable('albumsFiles', (table) => { + await knex.schema.createTable('albumsFiles', table => { table.increments(); table.integer('albumId'); table.integer('fileId'); @@ -61,13 +61,13 @@ exports.up = async (knex) => { table.unique(['albumId', 'fileId']); }); - await knex.schema.createTable('albumsLinks', (table) => { + await knex.schema.createTable('albumsLinks', table => { table.increments(); table.integer('albumId'); table.integer('linkId').unique(); }); - await knex.schema.createTable('tags', (table) => { + await knex.schema.createTable('tags', table => { table.increments(); table.string('uuid'); table.integer('userId'); @@ -78,7 +78,7 @@ exports.up = async (knex) => { table.unique(['userId', 'name']); }); - await knex.schema.createTable('fileTags', (table) => { + await knex.schema.createTable('fileTags', table => { table.increments(); table.integer('fileId'); table.integer('tagId'); @@ -86,13 +86,13 @@ exports.up = async (knex) => { table.unique(['fileId', 'tagId']); }); - await knex.schema.createTable('bans', (table) => { + await knex.schema.createTable('bans', table => { table.increments(); table.string('ip'); table.timestamp('createdAt'); }); }; -exports.down = async (knex) => { +exports.down = async knex => { await knex.schema.dropTableIfExists('users'); await knex.schema.dropTableIfExists('albums'); await knex.schema.dropTableIfExists('files'); diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 2383a7b..edc1949 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -2,7 +2,7 @@ const bcrypt = require('bcrypt'); const moment = require('moment'); -exports.seed = async (db) => { +exports.seed = async db => { const now = moment.utc().toDate(); const user = await db.table('users').where({ username: process.env.ADMIN_ACCOUNT }).first(); if (user) return; diff --git a/src/api/databaseMigration.js b/src/api/databaseMigration.js index 7e919f3..9afbb4a 100644 --- a/src/api/databaseMigration.js +++ b/src/api/databaseMigration.js @@ -27,7 +27,7 @@ const generateThumbnailForImage = async (filename, output) => { } }; -const generateThumbnailForVideo = (filename) => { +const generateThumbnailForVideo = filename => { try { ffmpeg(nodePath.join(__dirname, '../../uploads', filename)) .thumbnail({ @@ -36,7 +36,7 @@ const generateThumbnailForVideo = (filename) => { folder: nodePath.join(__dirname, '../../uploads/thumbs/square'), size: '64x64' }) - .on('error', (error) => console.error(error.message)); + .on('error', error => console.error(error.message)); ffmpeg(nodePath.join(__dirname, '../../uploads', filename)) .thumbnail({ timestamps: [0], @@ -44,7 +44,7 @@ const generateThumbnailForVideo = (filename) => { folder: nodePath.join(__dirname, '../../uploads/thumbs'), size: '150x?' }) - .on('error', (error) => console.error(error.message)); + .on('error', error => console.error(error.message)); console.log('finished', filename); } catch (error) { console.log('error', filename); @@ -64,15 +64,15 @@ const newDb = require('knex')({ connection: { filename: nodePath.join(__dirname, '../../', 'database.sqlite') }, - postProcessResponse: (result) => { + postProcessResponse: result => { const booleanFields = [ 'enabled', 'enableDownload', 'isAdmin' ]; - const processResponse = (row) => { - Object.keys(row).forEach((key) => { + const processResponse = row => { + Object.keys(row).forEach(key => { if (booleanFields.includes(key)) { if (row[key] === 0) row[key] = false; else if (row[key] === 1) row[key] = true; @@ -81,7 +81,7 @@ const newDb = require('knex')({ return row; }; - if (Array.isArray(result)) return result.map((row) => processResponse(row)); + if (Array.isArray(result)) return result.map(row => processResponse(row)); if (typeof result === 'object') return processResponse(result); return result; }, diff --git a/src/api/routes/albums/albumZipGET.js b/src/api/routes/albums/albumZipGET.js index cf1f6f8..26da2ba 100644 --- a/src/api/routes/albums/albumZipGET.js +++ b/src/api/routes/albums/albumZipGET.js @@ -64,11 +64,11 @@ class albumGET extends Route { /* Get the actual files */ - const fileIds = fileList.map((el) => el.fileId); + const fileIds = fileList.map(el => el.fileId); const files = await db.table('files') .whereIn('id', fileIds) .select('name'); - const filesToZip = files.map((el) => el.name); + const filesToZip = files.map(el => el.name); try { Util.createZip(filesToZip, album); diff --git a/src/api/routes/files/filesAlbumsGET.js b/src/api/routes/files/filesAlbumsGET.js index 90aa654..7f1190c 100644 --- a/src/api/routes/files/filesAlbumsGET.js +++ b/src/api/routes/files/filesAlbumsGET.js @@ -18,7 +18,7 @@ class filesGET extends Route { .select('albumId'); if (albumFiles.length) { - albumFiles = albumFiles.map((a) => a.albumId); + albumFiles = albumFiles.map(a => a.albumId); albums = await db.table('albums') .whereIn('id', albumFiles) .select('id', 'name'); diff --git a/src/api/routes/uploads/uploadPOST.js b/src/api/routes/uploads/uploadPOST.js index 567862a..5458d48 100644 --- a/src/api/routes/uploads/uploadPOST.js +++ b/src/api/routes/uploads/uploadPOST.js @@ -56,7 +56,7 @@ class uploadPOST extends Route { if (!album) return res.status(401).json({ message: 'Album doesn\'t exist or it doesn\'t belong to the user' }); } - return upload(req, res, async (err) => { + return upload(req, res, async err => { if (err) console.error(err.message); let uploadedFile = {}; @@ -142,7 +142,7 @@ class uploadPOST extends Route { async checkIfFileExists(db, user, hash) { const exists = await db.table('files') - .where(function () { // eslint-disable-line func-names + .where(function() { // eslint-disable-line func-names if (user) this.where('userId', user.id); else this.whereNull('userId'); }) diff --git a/src/api/structures/Route.js b/src/api/structures/Route.js index 74589c5..3806325 100644 --- a/src/api/structures/Route.js +++ b/src/api/structures/Route.js @@ -9,7 +9,7 @@ const db = require('knex')({ database: process.env.DB_DATABASE, filename: nodePath.join(__dirname, '../../../database.sqlite') }, - postProcessResponse: (result) => { + postProcessResponse: result => { /* Fun fact: Depending on the database used by the user and given that I don't want to force a specific database for everyone because of the nature of this project, @@ -18,8 +18,8 @@ const db = require('knex')({ */ const booleanFields = ['enabled', 'enableDownload', 'isAdmin']; - const processResponse = (row) => { - Object.keys(row).forEach((key) => { + const processResponse = row => { + Object.keys(row).forEach(key => { if (booleanFields.includes(key)) { if (row[key] === 0) row[key] = false; else if (row[key] === 1) row[key] = true; @@ -28,7 +28,7 @@ const db = require('knex')({ return row; }; - if (Array.isArray(result)) return result.map((row) => processResponse(row)); + if (Array.isArray(result)) return result.map(row => processResponse(row)); if (typeof result === 'object') return processResponse(result); return result; }, diff --git a/src/api/structures/Server.js b/src/api/structures/Server.js index 83b2880..0ef91fd 100644 --- a/src/api/structures/Server.js +++ b/src/api/structures/Server.js @@ -42,16 +42,16 @@ class Server { if (ext) { ext = `.${ext.toLowerCase()}`; } if ( - ThumbUtil.imageExtensions.indexOf(ext) > -1 - || ThumbUtil.videoExtensions.indexOf(ext) > -1 - || req.path.indexOf('_nuxt') > -1 - || req.path.indexOf('favicon.ico') > -1 + ThumbUtil.imageExtensions.indexOf(ext) > -1 || + ThumbUtil.videoExtensions.indexOf(ext) > -1 || + req.path.indexOf('_nuxt') > -1 || + req.path.indexOf('favicon.ico') > -1 ) { return true; } return false; }, - 'stream': { + stream: { write(str) { log.debug(str); } } })); @@ -64,7 +64,7 @@ class Server { } registerAllTheRoutes() { - jetpack.find(this.routesFolder, { matching: '*.js' }).forEach((routeFile) => { + jetpack.find(this.routesFolder, { matching: '*.js' }).forEach(routeFile => { // eslint-disable-next-line import/no-dynamic-require, global-require const RouteClass = require(path.join('../../../', routeFile)); let routes = [RouteClass]; diff --git a/src/api/utils/QueryHelper.js b/src/api/utils/QueryHelper.js index 7fabd06..c26c8eb 100644 --- a/src/api/utils/QueryHelper.js +++ b/src/api/utils/QueryHelper.js @@ -2,16 +2,16 @@ const chrono = require('chrono-node'); class QueryHelper { static parsers = { - before: (val) => QueryHelper.parseChronoList(val), - after: (val) => QueryHelper.parseChronoList(val), - tag: (val) => QueryHelper.sanitizeTags(val) + before: val => QueryHelper.parseChronoList(val), + after: val => QueryHelper.parseChronoList(val), + tag: val => QueryHelper.sanitizeTags(val) }; static requirementHandlers = { - album: (knex) => knex + album: knex => knex .join('albumsFiles', 'files.id', '=', 'albumsFiles.fileId') .join('albums', 'albumsFiles.albumId', '=', 'album.id'), - tag: (knex) => knex + tag: knex => knex .join('fileTags', 'files.id', '=', 'fileTags.fileId') .join('tags', 'fileTags.tagId', '=', 'tags.id') } @@ -93,11 +93,11 @@ class QueryHelper { } static parseChronoList(list) { - return list.map((e) => chrono.parse(e)); + return list.map(e => chrono.parse(e)); } static sanitizeTags(list) { - return list.map((e) => e.replace(/\s/g, '_')); + return list.map(e => e.replace(/\s/g, '_')); } static generateInclusionForTags(db, knex, list) { diff --git a/src/api/utils/ThumbUtil.js b/src/api/utils/ThumbUtil.js index 10a7cd9..254090d 100644 --- a/src/api/utils/ThumbUtil.js +++ b/src/api/utils/ThumbUtil.js @@ -53,7 +53,7 @@ class ThumbUtil { folder: ThumbUtil.squareThumbPath, size: '64x64' }) - .on('error', (error) => log.error(error.message)); + .on('error', error => log.error(error.message)); ffmpeg(filePath) .thumbnail({ @@ -62,7 +62,7 @@ class ThumbUtil { folder: ThumbUtil.thumbPath, size: '150x?' }) - .on('error', (error) => log.error(error.message)); + .on('error', error => log.error(error.message)); try { await previewUtil({ diff --git a/src/api/utils/videoPreview/FragmentPreview.js b/src/api/utils/videoPreview/FragmentPreview.js index 4f681fa..1d1ee02 100644 --- a/src/api/utils/videoPreview/FragmentPreview.js +++ b/src/api/utils/videoPreview/FragmentPreview.js @@ -25,7 +25,7 @@ const getStartTime = (vDuration, fDuration, ignoreBeforePercent, ignoreAfterPerc return getRandomInt(ignoreBeforePercent * safeVDuration, ignoreAfterPercent * safeVDuration); }; -module.exports = async (opts) => { +module.exports = async opts => { const { log = noop, @@ -78,7 +78,7 @@ module.exports = async (opts) => { .outputOptions([`-t ${fragmentDurationSecond}`]) .noAudio() .output(output) - .on('start', (cmd) => log && log({ cmd })) + .on('start', cmd => log && log({ cmd })) .on('end', resolve) .on('error', reject) .run(); diff --git a/src/api/utils/videoPreview/FrameIntervalPreview.js b/src/api/utils/videoPreview/FrameIntervalPreview.js index 8bb9836..96c6e3a 100644 --- a/src/api/utils/videoPreview/FrameIntervalPreview.js +++ b/src/api/utils/videoPreview/FrameIntervalPreview.js @@ -4,7 +4,7 @@ const probe = require('ffmpeg-probe'); const noop = () => {}; -module.exports = async (opts) => { +module.exports = async opts => { const { log = noop, @@ -22,7 +22,7 @@ module.exports = async (opts) => { const info = await probe(input); // const numFramesTotal = parseInt(info.streams[0].nb_frames, 10); const { avg_frame_rate: avgFrameRate, duration } = info.streams[0]; - const [frames, time] = avgFrameRate.split('/').map((e) => parseInt(e, 10)); + const [frames, time] = avgFrameRate.split('/').map(e => parseInt(e, 10)); const numFramesTotal = (frames / time) * duration; @@ -63,9 +63,9 @@ module.exports = async (opts) => { .noAudio() .outputFormat('webm') .output(output) - .on('start', (cmd) => log && log({ cmd })) + .on('start', cmd => log && log({ cmd })) .on('end', () => resolve()) - .on('error', (err) => reject(err)) + .on('error', err => reject(err)) .run(); }); diff --git a/src/site/components/album/AlbumDetails.vue b/src/site/components/album/AlbumDetails.vue index 4067853..f81e257 100644 --- a/src/site/components/album/AlbumDetails.vue +++ b/src/site/components/album/AlbumDetails.vue @@ -119,12 +119,12 @@ import { mapState, mapActions } from 'vuex'; export default { props: { albumId: { - type: Number, - default: 0 + 'type': Number, + 'default': 0 }, details: { - type: Object, - default: () => ({}) + 'type': Object, + 'default': () => ({}) } }, data() { @@ -175,7 +175,7 @@ export default { } catch (e) { this.alert({ text: e.message, error: true }); } finally { - this.isDeletingLinks = this.isDeletingLinks.filter((e) => e !== identifier); + this.isDeletingLinks = this.isDeletingLinks.filter(e => e !== identifier); } }, async createLink(albumId) { @@ -207,7 +207,7 @@ export default { maxlength: 10 }, trapFocus: true, - onConfirm: (value) => this.$handler.executeAction('albums/createCustomLink', { albumId, value }) + onConfirm: value => this.$handler.executeAction('albums/createCustomLink', { albumId, value }) }); }, isDeleting(identifier) { diff --git a/src/site/components/album/AlbumEntry.vue b/src/site/components/album/AlbumEntry.vue index 1e1b2cf..18633c4 100644 --- a/src/site/components/album/AlbumEntry.vue +++ b/src/site/components/album/AlbumEntry.vue @@ -53,7 +53,7 @@ <AlbumDetails v-if="isExpanded" :details="getDetails(album.id)" - :albumId="album.id" /> + :album-id="album.id" /> </div> </template> @@ -67,8 +67,8 @@ export default { }, props: { album: { - type: Object, - default: () => ({}) + 'type': Object, + 'default': () => ({}) } }, computed: { diff --git a/src/site/components/footer/Footer.vue b/src/site/components/footer/Footer.vue index b409cf5..aa54dce 100644 --- a/src/site/components/footer/Footer.vue +++ b/src/site/components/footer/Footer.vue @@ -54,6 +54,8 @@ </div> <div class="column"> <a href="https://github.com/weebdev/lolisafe">GitHub</a> + <a href="https://patreon.com/pitu">Patreon</a> + <a href="https://discord.gg/5g6vgwn">Discord</a> </div> <div class="column"> <a @@ -79,9 +81,9 @@ export default { computed: { ...mapGetters({ loggedIn: 'auth/isLoggedIn' }), ...mapState({ - version: (state) => state.config.version, - serviceName: (state) => state.config.serviceName, - token: (state) => state.auth.token + version: state => state.config.version, + serviceName: state => state.config.serviceName, + token: state => state.auth.token }) }, methods: { diff --git a/src/site/components/grid/Grid.vue b/src/site/components/grid/Grid.vue index ea568f0..0693c77 100644 --- a/src/site/components/grid/Grid.vue +++ b/src/site/components/grid/Grid.vue @@ -23,10 +23,10 @@ <template v-if="!images.showList"> <Waterfall - :gutterWidth="10" - :gutterHeight="4" + :gutter-width="10" + :gutter-height="4" :options="{fitWidth: true}" - :itemWidth="width" + :item-width="width" :items="gridFiles"> <template v-slot="{item}"> <template v-if="isPublic"> @@ -165,32 +165,32 @@ export default { }, props: { files: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] }, total: { - type: Number, - default: 0 + 'type': Number, + 'default': 0 }, fixed: { - type: Boolean, - default: false + 'type': Boolean, + 'default': false }, isPublic: { - type: Boolean, - default: false + 'type': Boolean, + 'default': false }, width: { - type: Number, - default: 150 + 'type': Number, + 'default': 150 }, enableSearch: { - type: Boolean, - default: true + 'type': Boolean, + 'default': true }, enableToolbar: { - type: Boolean, - default: true + 'type': Boolean, + 'default': true } }, data() { @@ -212,16 +212,16 @@ export default { }, computed: { ...mapState({ - user: (state) => state.auth.user, - albums: (state) => state.albums.tinyDetails, - images: (state) => state.images + user: state => state.auth.user, + albums: state => state.albums.tinyDetails, + images: state => state.images }), blank() { // eslint-disable-next-line global-require, import/no-unresolved return require('@/assets/images/blank.png'); }, gridFiles() { - return (this.files || []).filter((v) => !v.hideFromList); + return (this.files || []).filter(v => !v.hideFromList); } }, watch: { @@ -259,8 +259,8 @@ export default { }, isAlbumSelected(id) { if (!this.showingModalForFile) return false; - const found = this.showingModalForFile.albums.find((el) => el.id === id); - return !!(found && found.id); + const found = this.showingModalForFile.albums.find(el => el.id === id); + return Boolean(found && found.id); }, async openAlbumModal(file) { const { id } = file; diff --git a/src/site/components/grid/waterfall/Waterfall.vue b/src/site/components/grid/waterfall/Waterfall.vue index af2af3f..5a4c569 100644 --- a/src/site/components/grid/waterfall/Waterfall.vue +++ b/src/site/components/grid/waterfall/Waterfall.vue @@ -24,24 +24,24 @@ export default { }, props: { options: { - type: Object, - default: () => {} + 'type': Object, + 'default': () => {} }, items: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] }, itemWidth: { - type: Number, - default: 150 + 'type': Number, + 'default': 150 }, gutterWidth: { - type: Number, - default: 10 + 'type': Number, + 'default': 10 }, gutterHeight: { - type: Number, - default: 4 + 'type': Number, + 'default': 4 } }, mounted() { @@ -84,20 +84,20 @@ export default { this.masonry.layout(); }, diffDomChildren() { - const oldChildren = this.domChildren.filter((element) => !!element.parentNode); + const oldChildren = this.domChildren.filter(element => Boolean(element.parentNode)); const newChildren = this.getNewDomChildren(); - const removed = oldChildren.filter((oldChild) => !newChildren.includes(oldChild)); - const domDiff = newChildren.filter((newChild) => !oldChildren.includes(newChild)); + const removed = oldChildren.filter(oldChild => !newChildren.includes(oldChild)); + const domDiff = newChildren.filter(newChild => !oldChildren.includes(newChild)); const prepended = domDiff.filter((newChild, index) => newChildren[index] === newChild); - const appended = domDiff.filter((el) => !prepended.includes(el)); + const appended = domDiff.filter(el => !prepended.includes(el)); let moved = []; if (removed.length === 0) { moved = oldChildren.filter((child, index) => index !== newChildren.indexOf(child)); } this.domChildren = newChildren; return { - old: oldChildren, - new: newChildren, + 'old': oldChildren, + 'new': newChildren, removed, appended, prepended, @@ -120,15 +120,10 @@ export default { getNewDomChildren() { const node = this.$refs.waterfall; const children = this.options && this.options.itemSelector - ? node.querySelectorAll(this.options.itemSelector) : node.children; + ? node.querySelectorAll(this.options.itemSelector) + : node.children; return Array.prototype.slice.call(children); } } }; </script> - -<style lang="scss" scoped> -.wfi { - -} -</style> diff --git a/src/site/components/image-modal/AlbumInfo.vue b/src/site/components/image-modal/AlbumInfo.vue index 17c375a..8aeb02e 100644 --- a/src/site/components/image-modal/AlbumInfo.vue +++ b/src/site/components/image-modal/AlbumInfo.vue @@ -24,22 +24,20 @@ </template> <script> -import { mapState } from 'vuex'; - export default { name: 'Albuminfo', props: { imageId: { - type: Number, - default: 0 + 'type': Number, + 'default': 0 }, imageAlbums: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] }, albums: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] } }, data() { @@ -52,7 +50,7 @@ export default { this.orderedAlbums = this.getOrderedAlbums(); // we're sorting here instead of computed because we want sort on creation // then the array's values should be frozen - this.selectedOptions = this.imageAlbums.map((e) => e.id); + this.selectedOptions = this.imageAlbums.map(e => e.id); }, methods: { getOrderedAlbums() { @@ -70,8 +68,8 @@ export default { }, isAlbumSelected(id) { if (!this.showingModalForFile) return false; - const found = this.showingModalForFile.albums.find((el) => el.id === id); - return !!(found && found.id); + const found = this.showingModalForFile.albums.find(el => el.id === id); + return Boolean(found && found.id); }, async handleClick(id) { // here the album should be already removed from the selected list diff --git a/src/site/components/image-modal/ImageInfo.vue b/src/site/components/image-modal/ImageInfo.vue index 73b6339..07c87b5 100644 --- a/src/site/components/image-modal/ImageInfo.vue +++ b/src/site/components/image-modal/ImageInfo.vue @@ -97,12 +97,12 @@ <div class="divider is-lolisafe has-text-light"> Tags </div> - <Taginfo :imageId="file.id" :imageTags="tags" /> + <Taginfo :image-id="file.id" :image-tags="tags" /> <div class="divider is-lolisafe has-text-light"> Albums </div> - <Albuminfo :imageId="file.id" :imageAlbums="albums" :albums="tinyDetails" /> + <Albuminfo :image-id="file.id" :image-albums="albums" :albums="tinyDetails" /> </div> </div> </div> @@ -122,21 +122,21 @@ export default { }, props: { file: { - type: Object, - default: () => ({}) + 'type': Object, + 'default': () => ({}) }, albums: { - type: Array, - default: () => ([]) + 'type': Array, + 'default': () => ([]) }, tags: { - type: Array, - default: () => ([]) + 'type': Array, + 'default': () => ([]) } }, computed: mapState({ - images: (state) => state.images, - tinyDetails: (state) => state.albums.tinyDetails + images: state => state.images, + tinyDetails: state => state.albums.tinyDetails }), methods: { formatBytes(bytes, decimals = 2) { @@ -148,6 +148,7 @@ export default { const i = Math.floor(Math.log(bytes) / Math.log(k)); + // eslint-disable-next-line no-mixed-operators return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; }, isVideo(type) { diff --git a/src/site/components/image-modal/TagInfo.vue b/src/site/components/image-modal/TagInfo.vue index 59d01f5..756a32d 100644 --- a/src/site/components/image-modal/TagInfo.vue +++ b/src/site/components/image-modal/TagInfo.vue @@ -22,12 +22,12 @@ export default { name: 'Taginfo', props: { imageId: { - type: Number, - default: 0 + 'type': Number, + 'default': 0 }, imageTags: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] } }, data() { @@ -37,14 +37,14 @@ export default { }, computed: { ...mapState({ - tags: (state) => state.tags.tagsList + tags: state => state.tags.tagsList }), - selectedTags() { return this.imageTags.map((e) => e.name); }, - lowercaseTags() { return this.imageTags.map((e) => e.name.toLowerCase()); } + selectedTags() { return this.imageTags.map(e => e.name); }, + lowercaseTags() { return this.imageTags.map(e => e.name.toLowerCase()); } }, methods: { getFilteredTags(str) { - this.filteredTags = this.tags.map((e) => e.name).filter((e) => { + this.filteredTags = this.tags.map(e => e.name).filter(e => { // check if the search string matches any of the tags const sanitezedTag = e.toString().toLowerCase(); const matches = sanitezedTag.indexOf(str.toLowerCase()) >= 0; diff --git a/src/site/components/loading/CubeShadow.vue b/src/site/components/loading/CubeShadow.vue index 71b5da5..7aeed65 100644 --- a/src/site/components/loading/CubeShadow.vue +++ b/src/site/components/loading/CubeShadow.vue @@ -8,16 +8,16 @@ export default { props: { size: { - type: String, - default: '60px' + 'type': String, + 'default': '60px' }, background: { - type: String, - default: '#9C27B0' + 'type': String, + 'default': '#9C27B0' }, duration: { - type: String, - default: '1.8s' + 'type': String, + 'default': '1.8s' } }, computed: { diff --git a/src/site/components/loading/Origami.vue b/src/site/components/loading/Origami.vue index 59c5d8f..1c7a4c3 100644 --- a/src/site/components/loading/Origami.vue +++ b/src/site/components/loading/Origami.vue @@ -19,8 +19,8 @@ export default { props: { size: { - type: String, - default: '40px' + 'type': String, + 'default': '40px' } }, computed: { diff --git a/src/site/components/loading/PingPong.vue b/src/site/components/loading/PingPong.vue index c04ae72..bab33d5 100644 --- a/src/site/components/loading/PingPong.vue +++ b/src/site/components/loading/PingPong.vue @@ -18,8 +18,8 @@ export default { props: { size: { - type: String, - default: '60px' + 'type': String, + 'default': '60px' } }, computed: { diff --git a/src/site/components/loading/RotateSquare.vue b/src/site/components/loading/RotateSquare.vue index 7bc9bb0..b7967ec 100644 --- a/src/site/components/loading/RotateSquare.vue +++ b/src/site/components/loading/RotateSquare.vue @@ -8,8 +8,8 @@ export default { props: { size: { - type: String, - default: '40px' + 'type': String, + 'default': '40px' } }, computed: { diff --git a/src/site/components/navbar/Navbar.vue b/src/site/components/navbar/Navbar.vue index 22d41d4..c0b8668 100644 --- a/src/site/components/navbar/Navbar.vue +++ b/src/site/components/navbar/Navbar.vue @@ -72,8 +72,8 @@ import { mapState, mapGetters } from 'vuex'; export default { props: { isWhite: { - type: Boolean, - default: false + 'type': Boolean, + 'default': false } }, data() { diff --git a/src/site/components/search-input/SearchInput.vue b/src/site/components/search-input/SearchInput.vue index 1c5b983..10728a0 100644 --- a/src/site/components/search-input/SearchInput.vue +++ b/src/site/components/search-input/SearchInput.vue @@ -89,12 +89,12 @@ export default { props: { value: [Number, String], data: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] }, field: { - type: String, - default: 'value' + 'type': String, + 'default': 'value' }, keepFirst: Boolean, clearOnSelect: Boolean, @@ -105,8 +105,8 @@ export default { clearable: Boolean, maxHeight: [String, Number], dropdownPosition: { - type: String, - default: 'auto' + 'type': String, + 'default': 'auto' }, iconRight: String, iconRightClickable: Boolean, @@ -159,25 +159,25 @@ export default { * Check if exists default slot */ hasDefaultSlot() { - return !!this.$scopedSlots.default; + return Boolean(this.$scopedSlots.default); }, /** * Check if exists "empty" slot */ hasEmptySlot() { - return !!this.$slots.empty; + return Boolean(this.$slots.empty); }, /** * Check if exists "header" slot */ hasHeaderSlot() { - return !!this.$slots.header; + return Boolean(this.$slots.header); }, /** * Check if exists "footer" slot */ hasFooterSlot() { - return !!this.$slots.footer; + return Boolean(this.$slots.footer); }, /** * Apply dropdownPosition property @@ -202,7 +202,8 @@ export default { // eslint-disable-next-line no-nested-ternary maxHeight: this.maxHeight === undefined // eslint-disable-next-line no-restricted-globals - ? null : (isNaN(this.maxHeight) ? this.maxHeight : `${this.maxHeight}px`) + ? null + : (isNaN(this.maxHeight) ? this.maxHeight : `${this.maxHeight}px`) }; } }, @@ -239,7 +240,7 @@ export default { } // Close dropdown if input is clear or else open it if (this.hasFocus && (!this.openOnFocus || value)) { - this.isActive = !!value; + this.isActive = Boolean(value); } }, /** @@ -378,8 +379,8 @@ export default { * reached it's end. */ checkIfReachedTheEndOfScroll(list) { - if (list.clientHeight !== list.scrollHeight - && list.scrollTop + list.clientHeight >= list.scrollHeight) { + if (list.clientHeight !== list.scrollHeight && + list.scrollTop + list.clientHeight >= list.scrollHeight) { this.$emit('infinite-scroll'); } }, @@ -396,9 +397,9 @@ export default { if (this.$refs.dropdown === undefined) return; const rect = this.$refs.dropdown.getBoundingClientRect(); this.isListInViewportVertically = ( - rect.top >= 0 - && rect.bottom <= (window.innerHeight - || document.documentElement.clientHeight) + rect.top >= 0 && + rect.bottom <= (window.innerHeight || + document.documentElement.clientHeight) ); if (this.appendToBody) { this.updateAppendToBody(); @@ -425,9 +426,9 @@ export default { list.scrollTop = element.offsetTop; } else if (element.offsetTop >= visMax) { list.scrollTop = ( - element.offsetTop - - list.clientHeight - + element.clientHeight + element.offsetTop - + list.clientHeight + + element.clientHeight ); } } else { @@ -487,7 +488,7 @@ export default { if (dropdownMenu && trigger) { // update wrapper dropdown const root = this.$data._bodyEl; - root.classList.forEach((item) => root.classList.remove(item)); + root.classList.forEach(item => root.classList.remove(item)); root.classList.add('autocomplete'); root.classList.add('control'); if (this.expandend) { @@ -496,10 +497,10 @@ export default { const rect = trigger.getBoundingClientRect(); let top = rect.top + window.scrollY; const left = rect.left + window.scrollX; - if (!this.isOpenedTop) { - top += trigger.clientHeight; - } else { + if (this.isOpenedTop) { top -= dropdownMenu.clientHeight; + } else { + top += trigger.clientHeight; } this.style = { position: 'absolute', diff --git a/src/site/components/search/Search.vue b/src/site/components/search/Search.vue index 778474c..2c4e3bc 100644 --- a/src/site/components/search/Search.vue +++ b/src/site/components/search/Search.vue @@ -6,7 +6,7 @@ ref="autocomplete" v-model="query" :data="filteredHints" - :customSelector="handleSelect" + :custom-selector="handleSelect" field="name" class="lolisafe-input search" placeholder="Search" @@ -40,8 +40,8 @@ export default { }, props: { hiddenHints: { - type: Array, - default: () => [] + 'type': Array, + 'default': () => [] } }, data() { @@ -49,34 +49,34 @@ export default { query: '', hints: [ { - 'name': 'tag', - 'valueFormat': 'name', - 'hint': '' + name: 'tag', + valueFormat: 'name', + hint: '' }, { - 'name': 'album', - 'valueFormat': 'name', - 'hint': '' + name: 'album', + valueFormat: 'name', + hint: '' }, { - 'name': 'before', - 'valueFormat': 'specific date', - 'hint': '' + name: 'before', + valueFormat: 'specific date', + hint: '' }, { - 'name': 'during', - 'valueFormat': 'specific date', - 'hint': '' + name: 'during', + valueFormat: 'specific date', + hint: '' }, { - 'name': 'after', - 'valueFormat': 'specific date', - 'hint': '' + name: 'after', + valueFormat: 'specific date', + hint: '' }, { - 'name': 'file', - 'valueFormat': 'generated name', - 'hint': '' + name: 'file', + valueFormat: 'generated name', + hint: '' } ], filteredHints: [] @@ -98,13 +98,22 @@ export default { // get the last word or group of words let lastWord = (qry.match(/("[^"]*")|[^\s]+/g) || ['']).pop().toLowerCase(); // if there's an open/unbalanced quote, don't autosuggest - if (/^[^"]*("[^"]*"[^"]*)*(")[^"]*$/.test(qry)) { this.filteredHints = []; return; } + if (/^[^"]*("[^"]*"[^"]*)*(")[^"]*$/.test(qry)) { + this.filteredHints = []; + return; + } // don't autosuggest if we have an open query but no text yet - if (/:\s+$/gi.test(qry)) { this.filteredHints = []; return; } + if (/:\s+$/gi.test(qry)) { + this.filteredHints = []; + return; + } // if the above query didn't match (all quotes are balanced // and the previous tag has value // check if we're about to start a new tag - if (/\s+$/gi.test(qry)) { this.filteredHints = this.hints; return; } + if (/\s+$/gi.test(qry)) { + this.filteredHints = this.hints; + return; + } // ignore starting `-` from lastword, because - is used to // exclude something, so -alb should autosuggest album @@ -112,7 +121,7 @@ export default { // if we got here, then we handled all special cases // now take last word, and check if we can autosuggest a tag - this.filteredHints = this.hints.filter((hint) => hint.name + this.filteredHints = this.hints.filter(hint => hint.name .toString() .toLowerCase() .indexOf(lastWord) === 0); diff --git a/src/site/components/sidebar/Sidebar.vue b/src/site/components/sidebar/Sidebar.vue index e0c8fa2..8d96712 100644 --- a/src/site/components/sidebar/Sidebar.vue +++ b/src/site/components/sidebar/Sidebar.vue @@ -48,7 +48,7 @@ import { mapState } from 'vuex'; export default { computed: mapState({ - user: (state) => state.auth.user + user: state => state.auth.user }), methods: { isRouteActive(id) { diff --git a/src/site/components/uploader/Uploader.vue b/src/site/components/uploader/Uploader.vue index 2740bee..94d4003 100644 --- a/src/site/components/uploader/Uploader.vue +++ b/src/site/components/uploader/Uploader.vue @@ -93,8 +93,8 @@ export default { }, computed: { ...mapState({ - config: (state) => state.config, - albums: (state) => state.albums.tinyDetails + config: state => state.config, + albums: state => state.albums.tinyDetails }), ...mapGetters({ loggedIn: 'auth/isLoggedIn', token: 'auth/getToken' }) }, diff --git a/src/site/layouts/default.vue b/src/site/layouts/default.vue index 3fa7ebd..b2b2633 100644 --- a/src/site/layouts/default.vue +++ b/src/site/layouts/default.vue @@ -3,7 +3,7 @@ v-bar class="scroll-area"> <div class="default-body"> - <Navbar :isWhite="true" /> + <Navbar :is-white="true" /> <nuxt-child id="app" class="nuxt-app is-height-max-content" /> @@ -23,7 +23,7 @@ export default { }, computed: mapState(['config', 'alert']), created() { - this.$store.watch((state) => state.alert.message, () => { + this.$store.watch(state => state.alert.message, () => { const { message, type, snackbar } = this.alert; if (!message) return; diff --git a/src/site/layouts/error.vue b/src/site/layouts/error.vue index 77d188f..28f3036 100644 --- a/src/site/layouts/error.vue +++ b/src/site/layouts/error.vue @@ -10,7 +10,7 @@ <template> <section class="hero is-fullheight"> - <Navbar :isWhite="true" /> + <Navbar :is-white="true" /> <div class="hero-body"> <div class="container"> <h2>404エラ</h2> diff --git a/src/site/middleware/admin.js b/src/site/middleware/admin.js index 1a94b75..9a99153 100644 --- a/src/site/middleware/admin.js +++ b/src/site/middleware/admin.js @@ -1,4 +1,4 @@ -export default function ({ store, redirect }) { +export default function({ store, redirect }) { // If the user is not authenticated if (!store.state.auth.user) return redirect('/login'); if (!store.state.auth.user.isAdmin) return redirect('/dashboard'); diff --git a/src/site/middleware/auth.js b/src/site/middleware/auth.js index b2ecc68..020326f 100644 --- a/src/site/middleware/auth.js +++ b/src/site/middleware/auth.js @@ -1,4 +1,4 @@ -export default function ({ store, redirect }) { +export default function({ store, redirect }) { // If the user is not authenticated if (!store.state.auth.loggedIn) { return redirect('/login'); diff --git a/src/site/pages/a/_identifier.vue b/src/site/pages/a/_identifier.vue index 0c6261a..c1e6179 100644 --- a/src/site/pages/a/_identifier.vue +++ b/src/site/pages/a/_identifier.vue @@ -36,10 +36,10 @@ <Grid v-if="files && files.length" :files="files" - :isPublic="true" + :is-public="true" :width="200" - :enableSearch="false" - :enableToolbar="false" /> + :enable-search="false" + :enable-toolbar="false" /> </div> </template> <template v-else> diff --git a/src/site/pages/dashboard/account.vue b/src/site/pages/dashboard/account.vue index 5610495..8a8249d 100644 --- a/src/site/pages/dashboard/account.vue +++ b/src/site/pages/dashboard/account.vue @@ -115,9 +115,9 @@ export default { }; }, computed: { - ...mapGetters({ 'apiKey': 'auth/getApiKey' }), + ...mapGetters({ apiKey: 'auth/getApiKey' }), ...mapState({ - user: (state) => state.auth.user + user: state => state.auth.user }) }, metaInfo() { diff --git a/src/site/pages/dashboard/admin/file/_id.vue b/src/site/pages/dashboard/admin/file/_id.vue index d54bf54..135d066 100644 --- a/src/site/pages/dashboard/admin/file/_id.vue +++ b/src/site/pages/dashboard/admin/file/_id.vue @@ -168,6 +168,7 @@ export default { const i = Math.floor(Math.log(bytes) / Math.log(k)); + // eslint-disable-next-line no-mixed-operators return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; } } diff --git a/src/site/pages/dashboard/admin/settings.vue b/src/site/pages/dashboard/admin/settings.vue index c6a9ade..0ec235c 100644 --- a/src/site/pages/dashboard/admin/settings.vue +++ b/src/site/pages/dashboard/admin/settings.vue @@ -145,7 +145,7 @@ export default { return { title: 'Settings' }; }, computed: mapState({ - settings: (state) => state.admin.settings + settings: state => state.admin.settings }), methods: { promptRestartService() { diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue index 484d986..0ed3e86 100644 --- a/src/site/pages/dashboard/admin/user/_id.vue +++ b/src/site/pages/dashboard/admin/user/_id.vue @@ -92,7 +92,7 @@ export default { }; }, computed: mapState({ - user: (state) => state.admin.user + user: state => state.admin.user }), methods: { promptDisableUser() { diff --git a/src/site/pages/dashboard/admin/users.vue b/src/site/pages/dashboard/admin/users.vue index a13564c..e52476a 100644 --- a/src/site/pages/dashboard/admin/users.vue +++ b/src/site/pages/dashboard/admin/users.vue @@ -102,8 +102,8 @@ export default { } }], computed: mapState({ - users: (state) => state.admin.users, - config: (state) => state.config + users: state => state.admin.users, + config: state => state.config }), metaInfo() { return { title: 'Uploads' }; diff --git a/src/site/pages/dashboard/albums/index.vue b/src/site/pages/dashboard/albums/index.vue index 896d134..4f2f3e1 100644 --- a/src/site/pages/dashboard/albums/index.vue +++ b/src/site/pages/dashboard/albums/index.vue @@ -74,7 +74,7 @@ export default { }, methods: { ...mapActions({ - 'alert': 'alert/set' + alert: 'alert/set' }), async createAlbum() { if (!this.newAlbumName || this.newAlbumName === '') return; diff --git a/src/site/pages/dashboard/index.vue b/src/site/pages/dashboard/index.vue index 41605f9..0b60cdc 100644 --- a/src/site/pages/dashboard/index.vue +++ b/src/site/pages/dashboard/index.vue @@ -27,7 +27,7 @@ <Grid v-if="totalFiles && !isLoading" :files="images.files" - :enableSearch="false" + :enable-search="false" class="grid"> <template v-slot:pagination> <b-pagination @@ -112,6 +112,7 @@ export default { this.search = query; const sanitizedQ = this.sanitizeQuery(query); + // eslint-disable-next-line no-negated-condition if (!sanitizedQ.length) { this.current = 1; await this.fetch(this.current); diff --git a/src/site/plugins/axios.js b/src/site/plugins/axios.js index 98bec5c..e252425 100644 --- a/src/site/plugins/axios.js +++ b/src/site/plugins/axios.js @@ -1,13 +1,13 @@ -export default function ({ $axios, store }) { +export default function({ $axios, store }) { $axios.setHeader('accept', 'application/vnd.lolisafe.json'); - $axios.onRequest((config) => { + $axios.onRequest(config => { if (store.state.auth.token) { config.headers.common.Authorization = `bearer ${store.state.auth.token}`; } }); - $axios.onError((error) => { + $axios.onError(error => { if (process.env.NODE_ENV !== 'production') console.error('[AXIOS Error]', error); if (process.browser) { if (process.env.NODE_ENV !== 'production') { diff --git a/src/site/plugins/flexsearch.js b/src/site/plugins/flexsearch.js index 1c06c8d..2e1df36 100644 --- a/src/site/plugins/flexsearch.js +++ b/src/site/plugins/flexsearch.js @@ -6,11 +6,11 @@ const search = new FlexSearch('speed'); // https://github.com/nextapps-de/flexsearch Vue.prototype.$search = { - items: async (items) => { + 'items': async items => { await search.clear(); await search.add(items); }, - do: async (term, field) => { + 'do': async (term, field) => { const results = await search.search(term, { field }); return results; } diff --git a/src/site/plugins/nuxt-client-init.js b/src/site/plugins/nuxt-client-init.js index 01f33ff..4b10dcd 100644 --- a/src/site/plugins/nuxt-client-init.js +++ b/src/site/plugins/nuxt-client-init.js @@ -1,3 +1,3 @@ -export default async (ctx) => { +export default async ctx => { await ctx.store.dispatch('nuxtClientInit', ctx); }; diff --git a/src/site/store/albums.js b/src/site/store/albums.js index 4f796a1..8be0230 100644 --- a/src/site/store/albums.js +++ b/src/site/store/albums.js @@ -9,8 +9,8 @@ export const state = () => ({ }); export const getters = { - isExpanded: (state) => (id) => state.expandedAlbums.indexOf(id) > -1, - getDetails: (state) => (id) => state.albumDetails[id] || {} + isExpanded: state => id => state.expandedAlbums.indexOf(id) > -1, + getDetails: state => id => state.albumDetails[id] || {} }; export const actions = { diff --git a/src/site/store/auth.js b/src/site/store/auth.js index 85e3a39..51a79d6 100644 --- a/src/site/store/auth.js +++ b/src/site/store/auth.js @@ -11,9 +11,9 @@ const getDefaultState = () => ({ export const state = getDefaultState; export const getters = { - isLoggedIn: (state) => state.loggedIn, - getApiKey: (state) => state.user?.apiKey, - getToken: (state) => state.token + isLoggedIn: state => state.loggedIn, + getApiKey: state => state.user?.apiKey, + getToken: state => state.token }; export const actions = { |