fix: Switch converted to Object Literal (#940)

* 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
This commit is contained in:
rbtprograms
2019-08-04 13:31:13 -07:00
committed by Nicolas Giard
parent 2142b5f674
commit 0f9ddf1e5d
28 changed files with 82 additions and 45 deletions

View File

@@ -42,7 +42,8 @@
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
data() {

View File

@@ -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>
@@ -196,7 +195,8 @@ import nanoid from 'nanoid/non-secure/generate'
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
data() {

View File

@@ -57,7 +57,8 @@ import unassignUserMutation from 'gql/admin/groups/groups-mutation-unassign.gql'
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
components: {

View File

@@ -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() {
@@ -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',

View File

@@ -1,7 +1,5 @@
import { make } from 'vuex-pathify'
/* global siteConfig */
const state = {
info: {
currentVersion: 'n/a',

View File

@@ -8,6 +8,8 @@ import page from './page'
import site from './site'
import user from './user'
/* global WIKI */
Vue.use(Vuex)
const state = {

View File

@@ -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",
@@ -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",

View File

@@ -1,3 +1,5 @@
/* global WIKI */
exports.up = knex => {
const dbCompat = {
blobLength: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)

View File

@@ -1,3 +1,5 @@
/* global WIKI */
exports.up = knex => {
const dbCompat = {
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)

View File

@@ -1,3 +1,5 @@
/* global WIKI */
exports.up = knex => {
const dbCompat = {
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)

View File

@@ -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))
}
}

View File

@@ -1,6 +1,3 @@
/* global WIKI */
module.exports = {
// Query: {
// comments(obj, args, context, info) {

View File

@@ -1,6 +1,3 @@
/* global WIKI */
module.exports = {
// Query: {
// folders(obj, args, context, info) {

View File

@@ -1,8 +1,3 @@
/* global WIKI */
const gql = require('graphql')
module.exports = {
// Query: {
// tags(obj, args, context, info) {

View File

@@ -1,7 +1,5 @@
const crypto = require('crypto')
/* global WIKI */
module.exports = {
/**
* Generate unique hash from page

View File

@@ -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

View File

@@ -1,7 +1,5 @@
const { graphqlUploadExpress } = require('graphql-upload')
/* global WIKI */
/**
* GraphQL File Upload Middleware
*/

View File

@@ -138,6 +138,5 @@ module.exports = class Analytics extends Model {
bodyEnd: ''
}
}
}
}

View File

@@ -5,7 +5,6 @@
// ------------------------------------
const DiscordStrategy = require('passport-discord').Strategy
const _ = require('lodash')
module.exports = {
init (passport, conf) {

View File

@@ -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')

View File

@@ -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)
})
})

View File

@@ -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

BIN
yarn.lock

Binary file not shown.