fix: code linting

This commit is contained in:
Nick 2019-09-08 12:39:05 -04:00
parent 7634bd266d
commit 69e644e18f
13 changed files with 1114 additions and 2386 deletions

View File

@ -41,13 +41,17 @@
v-list-item-title.body-2 {{$t('common:header.edit')}} v-list-item-title.body-2 {{$t('common:header.edit')}}
v-list-item.pl-4(@click='pageHistory', v-if='mode !== `history`') v-list-item.pl-4(@click='pageHistory', v-if='mode !== `history`')
v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-history v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-history
v-list-item-content
v-list-item-title.body-2.grey--text.text--ligten-2 {{$t('common:header.history')}} v-list-item-title.body-2.grey--text.text--ligten-2 {{$t('common:header.history')}}
v-list-item-subtitle.overline.grey--text.text--lighten-2 Coming soon
v-list-item.pl-4(@click='pageSource', v-if='mode !== `source`') v-list-item.pl-4(@click='pageSource', v-if='mode !== `source`')
v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-code-tags v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-code-tags
v-list-item-title.body-2 {{$t('common:header.viewSource')}} v-list-item-title.body-2 {{$t('common:header.viewSource')}}
v-list-item.pl-4(@click='pageMove', v-if='isAuthenticated') v-list-item.pl-4(@click='pageMove', v-if='isAuthenticated')
v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-content-save-move-outline v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-content-save-move-outline
v-list-item-content
v-list-item-title.body-2.grey--text.text--ligten-2 {{$t('common:header.move')}} v-list-item-title.body-2.grey--text.text--ligten-2 {{$t('common:header.move')}}
v-list-item-subtitle.overline.grey--text.text--lighten-2 Coming soon
v-list-item.pl-4(@click='pageDelete', v-if='isAuthenticated') v-list-item.pl-4(@click='pageDelete', v-if='isAuthenticated')
v-list-item-avatar(size='24'): v-icon(color='red darken-2') mdi-trash-can-outline v-list-item-avatar(size='24'): v-icon(color='red darken-2') mdi-trash-can-outline
v-list-item-title.body-2 {{$t('common:header.delete')}} v-list-item-title.body-2 {{$t('common:header.delete')}}
@ -55,7 +59,9 @@
.overline.pa-4.grey--text {{$t('common:header.assets')}} .overline.pa-4.grey--text {{$t('common:header.assets')}}
v-list-item.pl-4(@click='assets') v-list-item.pl-4(@click='assets')
v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-folder-multiple-image v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-folder-multiple-image
v-list-item-content
v-list-item-title.body-2.grey--text.text--ligten-2 {{$t('common:header.imagesFiles')}} v-list-item-title.body-2.grey--text.text--ligten-2 {{$t('common:header.imagesFiles')}}
v-list-item-subtitle.overline.grey--text.text--lighten-2 Coming soon
v-toolbar-title(:class='{ "mx-2": $vuetify.breakpoint.mdAndUp, "mx-0": $vuetify.breakpoint.smAndDown }') v-toolbar-title(:class='{ "mx-2": $vuetify.breakpoint.mdAndUp, "mx-0": $vuetify.breakpoint.smAndDown }')
span.subheading {{title}} span.subheading {{title}}
v-flex(md4, v-if='$vuetify.breakpoint.mdAndUp') v-flex(md4, v-if='$vuetify.breakpoint.mdAndUp')
@ -150,12 +156,11 @@
v-btn(icon, v-on='{ ...menu, ...tooltip }', :class='$vuetify.rtl ? `ml-3` : ``') v-btn(icon, v-on='{ ...menu, ...tooltip }', :class='$vuetify.rtl ? `ml-3` : ``')
v-icon(color='grey') mdi-web v-icon(color='grey') mdi-web
span {{$t('common:header.language')}} span {{$t('common:header.language')}}
v-list.py-0 v-list(nav)
template(v-for='(lc, idx) of locales') template(v-for='(lc, idx) of locales')
v-list-item(@click='changeLocale(lc)') v-list-item(@click='changeLocale(lc)')
v-list-item-action: v-chip(:color='lc.code === locale ? `blue` : `grey`', small, label, dark) {{lc.code.toUpperCase()}} v-list-item-action: v-chip(:color='lc.code === locale ? `blue` : `grey`', small, label, dark) {{lc.code.toUpperCase()}}
v-list-item-title {{lc.name}} v-list-item-title {{lc.name}}
v-divider.my-0(v-if='idx < locales.length - 1')
v-tooltip(bottom, v-if='isAuthenticated && isAdmin') v-tooltip(bottom, v-if='isAuthenticated && isAdmin')
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')
v-btn.btn-animate-rotate(icon, href='/a', v-on='on', :class='$vuetify.rtl ? `ml-3` : ``') v-btn.btn-animate-rotate(icon, href='/a', v-on='on', :class='$vuetify.rtl ? `ml-3` : ``')
@ -170,7 +175,7 @@
v-avatar(v-else-if='picture.kind === `image`', :size='34') v-avatar(v-else-if='picture.kind === `image`', :size='34')
v-img(:src='picture.url') v-img(:src='picture.url')
span {{$t('common:header.account')}} span {{$t('common:header.account')}}
v-list.py-0 v-list(nav)
v-list-item.py-3.grey(:class='$vuetify.theme.dark ? `darken-4-l5` : `lighten-5`') v-list-item.py-3.grey(:class='$vuetify.theme.dark ? `darken-4-l5` : `lighten-5`')
v-list-item-avatar v-list-item-avatar
v-avatar.blue(v-if='picture.kind === `initials`', :size='40') v-avatar.blue(v-if='picture.kind === `initials`', :size='40')
@ -180,18 +185,19 @@
v-list-item-content v-list-item-content
v-list-item-title {{name}} v-list-item-title {{name}}
v-list-item-subtitle {{email}} v-list-item-subtitle {{email}}
v-divider.my-0
v-list-item(href='/w', disabled) v-list-item(href='/w', disabled)
v-list-item-action: v-icon(color='blue') mdi-view-compact-outline v-list-item-action: v-icon(color='blue') mdi-view-compact-outline
v-list-item-content
v-list-item-title {{$t('common:header.myWiki')}} v-list-item-title {{$t('common:header.myWiki')}}
v-divider.my-0 v-list-item-subtitle.overline Coming soon
v-list-item(href='/p', disabled) v-list-item(href='/p', disabled)
v-list-item-action: v-icon(color='blue') mdi-face-profile v-list-item-action: v-icon(color='blue') mdi-face-profile
v-list-item-content
v-list-item-title {{$t('common:header.profile')}} v-list-item-title {{$t('common:header.profile')}}
v-divider.my-0 v-list-item-subtitle.overline Coming soon
v-list-item(@click='logout') v-list-item(@click='logout')
v-list-item-action: v-icon(color='red') mdi-logout v-list-item-action: v-icon(color='red') mdi-logout
v-list-item-title {{$t('common:header.logout')}} v-list-item-title.red--text {{$t('common:header.logout')}}
v-tooltip(v-else, left) v-tooltip(v-else, left)
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')

View File

@ -319,21 +319,21 @@ export default {
}) })
}, 500), }, 500),
onCmPaste (cm, ev) { onCmPaste (cm, ev) {
const clipItems = (ev.clipboardData || ev.originalEvent.clipboardData).items // const clipItems = (ev.clipboardData || ev.originalEvent.clipboardData).items
for (let clipItem of clipItems) { // for (let clipItem of clipItems) {
if (_.startsWith(clipItem.type, 'image/')) { // if (_.startsWith(clipItem.type, 'image/')) {
const file = clipItem.getAsFile() // const file = clipItem.getAsFile()
const reader = new FileReader() // const reader = new FileReader()
reader.onload = evt => { // reader.onload = evt => {
this.$store.commit(`loadingStart`, 'editor-paste-image') // this.$store.commit(`loadingStart`, 'editor-paste-image')
this.insertAfter({ // this.insertAfter({
content: `![${file.name}](${evt.target.result})`, // content: `![${file.name}](${evt.target.result})`,
newLine: true // newLine: true
}) // })
} // }
reader.readAsDataURL(file) // reader.readAsDataURL(file)
} // }
} // }
}, },
/** /**
* Update cursor state * Update cursor state

View File

@ -4,10 +4,10 @@
* @return {string} Placeholder attributes * @return {string} Placeholder attributes
*/ */
@mixin placeholder { @mixin placeholder {
&::-webkit-input-placeholder {@content}; &::-webkit-input-placeholder {@content;}
&::-moz-placeholder {@content} &::-moz-placeholder {@content;}
&:-ms-input-placeholder {@content} &:-ms-input-placeholder {@content;}
&:placeholder-shown {@content}; &:placeholder-shown {@content;}
} }
/** /**
@ -30,7 +30,7 @@
100%{ 100%{
@include prefix(transform, rotate(360deg)); @include prefix(transform, rotate(360deg));
} }
}; }
} }
/** /**

View File

@ -18,11 +18,11 @@ export default {
state, state,
mutations: { mutations: {
...make.mutations(state), ...make.mutations(state),
pushMediaFolderTree: (state, folder) => { pushMediaFolderTree: (st, folder) => {
state.media.folderTree = state.media.folderTree.concat(folder) st.media.folderTree = st.media.folderTree.concat(folder)
}, },
popMediaFolderTree: (state) => { popMediaFolderTree: (st) => {
state.media.folderTree = state.media.folderTree.slice(0, -1) st.media.folderTree = st.media.folderTree.slice(0, -1)
} }
} }
} }

View File

@ -33,24 +33,24 @@ export default new Vuex.Store({
}, },
mutations: { mutations: {
...make.mutations(state), ...make.mutations(state),
loadingStart (state, stackName) { loadingStart (st, stackName) {
state.loadingStack = _.union(state.loadingStack, [stackName]) st.loadingStack = _.union(st.loadingStack, [stackName])
}, },
loadingStop (state, stackName) { loadingStop (st, stackName) {
state.loadingStack = _.without(state.loadingStack, stackName) st.loadingStack = _.without(st.loadingStack, stackName)
}, },
showNotification (state, opts) { showNotification (st, opts) {
state.notification = _.defaults(opts, { st.notification = _.defaults(opts, {
message: '', message: '',
style: 'primary', style: 'primary',
icon: 'cached', icon: 'cached',
isActive: true isActive: true
}) })
}, },
updateNotificationState (state, newState) { updateNotificationState (st, newState) {
state.notification.isActive = newState st.notification.isActive = newState
}, },
pushGraphError (state, err) { pushGraphError (st, err) {
WIKI.$store.commit('showNotification', { WIKI.$store.commit('showNotification', {
style: 'red', style: 'red',
message: _.get(err, 'graphQLErrors[0].message', err.message), message: _.get(err, 'graphQLErrors[0].message', err.message),

View File

@ -20,21 +20,21 @@ export default {
state, state,
mutations: { mutations: {
...make.mutations(state), ...make.mutations(state),
REFRESH_AUTH(state) { REFRESH_AUTH(st) {
const jwtCookie = Cookies.get('jwt') const jwtCookie = Cookies.get('jwt')
if (jwtCookie) { if (jwtCookie) {
try { try {
const jwtData = jwt.decode(jwtCookie) const jwtData = jwt.decode(jwtCookie)
state.id = jwtData.id st.id = jwtData.id
state.email = jwtData.email st.email = jwtData.email
state.name = jwtData.name st.name = jwtData.name
state.pictureUrl = jwtData.pictureUrl st.pictureUrl = jwtData.pictureUrl
state.localeCode = jwtData.localeCode st.localeCode = jwtData.localeCode
state.defaultEditor = jwtData.defaultEditor st.defaultEditor = jwtData.defaultEditor
state.permissions = jwtData.permissions st.permissions = jwtData.permissions
state.iat = jwtData.iat st.iat = jwtData.iat
state.exp = jwtData.exp st.exp = jwtData.exp
state.authenticated = true st.authenticated = true
} catch (err) { } catch (err) {
console.debug('Invalid JWT. Silent authentication skipped.') console.debug('Invalid JWT. Silent authentication skipped.')
} }

View File

@ -78,21 +78,27 @@
color='teal lighten-5' color='teal lighten-5'
v-for='(tag, idx) in tags' v-for='(tag, idx) in tags'
:href='`/t/` + tag.tag' :href='`/t/` + tag.tag'
:key='tag.tag' :key='`tag-` + tag.tag'
) )
v-icon(color='teal', left, small) mdi-label v-icon(color='teal', left, small) mdi-tag
span.teal--text.text--darken-2 {{tag.title}} span.teal--text.text--darken-2 {{tag.title}}
v-chip.mr-1(
label
color='teal lighten-5'
:href='`/t/` + tags.map(t => t.tag).join(`/`)'
)
v-icon(color='teal', size='20') mdi-tag-multiple
v-card.mb-5 v-card.mb-5
.pa-5 .pa-5
.overline.indigo--text.d-flex.align-center(:class='$vuetify.theme.dark ? `text--lighten-3` : ``') .overline.indigo--text.d-flex.align-center(:class='$vuetify.theme.dark ? `text--lighten-3` : ``')
span {{$t('common:page.lastEditedBy')}} span {{$t('common:page.lastEditedBy')}}
v-spacer //- v-spacer
v-tooltip(top, v-if='isAuthenticated') //- v-tooltip(top, v-if='isAuthenticated')
template(v-slot:activator='{ on }') //- template(v-slot:activator='{ on }')
v-btn.btn-animate-edit(icon, :href='"/h/" + locale + "/" + path', v-on='on', x-small) //- v-btn.btn-animate-edit(icon, :href='"/h/" + locale + "/" + path', v-on='on', x-small)
v-icon(color='grey', dense) mdi-history //- v-icon(color='grey', dense) mdi-history
span History //- span History
.body-2.grey--text(:class='darkMode ? `` : `text--darken-3`') {{ authorName }} .body-2.grey--text(:class='darkMode ? `` : `text--darken-3`') {{ authorName }}
.caption.grey--text.text--darken-1 {{ updatedAt | moment('calendar') }} .caption.grey--text.text--darken-1 {{ updatedAt | moment('calendar') }}

View File

@ -120,8 +120,8 @@ module.exports = {
} else { } else {
res.cookie('jwt', newToken.token, { expires: moment().add(365, 'days').toDate() }) res.cookie('jwt', newToken.token, { expires: moment().add(365, 'days').toDate() })
} }
} catch (err) { } catch (errc) {
WIKI.logger.warn(err) WIKI.logger.warn(errc)
return next() return next()
} }
} }
@ -137,8 +137,8 @@ module.exports = {
} }
// JWT is valid // JWT is valid
req.logIn(user, { session: false }, (err) => { req.logIn(user, { session: false }, (errc) => {
if (err) { return next(err) } if (errc) { return next(errc) }
next() next()
}) })
})(req, res, next) })(req, res, next)

View File

@ -45,8 +45,8 @@ module.exports = {
_.set(lcObj, key.replace(':', '.'), value) _.set(lcObj, key.replace(':', '.'), value)
}) })
const localeExists = await WIKI.models.locales.query().select('code').where('code', locale.code).first() const localeDbExists = await WIKI.models.locales.query().select('code').where('code', locale.code).first()
if (localeExists) { if (localeDbExists) {
await WIKI.models.locales.query().update({ await WIKI.models.locales.query().update({
code: locale.code, code: locale.code,
strings: lcObj, strings: lcObj,

View File

@ -71,8 +71,8 @@ module.exports = {
})) }))
resolve(true) resolve(true)
} catch (err) { } catch (errc) {
reject(err) reject(errc)
} }
db.close() db.close()
}) })

View File

@ -291,8 +291,8 @@ module.exports = class User extends Model {
mustChangePwd: true, mustChangePwd: true,
continuationToken: pwdChangeToken continuationToken: pwdChangeToken
}) })
} catch (err) { } catch (errc) {
WIKI.logger.warn(err) WIKI.logger.warn(errc)
return reject(new WIKI.Error.AuthGenericError()) return reject(new WIKI.Error.AuthGenericError())
} }
} }
@ -308,14 +308,14 @@ module.exports = class User extends Model {
tfaRequired: true, tfaRequired: true,
continuationToken: tfaToken continuationToken: tfaToken
}) })
} catch (err) { } catch (errc) {
WIKI.logger.warn(err) WIKI.logger.warn(errc)
return reject(new WIKI.Error.AuthGenericError()) return reject(new WIKI.Error.AuthGenericError())
} }
} }
context.req.logIn(user, { session: !strInfo.useForm }, async err => { context.req.logIn(user, { session: !strInfo.useForm }, async errc => {
if (err) { return reject(err) } if (errc) { return reject(errc) }
const jwtToken = await WIKI.models.users.refreshToken(user) const jwtToken = await WIKI.models.users.refreshToken(user)
resolve({ jwt: jwtToken.token }) resolve({ jwt: jwtToken.token })
}) })

View File

@ -31,22 +31,22 @@ module.exports = {
builder.andWhere('path', 'like', `${opts.path}%`) builder.andWhere('path', 'like', `${opts.path}%`)
} }
// TODO: Add user permissions filtering // TODO: Add user permissions filtering
builder.andWhere(builder => { builder.andWhere(builderSub => {
switch (WIKI.config.db.type) { switch (WIKI.config.db.type) {
case 'postgres': case 'postgres':
builder.where('title', 'ILIKE', `%${q}%`) builderSub.where('title', 'ILIKE', `%${q}%`)
builder.orWhere('description', 'ILIKE', `%${q}%`) builderSub.orWhere('description', 'ILIKE', `%${q}%`)
break break
case 'mysql': case 'mysql':
case 'mariadb': case 'mariadb':
builder.whereRaw(`title LIKE '%?%' COLLATE utf8_general_ci`, [q]) builderSub.whereRaw(`title LIKE '%?%' COLLATE utf8_general_ci`, [q])
builder.orWhereRaw(`description LIKE '%?%' COLLATE utf8_general_ci`, [q]) builderSub.orWhereRaw(`description LIKE '%?%' COLLATE utf8_general_ci`, [q])
break break
// TODO: MSSQL handling // TODO: MSSQL handling
default: default:
builder.where('title', 'LIKE', `%${q}%`) builderSub.where('title', 'LIKE', `%${q}%`)
builder.orWhere('description', 'LIKE', `%${q}%`) builderSub.orWhere('description', 'LIKE', `%${q}%`)
break break
} }
}) })

3210
yarn.lock

File diff suppressed because it is too large Load Diff