diff options
author | Dashie <dashie@sigpipe.me> | 2019-12-13 10:16:22 +0100 |
---|---|---|
committer | Dashie <dashie@sigpipe.me> | 2019-12-13 10:16:22 +0100 |
commit | 418a5f1c35a9a2d111a1949dc13cae46b0a4066e (patch) | |
tree | 45ddc8a74db29dc40e29f2564fd8b0820d415ddb /front | |
parent | da58fd77fa9ca63d13b5d6e119957bb89d81e91b (diff) |
Bump eslint-config-standard and fixes
Diffstat (limited to 'front')
38 files changed, 132 insertions, 152 deletions
diff --git a/front/.eslintrc.js b/front/.eslintrc.js index 92e1ac26..ba72be85 100644 --- a/front/.eslintrc.js +++ b/front/.eslintrc.js @@ -51,6 +51,8 @@ module.exports = { "allowFirstLine": true } }], - 'vue/require-default-prop': 0 + 'vue/require-default-prop': 0, + 'no-async-promise-executor': 0, + 'no-prototype-builtins': 0 } } diff --git a/front/package.json b/front/package.json index 3eebfb90..d31f9740 100644 --- a/front/package.json +++ b/front/package.json @@ -52,7 +52,7 @@ "@vue/cli-plugin-babel": "^4.1.1", "@vue/cli-plugin-eslint": "^4.1.1", "@vue/cli-service": "^3.12.0", - "@vue/eslint-config-standard": "^4.0.0", + "@vue/eslint-config-standard": "^5.0.1", "@vue/test-utils": "^1.0.0-beta.30", "babel-core": "^6.0.0", "babel-eslint": "^10.0.3", diff --git a/front/src/App.vue b/front/src/App.vue index fbb82724..8d5a379a 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -110,7 +110,7 @@ export default { sitename () { return this.$store.state.instance.name }, atUsername () { return '@' + this.currentUser.screen_name }, usernameAvatar () { - let msg = this.$pgettext('Header/*/Image/Avatar alt', '%{username} avatar') + const msg = this.$pgettext('Header/*/Image/Avatar alt', '%{username} avatar') return this.$gettextInterpolate(msg, { username: this.currentUser.screen_name }) }, labels () { @@ -148,12 +148,12 @@ export default { if (newValue === 'en_us') { return this.$store.dispatch('setOption', { name: 'momentLocale', value: 'en' }) } - let momentLocale = newValue.replace('_', '-').toLowerCase() + const momentLocale = newValue.replace('_', '-').toLowerCase() import(`moment/locale/${momentLocale}.js`).then(() => { this.$store.dispatch('setOption', { name: 'momentLocale', value: momentLocale }) }).catch(() => { console.log('No momentjs locale available for', momentLocale) - let shortLocale = momentLocale.split('-')[0] + const shortLocale = momentLocale.split('-')[0] import(`moment/locale/${shortLocale}.js`).then(() => { this.$store.dispatch('setOption', { name: 'momentLocale', value: shortLocale }) }).catch(() => { @@ -181,13 +181,13 @@ export default { return } console.log('user not logged in, detecting language...') - let userLanguage = navigator.language || navigator.userLanguage - let available = locales.locales.map(e => { return e.code }) + const userLanguage = navigator.language || navigator.userLanguage + const available = locales.locales.map(e => { return e.code }) let candidate - let matching = available.filter((a) => { + const matching = available.filter((a) => { return userLanguage.replace('-', '_') === a }) - let almostMatching = available.filter((a) => { + const almostMatching = available.filter((a) => { return userLanguage.replace('-', '_').split('_')[0] === a.split('_')[0] }) if (matching.length > 0) { diff --git a/front/src/backend/oauth/oauth.js b/front/src/backend/oauth/oauth.js index fc0ca11b..c2ab962d 100644 --- a/front/src/backend/oauth/oauth.js +++ b/front/src/backend/oauth/oauth.js @@ -11,7 +11,7 @@ export const getOrCreateApp = ({ clientId, clientSecret, commit }) => { } console.debug('registering a new app') - const url = `/api/v1/apps` + const url = '/api/v1/apps' const form = new window.FormData() form.append('client_name', `reel2bit_front_${window.___reel2bitsfe_commit_hash}_${(new Date()).toISOString()}`) @@ -52,7 +52,7 @@ const login = ({ clientId }) => { // Used on : login const getTokenWithCredentials = ({ clientId, clientSecret, username, password }) => { console.debug('getTokenWithCredentials') - const url = `/oauth/token` + const url = '/oauth/token' const form = new window.FormData() form.append('client_id', clientId) @@ -70,7 +70,7 @@ const getTokenWithCredentials = ({ clientId, clientSecret, username, password }) const getToken = ({ clientId, clientSecret, code }) => { console.debug('getToken') - const url = `/oauth/token` + const url = '/oauth/token' const form = new window.FormData() form.append('client_id', clientId) @@ -89,7 +89,7 @@ const getToken = ({ clientId, clientSecret, code }) => { export const getClientToken = ({ clientId, clientSecret }) => { console.debug('getClientToken') - const url = `/oauth/token` + const url = '/oauth/token' const form = new window.FormData() form.append('client_id', clientId) @@ -105,7 +105,7 @@ export const getClientToken = ({ clientId, clientSecret }) => { } const revokeToken = ({ app, token }) => { - const url = `/oauth/revoke` + const url = '/oauth/revoke' const form = new window.FormData() form.append('client_id', app.clientId) @@ -115,7 +115,7 @@ const revokeToken = ({ app, token }) => { const auth = window.btoa(token) return window.fetch(url, { - headers: { 'Authorization': `Basic ${auth}` }, + headers: { Authorization: `Basic ${auth}` }, method: 'POST', body: form }).then((data) => data.json()) diff --git a/front/src/boot/after_store.js b/front/src/boot/after_store.js index 9b7e227a..2378e8d0 100644 --- a/front/src/boot/after_store.js +++ b/front/src/boot/after_store.js @@ -9,7 +9,7 @@ import backendInteractorService from '../services/backend_interactor_service/bac const getNodeInfo = async ({ store }) => { try { - const res = await window.fetch(`/nodeinfo/2.1`) + const res = await window.fetch('/nodeinfo/2.1') if (res.ok) { const data = await res.json() store.dispatch('setInstanceOption', { name: 'registrationOpen', value: data.openRegistrations }) diff --git a/front/src/boot/routes.js b/front/src/boot/routes.js index 27a65c22..6457561c 100644 --- a/front/src/boot/routes.js +++ b/front/src/boot/routes.js @@ -32,7 +32,8 @@ export default (store) => { // On new routes, don't forget to update utile.py::forbidden_username list return [ - { name: 'home', + { + name: 'home', path: '/', redirect: _to => { return (store.state.users.currentUser diff --git a/front/src/components/album/album.vue b/front/src/components/album/album.vue index ae6ee070..9fb848dc 100644 --- a/front/src/components/album/album.vue +++ b/front/src/components/album/album.vue @@ -87,7 +87,7 @@ const Album = { changeCurrentTrack (trackId) { console.log(`changing track by id ${trackId}`) // Find track - let track = this.album.tracks.find(t => t.id === trackId) + const track = this.album.tracks.find(t => t.id === trackId) if (track) { console.log(track) this.currentTrack = track diff --git a/front/src/components/content_audio_player/content_audio_player.vue b/front/src/components/content_audio_player/content_audio_player.vue index 82d79746..caa0a7ec 100644 --- a/front/src/components/content_audio_player/content_audio_player.vue +++ b/front/src/components/content_audio_player/content_audio_player.vue @@ -175,7 +175,7 @@ export default { return `waveform-${this.track.slug}` }, userAvatarAlt () { - let msg = this.$pgettext('Content/Track/Image/User Avatar alt', '%{username} avatar') + const msg = this.$pgettext('Content/Track/Image/User Avatar alt', '%{username} avatar') return this.$gettextInterpolate(msg, { username: this.track.account.screen_name }) }, userProfileLink () { @@ -186,7 +186,7 @@ export default { } }, watch: { - 'track': 'reloadTrack', // if track change, reload wavesurfer + track: 'reloadTrack', // if track change, reload wavesurfer '$store.state.player.track': 'stopPlaying' }, created () { @@ -195,7 +195,7 @@ export default { return // no wavesurfer initialisation if processing isn't done } this.$nextTick(() => { - let opts = { + const opts = { container: `#${this.wavesurferContainer}`, height: 40, progressColor: '#C728B6', @@ -205,7 +205,7 @@ export default { } // TODO: WebAudio (default) seems a bit slow to start the playback with ~1/2s delay if (!this.track.waveform) { - opts['normalize'] = true + opts.normalize = true } this.wavesurfer = WaveSurfer.create(opts) @@ -272,7 +272,7 @@ export default { // Load new file and waveform // Create an <audio> Element - let audio = document.createElement('audio') + const audio = document.createElement('audio') // Don't forget to set the id to an unique one audio.setAttribute('id', `audio-${this.wavesurferContainer}`) // Set the source diff --git a/front/src/components/image_cropper/image_cropper.vue b/front/src/components/image_cropper/image_cropper.vue index b5f7de3e..017fa33f 100644 --- a/front/src/components/image_cropper/image_cropper.vue +++ b/front/src/components/image_cropper/image_cropper.vue @@ -177,7 +177,7 @@ const ImageCropper = { const fileInput = this.$refs.input if (fileInput.files != null && fileInput.files[0] != null) { this.file = fileInput.files[0] - let reader = new window.FileReader() + const reader = new window.FileReader() reader.onload = (e) => { this.dataUrl = e.target.result this.$emit('open') diff --git a/front/src/components/login_form/login_form.vue b/front/src/components/login_form/login_form.vue index 54a219db..0e4b31be 100644 --- a/front/src/components/login_form/login_form.vue +++ b/front/src/components/login_form/login_form.vue @@ -154,7 +154,7 @@ export default { this.error = false }, focusOnPasswordInput () { - let passwordInput = this.$refs.passwordInput + const passwordInput = this.$refs.passwordInput passwordInput.focus() passwordInput.setSelectionRange(0, passwordInput.value.length) } diff --git a/front/src/components/sidebar/sidebar.vue b/front/src/components/sidebar/sidebar.vue index e58db11a..6610a9c8 100644 --- a/front/src/components/sidebar/sidebar.vue +++ b/front/src/components/sidebar/sidebar.vue @@ -60,14 +60,14 @@ const Sidebar = { if (this.displayUser.reel2bits.quota_count === 0) { quotaCount = '0' } else { - let ffs = fileSizeFormatService.fileSizeFormat(this.displayUser.reel2bits.quota_count) + const ffs = fileSizeFormatService.fileSizeFormat(this.displayUser.reel2bits.quota_count) quotaCount = ffs.num + ffs.unit } if (this.displayUser.reel2bits.quota_limit === 0) { quotaLimit = '0' } else { - let ffs = fileSizeFormatService.fileSizeFormat(this.displayUser.reel2bits.quota_limit) + const ffs = fileSizeFormatService.fileSizeFormat(this.displayUser.reel2bits.quota_limit) quotaLimit = ffs.num + ffs.unit } diff --git a/front/src/components/user_card/user_card.vue b/front/src/components/user_card/user_card.vue index e296dfa6..671d8326 100644 --- a/front/src/components/user_card/user_card.vue +++ b/front/src/components/user_card/user_card.vue @@ -131,7 +131,7 @@ const UserCard = { return this.$store.state.users.currentUser }, userAvatarAlt () { - let msg = this.$pgettext('Content/UserCard/Image/Avatar alt', '%{username} avatar') + const msg = this.$pgettext('Content/UserCard/Image/Avatar alt', '%{username} avatar') return this.$gettextInterpolate(msg, { username: this.user.screen_name }) } }, diff --git a/front/src/components/user_card_list/user_card_list.vue b/front/src/components/user_card_list/user_card_list.vue index a9dbbb40..11740fa9 100644 --- a/front/src/components/user_card_list/user_card_list.vue +++ b/front/src/components/user_card_list/user_card_list.vue @@ -131,7 +131,7 @@ const UserCardList = { return this.$store.state.users.currentUser }, userAvatarAlt () { - let msg = this.$pgettext('Content/UserCardList/Image/Avatar alt', '%{username} avatar') + const msg = this.$pgettext('Content/UserCardList/Image/Avatar alt', '%{username} avatar') return this.$gettextInterpolate(msg, { username: this.user.screen_name }) } }, diff --git a/front/src/components/user_followers/user_followers.vue b/front/src/components/user_followers/user_followers.vue index cb3d03d0..e4938950 100644 --- a/front/src/components/user_followers/user_followers.vue +++ b/front/src/components/user_followers/user_followers.vue @@ -87,7 +87,7 @@ export default { if (errorMessage) { this.error = errorMessage } else { - let msg = this.$pgettext('Content/UserFollowers/Error', 'Error loading user: %{errorMsg}') + const msg = this.$pgettext('Content/UserFollowers/Error', 'Error loading user: %{errorMsg}') this.error = this.$gettextInterpolate(msg, { errorMsg: errorMessage }) this.$bvToast.toast(this.$pgettext('Content/UserFollowers/Toast/Error/Message', 'Cannot fetch user'), { title: this.$pgettext('Content/UserFollowers/Toast/Error/Title', 'Followers'), @@ -112,7 +112,7 @@ export default { }) .catch((e) => { console.log('cannot fetch user followers: ' + e.message) - let msg = this.$pgettext('Content/UserFollowers/Error', 'Error loading user followers: %{errorMsg}') + const msg = this.$pgettext('Content/UserFollowers/Error', 'Error loading user followers: %{errorMsg}') this.error = this.$gettextInterpolate(msg, { errorMsg: e.message }) this.usersError = e this.usersLoaded = false diff --git a/front/src/components/user_followings/user_followings.vue b/front/src/components/user_followings/user_followings.vue index 63808a85..eaad7d3d 100644 --- a/front/src/components/user_followings/user_followings.vue +++ b/front/src/components/user_followings/user_followings.vue @@ -87,7 +87,7 @@ export default { if (errorMessage) { this.error = errorMessage } else { - let msg = this.$pgettext('Content/UserFollowings/Error', 'Error loading user: %{errorMsg}') + const msg = this.$pgettext('Content/UserFollowings/Error', 'Error loading user: %{errorMsg}') this.error = this.$gettextInterpolate(msg, { errorMsg: errorMessage }) this.$bvToast.toast(this.$pgettext('Content/UserFollowings/Toast/Error/Message', 'Cannot fetch user'), { title: this.$pgettext('Content/UserFollowings/Toast/Error/Title', 'Followings'), @@ -110,7 +110,7 @@ export default { this.usersLoaded = true }) .catch((e) => { - let msg = this.$pgettext('Content/UserFollowings/Error', 'Error loading user followings: %{errorMsg}') + const msg = this.$pgettext('Content/UserFollowings/Error', 'Error loading user followings: %{errorMsg}') this.error = this.$gettextInterpolate(msg, { errorMsg: e.message }) this.usersError = e this.usersLoaded = false diff --git a/front/src/components/user_profile/user_profile.vue b/front/src/components/user_profile/user_profile.vue index 919b0f6f..407d11e1 100644 --- a/front/src/components/user_profile/user_profile.vue +++ b/front/src/components/user_profile/user_profile.vue @@ -115,14 +115,14 @@ export default { if (this.user.reel2bits.quota_count === 0) { quotaCount = '0' } else { - let ffs = fileSizeFormatService.fileSizeFormat(this.user.reel2bits.quota_count) + const ffs = fileSizeFormatService.fileSizeFormat(this.user.reel2bits.quota_count) quotaCount = ffs.num + ffs.unit } if (this.user.reel2bits.quota_limit === 0) { quotaLimit = '0' } else { - let ffs = fileSizeFormatService.fileSizeFormat(this.user.reel2bits.quota_limit) + const ffs = fileSizeFormatService.fileSizeFormat(this.user.reel2bits.quota_limit) quotaLimit = ffs.num + ffs.unit } @@ -176,7 +176,7 @@ export default { if (errorMessage) { this.error = errorMessage } else { - let msg = this.$pgettext('Content/UserProfile/Error', 'Error loading user: %{errorMsg}') + const msg = this.$pgettext('Content/UserProfile/Error', 'Error loading user: %{errorMsg}') this.error = this.$gettextInterpolate(msg, { errorMsg: errorMessage }) } this.$bvToast.toast(this.$pgettext('Content/UserProfile/Toast/Error/Message', 'Cannot fetch user'), { diff --git a/front/src/components/user_settings/user_settings.vue b/front/src/components/user_settings/user_settings.vue index 3cfba175..16e5d1d9 100644 --- a/front/src/components/user_settings/user_settings.vue +++ b/front/src/components/user_settings/user_settings.vue @@ -218,7 +218,7 @@ export default { }, saveError: false, saveOk: false, - changePasswordInputs: [ '', '', '' ], + changePasswordInputs: ['', '', ''], changedPassword: false, changePasswordError: false, pickAvatarBtnVisible: true diff --git a/front/src/lib/persisted_state.js b/front/src/lib/persisted_state.js index a0349c47..b0ee5ee5 100644 --- a/front/src/lib/persisted_state.js +++ b/front/src/lib/persisted_state.js @@ -32,7 +32,7 @@ export default function createPersistedState ({ key = 'vuex-lz', paths = [], getState = (key, storage) => { - let value = storage.getItem(key) + const value = storage.getItem(key) return value }, setState = (key, state, storage) => { diff --git a/front/src/main.js b/front/src/main.js index 48b4d55a..925dd065 100644 --- a/front/src/main.js +++ b/front/src/main.js @@ -27,8 +27,8 @@ import afterStoreSetup from './boot/after_store.js' Vue.config.productionTip = false -let availableLanguages = (function () { - let l = {} +const availableLanguages = (function () { + const l = {} locales.locales.forEach(c => { l[c.code] = c.label }) diff --git a/front/src/modules/albums.js b/front/src/modules/albums.js index 9cadf5f0..e0b1e0ef 100644 --- a/front/src/modules/albums.js +++ b/front/src/modules/albums.js @@ -36,7 +36,7 @@ const albums = { store.commit('createPending') try { - let data = await apiService.albumNew(albumInfo, store) + const data = await apiService.albumNew(albumInfo, store) store.commit('createSuccess', data) } catch (e) { let errors = JSON.parse(e.message) diff --git a/front/src/modules/api.js b/front/src/modules/api.js index f50edcb0..8ca8ce7a 100644 --- a/front/src/modules/api.js +++ b/front/src/modules/api.js @@ -40,7 +40,7 @@ const api = { }, startFetchingNotifications (store) { // Don't start fetching if we already are. - if (store.state.fetchers['notifications']) return + if (store.state.fetchers.notifications) return const fetcher = store.state.backendInteractor.startFetchingNotifications({ store }) store.commit('addFetcher', { fetcherName: 'notifications', fetcher }) @@ -69,7 +69,7 @@ const api = { commit('setSocket', null) }, removeFollowRequest (store, request) { - let requests = store.state.followRequests.filter((it) => it !== request) + const requests = store.state.followRequests.filter((it) => it !== request) store.commit('setFollowRequests', requests) } } diff --git a/front/src/modules/errors.js b/front/src/modules/errors.js index 39b6f9cb..b9fcda08 100644 --- a/front/src/modules/errors.js +++ b/front/src/modules/errors.js @@ -4,8 +4,8 @@ import { capitalize } from 'lodash' export function humanizeErrors (errors) { return Object.entries(errors).reduce((errs, [k, val]) => { - let message = val.reduce((acc, message) => { - let key = capitalize(k.replace(/_/g, ' ')) + const message = val.reduce((acc, message) => { + const key = capitalize(k.replace(/_/g, ' ')) return acc + [key, message].join(' ') + '. ' }, '') return [...errs, message] diff --git a/front/src/modules/statuses.js b/front/src/modules/statuses.js index 1df8f339..4ef2c8f6 100644 --- a/front/src/modules/statuses.js +++ b/front/src/modules/statuses.js @@ -153,8 +153,10 @@ const removeStatusFromGlobalStorage = (state, status) => { } } -const addNewStatuses = (state, { statuses, showImmediately = false, timeline, user = {}, - noIdUpdate = false, userId }) => { +const addNewStatuses = (state, { + statuses, showImmediately = false, timeline, user = {}, + noIdUpdate = false, userId +}) => { // Sanity check if (!isArray(statuses)) { return false @@ -242,10 +244,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } const processors = { - 'status': (status) => { + status: (status) => { addStatus(status, showImmediately) }, - 'retweet': (status) => { + retweet: (status) => { // RetweetedStatuses are never shown immediately const retweetedStatus = addStatus(status.retweeted_status, false, false) @@ -267,7 +269,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us retweet.retweeted_status = retweetedStatus }, - 'favorite': (favorite) => { + favorite: (favorite) => { // Only update if this is a new favorite. // Ignore our own favorites because we get info about likes as response to like request if (!state.favorites.has(favorite.id)) { @@ -275,7 +277,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us favoriteStatus(favorite) } }, - 'deletion': (deletion) => { + deletion: (deletion) => { const uri = deletion.uri const status = find(allStatuses, { uri }) if (!status) { @@ -289,10 +291,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us remove(timelineObject.visibleStatuses, { uri }) } }, - 'follow': (follow) => { + follow: (follow) => { // NOOP, it is known status but we don't do anything about it for now }, - 'default': (unknown) => { + default: (unknown) => { console.log('unknown status type') console.log(unknown) } @@ -300,7 +302,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us each(statuses, (status) => { const type = status.type - const processor = processors[type] || processors['default'] + const processor = processors[type] || processors.default processor(status) }) @@ -360,7 +362,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot } if (!notification.seen && !state.notifications.desktopNotificationSilence && visibleNotificationTypes.includes(notification.type)) { - let notification = new window.Notification(title, notifObj) + const notification = new window.Notification(title, notifObj) // Chrome is known for not closing notifications automatically // according to MDN, anyway. setTimeout(notification.close.bind(notification), 5000) diff --git a/front/src/modules/tracks.js b/front/src/modules/tracks.js index afa0cdb2..9a545bba 100644 --- a/front/src/modules/tracks.js +++ b/front/src/modules/tracks.js @@ -36,7 +36,7 @@ const tracks = { store.commit('uploadPending') try { - let data = await apiService.trackUpload(trackInfo, store) + const data = await apiService.trackUpload(trackInfo, store) store.commit('uploadSuccess', data) } catch (e) { let errors = JSON.parse(e.message) diff --git a/front/src/modules/users.js b/front/src/modules/users.js index fd641517..92a3abe6 100644 --- a/front/src/modules/users.js +++ b/front/src/modules/users.js @@ -167,7 +167,7 @@ const users = { store.commit('signUpPending') try { - let data = await apiService.register(userInfo, store) + const data = await apiService.register(userInfo, store) |