Skip to content

Commit

Permalink
fix: Switch converted to Object Literal (#940)
Browse files Browse the repository at this point in the history
* updating a switch into object literal and fixed a couple linter errors

* added a comment about weird formatting

* style: use lodash get

* fix: pass eslint + puglint + jest
  • Loading branch information
rbtprograms authored and NGPixel committed Aug 4, 2019
1 parent 2142b5f commit 0f9ddf1
Show file tree
Hide file tree
Showing 28 changed files with 701 additions and 59 deletions.
3 changes: 2 additions & 1 deletion client/components/admin/admin-groups-edit-permissions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
data() {
Expand Down
4 changes: 2 additions & 2 deletions client/components/admin/admin-groups-edit-rules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
v-subheader.pl-0 Regular Expressions
span Expressions that are deemed unsafe or could result in exponential time processing will be rejected upon saving.


</template>

<script>
Expand All @@ -196,7 +195,8 @@ import nanoid from 'nanoid/non-secure/generate'
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
data() {
Expand Down
3 changes: 2 additions & 1 deletion client/components/admin/admin-groups-edit-users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ import unassignUserMutation from 'gql/admin/groups/groups-mutation-unassign.gql'
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
components: {
Expand Down
4 changes: 2 additions & 2 deletions client/components/editor/editor-wysiwyg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import 'grapesjs/dist/css/grapes.min.css'
import grapesjs from 'grapesjs'
let editor
let editor // eslint-disable-line no-unused-vars
export default {
mounted() {
Expand All @@ -31,7 +31,7 @@ export default {
}, {
id: 'text',
label: 'Text',
content: '<div data-gjs-type="text">Insert your text here</div>',
content: '<div data-gjs-type="text">Insert your text here</div>'
}, {
id: 'image',
label: 'Image',
Expand Down
2 changes: 1 addition & 1 deletion client/modules/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
],
backendOptions: [
{
expirationTime: 1000*60*60*24 // 24h
expirationTime: 1000 * 60 * 60 * 24 // 24h
},
{
loadPath: '{{lng}}/{{ns}}',
Expand Down
2 changes: 0 additions & 2 deletions client/store/admin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { make } from 'vuex-pathify'

/* global siteConfig */

const state = {
info: {
currentVersion: 'n/a',
Expand Down
2 changes: 2 additions & 0 deletions client/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import page from './page'
import site from './site'
import user from './user'

/* global WIKI */

Vue.use(Vuex)

const state = {
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"i18next-localstorage-backend": "3.0.0",
"i18next-xhr-backend": "3.0.1",
"ignore-loader": "0.1.2",
"jest": "24.8.0",
"js-cookie": "2.2.0",
"mini-css-extract-plugin": "0.8.0",
"moment-duration-format": "2.3.2",
Expand Down Expand Up @@ -343,9 +344,15 @@
"requireSpaceAfterCodeOperator": true,
"requireStrictEqualityOperators": true,
"validateAttributeQuoteMarks": "'",
"validateAttributeSeparator": ", ",
"validateAttributeSeparator": { "separator": ", ", "multiLineSeparator": "\n " },
"validateDivTags": true,
"validateIndentation": 2
"validateIndentation": 2,
"excludeFiles": [
"node_modules/**",
"server/views/master.pug",
"server/views/setup.pug",
"server/views/legacy/master.pug"
]
},
"collective": {
"type": "opencollective",
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const bruteforce = new ExpressBrute(new BruteKnex({
knex: WIKI.models.knex
}), {
freeRetries: 5,
minWait: 5*60*1000, // 5 minutes
maxWait: 60*60*1000, // 1 hour
minWait: 5 * 60 * 1000, // 5 minutes
maxWait: 60 * 60 * 1000, // 1 hour
failCallback: (req, res, next) => {
res.status(401).send('Too many failed attempts. Try again later.')
}
Expand Down
2 changes: 2 additions & 0 deletions server/db/migrations/2.0.0-beta.148.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global WIKI */

exports.up = knex => {
const dbCompat = {
blobLength: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
Expand Down
2 changes: 2 additions & 0 deletions server/db/migrations/2.0.0-beta.205.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global WIKI */

exports.up = knex => {
const dbCompat = {
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
Expand Down
2 changes: 2 additions & 0 deletions server/db/migrations/2.0.0-beta.99.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global WIKI */

exports.up = knex => {
const dbCompat = {
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
Expand Down
4 changes: 2 additions & 2 deletions server/db/migrator-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module.exports = {
},

getMigrationName(migration) {
return migration.file;
return migration.file
},

getMigration(migration) {
return require(path.join(baseMigrationPath, migration.file));
return require(path.join(baseMigrationPath, migration.file))
}
}
3 changes: 0 additions & 3 deletions server/graph/resolvers/comment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

/* global WIKI */

module.exports = {
// Query: {
// comments(obj, args, context, info) {
Expand Down
3 changes: 0 additions & 3 deletions server/graph/resolvers/folder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

/* global WIKI */

module.exports = {
// Query: {
// folders(obj, args, context, info) {
Expand Down
2 changes: 1 addition & 1 deletion server/graph/resolvers/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
}
},
async update(obj, args) {
if(_.some(args.pageRules, pr => {
if (_.some(args.pageRules, pr => {
return pr.match === 'REGEX' && !safeRegex(pr.path)
})) {
throw new gql.GraphQLError('Some Page Rules contains unsafe or exponential time regex.')
Expand Down
4 changes: 2 additions & 2 deletions server/graph/resolvers/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
return {
responseResult: graphHelper.generateSuccess('Telemetry state updated successfully')
}
} catch(err) {
} catch (err) {
return graphHelper.generateError(err)
}
},
Expand All @@ -63,7 +63,7 @@ module.exports = {
return {
responseResult: graphHelper.generateSuccess('Telemetry Client ID has been reset successfully')
}
} catch(err) {
} catch (err) {
return graphHelper.generateError(err)
}
}
Expand Down
5 changes: 0 additions & 5 deletions server/graph/resolvers/tag.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@

/* global WIKI */

const gql = require('graphql')

module.exports = {
// Query: {
// tags(obj, args, context, info) {
Expand Down
2 changes: 0 additions & 2 deletions server/helpers/asset.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const crypto = require('crypto')

/* global WIKI */

module.exports = {
/**
* Generate unique hash from page
Expand Down
11 changes: 4 additions & 7 deletions server/helpers/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,11 @@ module.exports = {
['date', page.updatedAt],
['tags', '']
]
switch (page.contentType) {
case 'markdown':
return '---\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n---\n\n' + page.content
case 'html':
return '<!--\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n-->\n\n' + page.content
default:
return page.content
const inject = {
'markdown': '---\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n---\n\n' + page.content,
'html': '<!--\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n-->\n\n' + page.content
}
return _.get(inject, page.contentType, page.content)
},
/**
* Check if path is a reserved path
Expand Down
2 changes: 0 additions & 2 deletions server/middlewares/upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { graphqlUploadExpress } = require('graphql-upload')

/* global WIKI */

/**
* GraphQL File Upload Middleware
*/
Expand Down
1 change: 0 additions & 1 deletion server/models/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,5 @@ module.exports = class Analytics extends Model {
bodyEnd: ''
}
}

}
}
1 change: 0 additions & 1 deletion server/modules/authentication/discord/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// ------------------------------------

const DiscordStrategy = require('passport-discord').Strategy
const _ = require('lodash')

module.exports = {
init (passport, conf) {
Expand Down
2 changes: 1 addition & 1 deletion server/modules/authentication/github/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
githubConfig.authorizationURL = `https://${conf.enterpriseDomain}/login/oauth/authorize`
githubConfig.tokenURL = `https://${conf.enterpriseDomain}/login/oauth/access_token`
githubConfig.userProfileURL = conf.enterpriseUserEndpoint
githubConfig.userEmailURL = `${conf.enterpriseUserEndpoint}/emails`
githubConfig.userEmailURL = `${conf.enterpriseUserEndpoint}/emails`
}

passport.use('github',
Expand Down
1 change: 0 additions & 1 deletion server/modules/storage/disk/storage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fs = require('fs-extra')
const _ = require('lodash')
const path = require('path')
const tar = require('tar-fs')
const zlib = require('zlib')
Expand Down
43 changes: 43 additions & 0 deletions server/test/helpers/page.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { injectPageMetadata } = require('../../helpers/page')

describe('injectPageMetadata tests', () => {
let page = {
title: 'PAGE TITLE',
description: 'A PAGE',
isPublished: true,
updatedAt: new Date(),
content: 'TEST CONTENT'
}
test('injectPageMetadata: default', () => {
const expected = 'TEST CONTENT'
const result = injectPageMetadata(page)
expect(result).toEqual(expected)
})
test('injectPageMetadata: markdown', () => {
page.contentType = 'markdown'
const expected = `---
title: ${page.title}
description: ${page.description}
published: ${page.isPublished.toString()}
date: ${page.updatedAt}
tags: \n---
TEST CONTENT`
const result = injectPageMetadata(page)
expect(result).toEqual(expected)
})

test('injectPageMetadata: hmtl', () => {
page.contentType = 'html'
const expected = `<!--
title: ${page.title}
description: ${page.description}
published: ${page.isPublished.toString()}
date: ${page.updatedAt}
tags: \n-->
TEST CONTENT`
const result = injectPageMetadata(page)
expect(result).toEqual(expected)
})
})
2 changes: 1 addition & 1 deletion server/views/error.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ block body
v-layout(row)
v-flex(xs10)
a(href='/'): img(src='/svg/logo-wikijs.svg')
v-flex(xs2).text-xs-right
v-flex.text-right(xs2)
v-btn(href='/', depressed, color='red darken-3')
v-icon(left) home
span Home
Expand Down

0 comments on commit 0f9ddf1

Please sign in to comment.