From 98d311145ba7a5bc025768423ec07139deeb4975 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 29 Oct 2017 21:36:05 -0400 Subject: [PATCH] fix: eslint for vue components --- .eslintrc.json | 14 - .eslintrc.yml | 12 + .vscode/settings.json | 6 +- client/js/components/alert.vue | 22 +- client/js/components/anchor.vue | 62 +- client/js/components/color-picker.vue | 64 +- .../js/components/config-manager.component.js | 41 +- client/js/components/editor-codeblock.vue | 2 +- client/js/components/editor-file.vue | 898 +++++++++--------- client/js/components/editor-video.vue | 110 +-- client/js/components/history.vue | 4 +- client/js/components/loading-spinner.vue | 10 +- client/js/components/login.vue | 3 +- client/js/components/modal-create-page.vue | 88 +- client/js/components/modal-delete-page.vue | 72 +- client/js/components/modal-discard-page.vue | 40 +- client/js/components/modal-move-page.vue | 104 +- client/js/components/search.vue | 8 +- client/js/components/toggle.vue | 20 +- client/js/components/tree.vue | 126 +-- client/js/configure.js | 310 ------ client/js/store/modules/editor-codeblock.js | 2 +- client/js/store/modules/editor-file.js | 2 +- client/js/store/modules/editor-video.js | 2 +- client/js/store/modules/editor.js | 2 +- client/js/store/modules/modal-create-page.js | 2 - client/js/store/modules/modal-create-user.js | 2 +- client/js/store/modules/modal-delete-user.js | 2 - client/js/store/modules/modal-discard-page.js | 2 - client/js/store/modules/modal-move-page.js | 2 - client/js/store/modules/modal-profile-2fa.js | 2 - .../js/store/modules/modal-upgrade-system.js | 2 - client/js/store/modules/page-loader.js | 2 - package.json | 3 +- server/helpers/entry.js | 2 +- server/middlewares/auth.js | 2 +- server/models/user.js | 2 +- server/modules/documents.js | 84 +- server/modules/markdown.js | 5 +- server/modules/search.js | 4 +- server/modules/system.js | 2 +- server/views/configure/index.pug | 24 +- test/lint.js | 12 +- tools/fuse_tasks.js | 3 - yarn.lock | 23 +- 45 files changed, 953 insertions(+), 1253 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 .eslintrc.yml delete mode 100644 client/js/configure.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 8bf80646..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "requarks", - "env": { - "node": true, - "es6": true, - "jest": true - }, - "globals": { - "document": false, - "navigator": false, - "window": false, - "FuseBox": false - } -} diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 00000000..bb336b51 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,12 @@ +extends: + - requarks + - plugin:vue/recommended +env: + node: true + es6: true + jest: true +globals: + document: false + navigator: false + window: false + FuseBox: false \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 843758fc..8c7b6c96 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,9 @@ "puglint.enable": true, "standard.enable": false, "editor.formatOnSave": false, - "editor.tabSize": 2 + "editor.tabSize": 2, + "eslint.validate": [ + "javascript", + "vue" + ] } diff --git a/client/js/components/alert.vue b/client/js/components/alert.vue index 95af3539..d683209b 100644 --- a/client/js/components/alert.vue +++ b/client/js/components/alert.vue @@ -6,16 +6,16 @@ diff --git a/client/js/components/anchor.vue b/client/js/components/anchor.vue index 4f2bda58..29b9b280 100644 --- a/client/js/components/anchor.vue +++ b/client/js/components/anchor.vue @@ -17,39 +17,39 @@ diff --git a/client/js/components/color-picker.vue b/client/js/components/color-picker.vue index 6abdc445..cb53dd85 100644 --- a/client/js/components/color-picker.vue +++ b/client/js/components/color-picker.vue @@ -4,38 +4,38 @@ diff --git a/client/js/components/config-manager.component.js b/client/js/components/config-manager.component.js index fbb0f142..f25cf05b 100644 --- a/client/js/components/config-manager.component.js +++ b/client/js/components/config-manager.component.js @@ -27,29 +27,28 @@ export default { results: [] }, conf: { - telemetry: true, - upgrade: false, - title: siteConfig.title || 'Wiki', - path: siteConfig.path || '/', - port: siteConfig.port || 80, - lang: siteConfig.lang || 'en', - public: (siteConfig.public === true), - pathData: './data', - pathRepo: './repo', - gitUseRemote: (siteConfig.git !== false), - gitUrl: '', - gitBranch: 'master', - gitAuthType: 'ssh', - gitAuthSSHKey: '', - gitAuthUser: '', - gitAuthPass: '', - gitAuthSSL: true, - gitShowUserEmail: true, - gitServerEmail: '', - mongo: 'mongodb://', adminEmail: '', adminPassword: '', - adminPasswordConfirm: '' + adminPasswordConfirm: '', + gitAuthPass: '', + gitAuthSSHKey: '', + gitAuthSSL: true, + gitAuthType: 'ssh', + gitAuthUser: '', + gitBranch: 'master', + gitServerEmail: '', + gitShowUserEmail: true, + gitUrl: '', + gitUseRemote: (siteConfig.git !== false), + lang: siteConfig.lang || 'en', + mongo: 'mongodb://', + path: siteConfig.path || '/', + pathRepo: './repo', + port: siteConfig.port || 80, + public: (siteConfig.public === true), + telemetry: true, + title: siteConfig.title || 'Wiki', + upgrade: false }, considerations: { https: false, diff --git a/client/js/components/editor-codeblock.vue b/client/js/components/editor-codeblock.vue index b486d823..0f215713 100644 --- a/client/js/components/editor-codeblock.vue +++ b/client/js/components/editor-codeblock.vue @@ -81,7 +81,7 @@ export default { self.isLoading = true self.$http.get('/js/ace/mode-' + m + '.js').then(resp => { if (resp.ok) { - eval(resp.bodyText) + eval(resp.bodyText) // eslint-disable-line no-eval self.modelistLoaded.push(m) ace.acequire('ace/mode/' + m) codeEditor.getSession().setMode('ace/mode/' + m) diff --git a/client/js/components/editor-file.vue b/client/js/components/editor-file.vue index 64223870..72f290e9 100644 --- a/client/js/components/editor-file.vue +++ b/client/js/components/editor-file.vue @@ -128,476 +128,478 @@ diff --git a/client/js/components/editor-video.vue b/client/js/components/editor-video.vue index 50e998ed..59988992 100644 --- a/client/js/components/editor-video.vue +++ b/client/js/components/editor-video.vue @@ -33,62 +33,62 @@ diff --git a/client/js/components/history.vue b/client/js/components/history.vue index 01d81ff3..051a5c04 100644 --- a/client/js/components/history.vue +++ b/client/js/components/history.vue @@ -44,6 +44,8 @@ diff --git a/client/js/components/login.vue b/client/js/components/login.vue index d725ce5a..6496fd29 100644 --- a/client/js/components/login.vue +++ b/client/js/components/login.vue @@ -24,6 +24,8 @@ - diff --git a/client/js/components/modal-create-page.vue b/client/js/components/modal-create-page.vue index c4529a1d..41402eb9 100644 --- a/client/js/components/modal-create-page.vue +++ b/client/js/components/modal-create-page.vue @@ -18,50 +18,50 @@ diff --git a/client/js/components/modal-delete-page.vue b/client/js/components/modal-delete-page.vue index e188e794..9369c6a7 100644 --- a/client/js/components/modal-delete-page.vue +++ b/client/js/components/modal-delete-page.vue @@ -18,49 +18,49 @@ diff --git a/client/js/components/modal-discard-page.vue b/client/js/components/modal-discard-page.vue index 52650d65..0d82d987 100644 --- a/client/js/components/modal-discard-page.vue +++ b/client/js/components/modal-discard-page.vue @@ -16,28 +16,28 @@ diff --git a/client/js/components/modal-move-page.vue b/client/js/components/modal-move-page.vue index ad76f3f6..5d2d3049 100644 --- a/client/js/components/modal-move-page.vue +++ b/client/js/components/modal-move-page.vue @@ -19,68 +19,68 @@ diff --git a/client/js/components/search.vue b/client/js/components/search.vue index 5c97ce38..60d814e1 100644 --- a/client/js/components/search.vue +++ b/client/js/components/search.vue @@ -18,6 +18,8 @@ diff --git a/client/js/components/tree.vue b/client/js/components/tree.vue index 163510f9..dd6158a8 100644 --- a/client/js/components/tree.vue +++ b/client/js/components/tree.vue @@ -15,68 +15,70 @@ diff --git a/client/js/configure.js b/client/js/configure.js deleted file mode 100644 index 5d131538..00000000 --- a/client/js/configure.js +++ /dev/null @@ -1,310 +0,0 @@ -'use strict' - -/* global appconfig, runmode */ - -import jQuery from 'jquery' -import _ from 'lodash' -import Vue from 'vue' -import VeeValidate from 'vee-validate' -import axios from 'axios' - -Vue.use(VeeValidate, { - enableAutoClasses: true, - classNames: { - touched: 'is-touched', // the control has been blurred - untouched: 'is-untouched', // the control hasn't been blurred - valid: 'is-valid', // model is valid - invalid: 'is-invalid', // model is invalid - pristine: 'is-pristine', // control has not been interacted with - dirty: 'is-dirty' // control has been interacted with - } -}) - -jQuery(document).ready(function ($) { - new Vue({ // eslint-disable-line no-new - el: 'main', - data: { - loading: false, - state: 'welcome', - syscheck: { - ok: false, - error: '', - results: [] - }, - dbcheck: { - ok: false, - error: '' - }, - gitcheck: { - ok: false, - error: '' - }, - final: { - ok: false, - error: '', - results: [] - }, - conf: { - title: appconfig.title || 'Wiki', - host: appconfig.host || 'http://', - port: appconfig.port || 80, - lang: appconfig.lang || 'en', - public: (appconfig.public === true), - db: appconfig.db || 'mongodb://localhost:27017/wiki', - pathData: './data', - pathRepo: './repo', - gitUseRemote: (appconfig.git !== false), - gitUrl: '', - gitBranch: 'master', - gitAuthType: 'ssh', - gitAuthSSHKey: '', - gitAuthUser: '', - gitAuthPass: '', - gitAuthSSL: true, - gitShowUserEmail: true, - gitServerEmail: '', - adminEmail: '', - adminPassword: '', - adminPasswordConfirm: '' - }, - considerations: { - https: false, - port: false, - localhost: false - } - }, - computed: { - currentProgress: function () { - let perc = '0%' - switch (this.state) { - case 'welcome': - perc = '0%' - break - case 'syscheck': - perc = (this.syscheck.ok) ? '15%' : '5%' - break - case 'general': - perc = '20%' - break - case 'considerations': - perc = '30%' - break - case 'db': - perc = '35%' - break - case 'dbcheck': - perc = (this.dbcheck.ok) ? '50%' : '40%' - break - case 'paths': - perc = '55%' - break - case 'git': - perc = '60%' - break - case 'gitcheck': - perc = (this.gitcheck.ok) ? '75%' : '65%' - break - case 'admin': - perc = '80%' - break - } - return perc - } - }, - mounted: function () { - if (appconfig.paths) { - this.conf.pathData = appconfig.paths.data || './data' - this.conf.pathRepo = appconfig.paths.repo || './repo' - } - if (appconfig.git !== false && _.isPlainObject(appconfig.git)) { - this.conf.gitUrl = appconfig.git.url || '' - this.conf.gitBranch = appconfig.git.branch || 'master' - this.conf.gitShowUserEmail = (appconfig.git.showUserEmail !== false) - this.conf.gitServerEmail = appconfig.git.serverEmail || '' - if (_.isPlainObject(appconfig.git.auth)) { - this.conf.gitAuthType = appconfig.git.auth.type || 'ssh' - this.conf.gitAuthSSHKey = appconfig.git.auth.privateKey || '' - this.conf.gitAuthUser = appconfig.git.auth.username || '' - this.conf.gitAuthPass = appconfig.git.auth.password || '' - this.conf.gitAuthSSL = (appconfig.git.auth.sslVerify !== false) - } - } - }, - methods: { - proceedToWelcome: function (ev) { - this.state = 'welcome' - this.loading = false - }, - proceedToSyscheck: function (ev) { - let self = this - this.state = 'syscheck' - this.loading = true - self.syscheck = { - ok: false, - error: '', - results: [] - } - - _.delay(() => { - axios.post('/syscheck').then(resp => { - if (resp.data.ok === true) { - self.syscheck.ok = true - self.syscheck.results = resp.data.results - } else { - self.syscheck.ok = false - self.syscheck.error = resp.data.error - } - self.loading = false - self.$nextTick() - }).catch(err => { - window.alert(err.message) - }) - }, 1000) - }, - proceedToGeneral: function (ev) { - let self = this - self.state = 'general' - self.loading = false - self.$nextTick(() => { - self.$validator.validateAll('general') - }) - }, - proceedToConsiderations: function (ev) { - this.considerations = { - https: !_.startsWith(this.conf.host, 'https'), - port: false, // TODO - localhost: _.includes(this.conf.host, 'localhost') - } - this.state = 'considerations' - this.loading = false - }, - proceedToDb: function (ev) { - let self = this - if (runmode.staticMongo) { - return self.proceedToDbcheck() - } - self.state = 'db' - self.loading = false - self.$nextTick(() => { - self.$validator.validateAll('db') - }) - }, - proceedToDbcheck: function (ev) { - let self = this - this.state = 'dbcheck' - this.loading = true - self.dbcheck = { - ok: false, - error: '' - } - - _.delay(() => { - axios.post('/dbcheck', { - db: self.conf.db - }).then(resp => { - if (resp.data.ok === true) { - self.dbcheck.ok = true - } else { - self.dbcheck.ok = false - self.dbcheck.error = resp.data.error - } - self.loading = false - self.$nextTick() - }).catch(err => { - window.alert(err.message) - }) - }, 1000) - }, - proceedToPaths: function (ev) { - let self = this - self.state = 'paths' - self.loading = false - self.$nextTick(() => { - self.$validator.validateAll('paths') - }) - }, - proceedToGit: function (ev) { - let self = this - self.state = 'git' - self.loading = false - self.$nextTick(() => { - self.$validator.validateAll('git') - }) - }, - proceedToGitCheck: function (ev) { - let self = this - this.state = 'gitcheck' - this.loading = true - self.gitcheck = { - ok: false, - results: [], - error: '' - } - - _.delay(() => { - axios.post('/gitcheck', self.conf).then(resp => { - if (resp.data.ok === true) { - self.gitcheck.ok = true - self.gitcheck.results = resp.data.results - } else { - self.gitcheck.ok = false - self.gitcheck.error = resp.data.error - } - self.loading = false - self.$nextTick() - }).catch(err => { - window.alert(err.message) - }) - }, 1000) - }, - proceedToAdmin: function (ev) { - let self = this - self.state = 'admin' - self.loading = false - self.$nextTick(() => { - self.$validator.validateAll('admin') - }) - }, - proceedToFinal: function (ev) { - let self = this - self.state = 'final' - self.loading = true - self.final = { - ok: false, - error: '', - results: [] - } - - _.delay(() => { - axios.post('/finalize', self.conf).then(resp => { - if (resp.data.ok === true) { - self.final.ok = true - self.final.results = resp.data.results - } else { - self.final.ok = false - self.final.error = resp.data.error - } - self.loading = false - self.$nextTick() - }).catch(err => { - window.alert(err.message) - }) - }, 1000) - }, - finish: function (ev) { - let self = this - self.state = 'restart' - - _.delay(() => { - axios.post('/restart', {}).then(resp => { - _.delay(() => { - window.location.assign(self.conf.host) - }, 30000) - }).catch(err => { - window.alert(err.message) - }) - }, 1000) - } - } - }) -}) diff --git a/client/js/store/modules/editor-codeblock.js b/client/js/store/modules/editor-codeblock.js index 94418f0b..3244a3d8 100644 --- a/client/js/store/modules/editor-codeblock.js +++ b/client/js/store/modules/editor-codeblock.js @@ -1,4 +1,4 @@ -'use strict' +/* global wikijs */ export default { namespaced: true, diff --git a/client/js/store/modules/editor-file.js b/client/js/store/modules/editor-file.js index 2f6f2304..1dd33b26 100644 --- a/client/js/store/modules/editor-file.js +++ b/client/js/store/modules/editor-file.js @@ -1,4 +1,4 @@ -'use strict' +/* global wikijs */ export default { namespaced: true, diff --git a/client/js/store/modules/editor-video.js b/client/js/store/modules/editor-video.js index 75c8754c..d7de8b30 100644 --- a/client/js/store/modules/editor-video.js +++ b/client/js/store/modules/editor-video.js @@ -1,4 +1,4 @@ -'use strict' +/* global wikijs */ export default { namespaced: true, diff --git a/client/js/store/modules/editor.js b/client/js/store/modules/editor.js index f6bc83fe..cb64165f 100644 --- a/client/js/store/modules/editor.js +++ b/client/js/store/modules/editor.js @@ -1,4 +1,4 @@ -'use strict' +/* global wikijs */ export default { namespaced: true, diff --git a/client/js/store/modules/modal-create-page.js b/client/js/store/modules/modal-create-page.js index 5b1d08c9..7dc8d763 100644 --- a/client/js/store/modules/modal-create-page.js +++ b/client/js/store/modules/modal-create-page.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/client/js/store/modules/modal-create-user.js b/client/js/store/modules/modal-create-user.js index c4a33224..087c64a5 100644 --- a/client/js/store/modules/modal-create-user.js +++ b/client/js/store/modules/modal-create-user.js @@ -1,4 +1,4 @@ -'use strict' +/* global wikijs */ export default { namespaced: true, diff --git a/client/js/store/modules/modal-delete-user.js b/client/js/store/modules/modal-delete-user.js index 5b1d08c9..7dc8d763 100644 --- a/client/js/store/modules/modal-delete-user.js +++ b/client/js/store/modules/modal-delete-user.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/client/js/store/modules/modal-discard-page.js b/client/js/store/modules/modal-discard-page.js index 5b1d08c9..7dc8d763 100644 --- a/client/js/store/modules/modal-discard-page.js +++ b/client/js/store/modules/modal-discard-page.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/client/js/store/modules/modal-move-page.js b/client/js/store/modules/modal-move-page.js index 5b1d08c9..7dc8d763 100644 --- a/client/js/store/modules/modal-move-page.js +++ b/client/js/store/modules/modal-move-page.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/client/js/store/modules/modal-profile-2fa.js b/client/js/store/modules/modal-profile-2fa.js index bb0f9e8f..706953ca 100644 --- a/client/js/store/modules/modal-profile-2fa.js +++ b/client/js/store/modules/modal-profile-2fa.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/client/js/store/modules/modal-upgrade-system.js b/client/js/store/modules/modal-upgrade-system.js index 9ad70316..ea8a5b64 100644 --- a/client/js/store/modules/modal-upgrade-system.js +++ b/client/js/store/modules/modal-upgrade-system.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/client/js/store/modules/page-loader.js b/client/js/store/modules/page-loader.js index 9b5d3be2..9d77ff72 100644 --- a/client/js/store/modules/page-loader.js +++ b/client/js/store/modules/page-loader.js @@ -1,5 +1,3 @@ -'use strict' - export default { namespaced: true, state: { diff --git a/package.json b/package.json index 434f5fc0..7c00d9dc 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "restart": "node wiki restart", "build": "node tools/fuse", "dev": "node tools/fuse -d", - "test": "jest" + "test": "eslint --ext .js,.vue . && jest" }, "bin": { "wiki": "wiki.js" @@ -149,6 +149,7 @@ "eslint-plugin-node": "5.2.1", "eslint-plugin-promise": "3.6.0", "eslint-plugin-standard": "3.0.1", + "eslint-plugin-vue": "3.13.1", "fuse-box": "2.4.0", "graphql-tag": "^2.5.0", "i18next-xhr-backend": "1.4.3", diff --git a/server/helpers/entry.js b/server/helpers/entry.js index c476cc5e..d8f58c99 100644 --- a/server/helpers/entry.js +++ b/server/helpers/entry.js @@ -1,4 +1,4 @@ -'use strict' +/* global appdata, ROOTPATH */ const crypto = require('crypto') const path = require('path') diff --git a/server/middlewares/auth.js b/server/middlewares/auth.js index cd20b7a0..59c2babc 100644 --- a/server/middlewares/auth.js +++ b/server/middlewares/auth.js @@ -1,6 +1,6 @@ 'use strict' -/* global appdata, rights */ +/* global rights */ /** * Authentication middleware diff --git a/server/models/user.js b/server/models/user.js index c9102ac7..51916d07 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,4 +1,4 @@ -/* global wiki */ +/* global wiki, appconfig */ const Promise = require('bluebird') const bcrypt = require('bcryptjs-then') diff --git a/server/modules/documents.js b/server/modules/documents.js index 8406be0d..0cc59a6f 100644 --- a/server/modules/documents.js +++ b/server/modules/documents.js @@ -1,5 +1,3 @@ -'use strict' - /* global wiki */ const Promise = require('bluebird') @@ -78,7 +76,7 @@ module.exports = { return fs.readFileAsync(cpath).then((contents) => { return JSON.parse(contents) }).catch((err) => { // eslint-disable-line handle-callback-err - winston.error('Corrupted cache file. Deleting it...') + wiki.logger.error('Corrupted cache file. Deleting it...') fs.unlinkSync(cpath) return false }) @@ -115,7 +113,7 @@ module.exports = { return fs.statAsync(fpath).then((st) => { if (st.isFile()) { return fs.readFileAsync(fpath, 'utf8').then((contents) => { - let htmlProcessor = (options.parseMarkdown) ? mark.parseContent(contents) : Promise.resolve('') + let htmlProcessor = (options.parseMarkdown) ? wiki.mark.parseContent(contents) : Promise.resolve('') // Parse contents @@ -123,8 +121,8 @@ module.exports = { let pageData = { markdown: (options.includeMarkdown) ? contents : '', html, - meta: (options.parseMeta) ? mark.parseMeta(contents) : {}, - tree: (options.parseTree) ? mark.parseTree(contents) : [] + meta: (options.parseMeta) ? wiki.mark.parseMeta(contents) : {}, + tree: (options.parseTree) ? wiki.mark.parseTree(contents) : [] } if (!pageData.meta.title) { @@ -147,8 +145,8 @@ module.exports = { if (options.cache) { let cacheData = JSON.stringify(_.pick(pageData, ['html', 'meta', 'tree', 'parent']), false, false, false) return fs.writeFileAsync(cpath, cacheData).catch((err) => { - winston.error('Unable to write to cache! Performance may be affected.') - winston.error(err) + wiki.logger.error('Unable to write to cache! Performance may be affected.') + wiki.logger.error(err) return true }) } else { @@ -161,7 +159,7 @@ module.exports = { return false } }).catch((err) => { // eslint-disable-line handle-callback-err - throw new Promise.OperationalError(lang.t('errors:notexist', { path: entryPath })) + throw new Promise.OperationalError(wiki.lang.t('errors:notexist', { path: entryPath })) }) }, @@ -181,7 +179,7 @@ module.exports = { return fs.statAsync(fpath).then((st) => { if (st.isFile()) { return fs.readFileAsync(fpath, 'utf8').then((contents) => { - let pageMeta = mark.parseMeta(contents) + let pageMeta = wiki.mark.parseMeta(contents) return { path: parentPath, @@ -190,11 +188,11 @@ module.exports = { } }) } else { - return Promise.reject(new Error(lang.t('errors:parentinvalid'))) + return Promise.reject(new Error(wiki.lang.t('errors:parentinvalid'))) } }) } else { - return Promise.reject(new Error(lang.t('errors:parentisroot'))) + return Promise.reject(new Error(wiki.lang.t('errors:parentisroot'))) } }, @@ -214,15 +212,15 @@ module.exports = { if (st.isFile()) { return self.makePersistent(entryPath, contents, author).then(() => { return self.updateCache(entryPath).then(entry => { - return search.add(entry) + return wiki.search.add(entry) }) }) } else { - return Promise.reject(new Error(lang.t('errors:notexist', { path: entryPath }))) + return Promise.reject(new Error(wiki.lang.t('errors:notexist', { path: entryPath }))) } }).catch((err) => { - winston.error(err) - return Promise.reject(new Error(lang.t('errors:savefailed'))) + wiki.logger.error(err) + return Promise.reject(new Error(wiki.lang.t('errors:savefailed'))) }) }, @@ -243,21 +241,21 @@ module.exports = { includeParentInfo: true, cache: true }).catch(err => { - winston.error(err) + wiki.logger.error(err) return err }).then((pageData) => { return { entryPath, meta: pageData.meta, parent: pageData.parent || {}, - text: mark.removeMarkdown(pageData.markdown) + text: wiki.mark.removeMarkdown(pageData.markdown) } }).catch(err => { - winston.error(err) + wiki.logger.error(err) return err }).then((content) => { let parentPath = _.chain(content.entryPath).split('/').initial().join('/').value() - return db.Entry.findOneAndUpdate({ + return wiki.db.Entry.findOneAndUpdate({ _id: content.entryPath }, { _id: content.entryPath, @@ -280,7 +278,7 @@ module.exports = { return result }) }).catch(err => { - winston.error(err) + wiki.logger.error(err) return err }) }, @@ -291,12 +289,12 @@ module.exports = { * @returns {Promise} Promise of the operation */ updateTreeInfo() { - return db.Entry.distinct('parentPath', { parentPath: { $ne: '' } }).then(allPaths => { + return wiki.db.Entry.distinct('parentPath', { parentPath: { $ne: '' } }).then(allPaths => { if (allPaths.length > 0) { return Promise.map(allPaths, pathItem => { let parentPath = _.chain(pathItem).split('/').initial().join('/').value() let guessedTitle = _.chain(pathItem).split('/').last().startCase().value() - return db.Entry.update({ _id: pathItem }, { + return wiki.db.Entry.update({ _id: pathItem }, { $set: { isDirectory: true }, $setOnInsert: { isEntry: false, title: guessedTitle, parentPath } }, { upsert: true }) @@ -322,15 +320,15 @@ module.exports = { if (!docExists) { return self.makePersistent(entryPath, contents, author).then(() => { return self.updateCache(entryPath).then(entry => { - return search.add(entry) + return wiki.search.add(entry) }) }) } else { - return Promise.reject(new Error(lang.t('errors:alreadyexists'))) + return Promise.reject(new Error(wiki.lang.t('errors:alreadyexists'))) } }).catch((err) => { - winston.error(err) - return Promise.reject(new Error(lang.t('errors:generic'))) + wiki.logger.error(err) + return Promise.reject(new Error(wiki.lang.t('errors:generic'))) }) }, @@ -346,7 +344,7 @@ module.exports = { let fpath = entryHelper.getFullPath(entryPath) return fs.outputFileAsync(fpath, contents).then(() => { - return git.commitDocument(entryPath, author) + return wiki.git.commitDocument(entryPath, author) }) }, @@ -362,11 +360,11 @@ module.exports = { let self = this if (_.isEmpty(entryPath) || entryPath === 'home') { - return Promise.reject(new Error(lang.t('errors:invalidpath'))) + return Promise.reject(new Error(wiki.lang.t('errors:invalidpath'))) } - return git.moveDocument(entryPath, newEntryPath).then(() => { - return git.commitDocument(newEntryPath, author).then(() => { + return wiki.git.moveDocument(entryPath, newEntryPath).then(() => { + return wiki.git.commitDocument(newEntryPath, author).then(() => { // Delete old cache version let oldEntryCachePath = entryHelper.getCachePath(entryPath) @@ -374,14 +372,14 @@ module.exports = { // Delete old index entry - search.delete(entryPath) + wiki.search.delete(entryPath) // Create cache for new entry return Promise.join( - db.Entry.deleteOne({ _id: entryPath }), + wiki.db.Entry.deleteOne({ _id: entryPath }), self.updateCache(newEntryPath).then(entry => { - return search.add(entry) + return wiki.search.add(entry) }) ) }) @@ -397,20 +395,20 @@ module.exports = { */ remove(entryPath, author) { if (_.isEmpty(entryPath) || entryPath === 'home') { - return Promise.reject(new Error(lang.t('errors:invalidpath'))) + return Promise.reject(new Error(wiki.lang.t('errors:invalidpath'))) } - return git.deleteDocument(entryPath, author).then(() => { + return wiki.git.deleteDocument(entryPath, author).then(() => { // Delete old cache version let oldEntryCachePath = entryHelper.getCachePath(entryPath) fs.unlinkAsync(oldEntryCachePath).catch((err) => { return true }) // eslint-disable-line handle-callback-err // Delete old index entry - search.delete(entryPath) + wiki.search.delete(entryPath) // Delete entry - return db.Entry.deleteOne({ _id: entryPath }) + return wiki.db.Entry.deleteOne({ _id: entryPath }) }) }, @@ -423,7 +421,7 @@ module.exports = { getStarter(entryPath) { let formattedTitle = _.startCase(_.last(_.split(entryPath, '/'))) - return fs.readFileAsync(path.join(SERVERPATH, 'app/content/create.md'), 'utf8').then((contents) => { + return fs.readFileAsync(path.join(wiki.SERVERPATH, 'app/content/create.md'), 'utf8').then((contents) => { return _.replace(contents, new RegExp('{TITLE}', 'g'), formattedTitle) }) }, @@ -436,17 +434,17 @@ module.exports = { * @return {Promise} List of entries */ getFromTree(basePath, usr) { - return db.Entry.find({ parentPath: basePath }, 'title parentPath isDirectory isEntry').sort({ title: 'asc' }).then(results => { + return wiki.db.Entry.find({ parentPath: basePath }, 'title parentPath isDirectory isEntry').sort({ title: 'asc' }).then(results => { return _.filter(results, r => { - return rights.checkRole('/' + r._id, usr.rights, 'read') + return wiki.rights.checkRole('/' + r._id, usr.rights, 'read') }) }) }, getHistory(entryPath) { - return db.Entry.findOne({ _id: entryPath, isEntry: true }).then(entry => { + return wiki.db.Entry.findOne({ _id: entryPath, isEntry: true }).then(entry => { if (!entry) { return false } - return git.getHistory(entryPath).then(history => { + return wiki.git.getHistory(entryPath).then(history => { return { meta: entry, history diff --git a/server/modules/markdown.js b/server/modules/markdown.js index 71e0ea54..7e258948 100644 --- a/server/modules/markdown.js +++ b/server/modules/markdown.js @@ -1,5 +1,3 @@ -'use strict' - /* global wiki */ const Promise = require('bluebird') @@ -58,8 +56,7 @@ var mkdown = md({ }) .use(mdAttrs) -// if (wiki.config.features.mathjax) { -if (true) { +if (wiki.config.features.mathjax) { mkdown.use(mdMathjax) } diff --git a/server/modules/search.js b/server/modules/search.js index 7801a739..26c17c6a 100644 --- a/server/modules/search.js +++ b/server/modules/search.js @@ -5,7 +5,7 @@ const Promise = require('bluebird') const _ = require('lodash') // const searchIndex = require('./search-index') -const stopWord = require('stopword') +// const stopWord = require('stopword') const streamToPromise = require('stream-to-promise') const searchAllowedChars = new RegExp('[^a-z0-9' + wiki.data.regex.cjk + wiki.data.regex.arabic + ' ]', 'g') @@ -22,7 +22,7 @@ module.exports = { init () { let self = this self._isReady = new Promise((resolve, reject) => { - /*searchIndex({ + /* searchIndex({ deletable: true, fieldedSearch: true, indexPath: 'wiki', diff --git a/server/modules/system.js b/server/modules/system.js index 8cf4dfcc..3c76645f 100644 --- a/server/modules/system.js +++ b/server/modules/system.js @@ -1,6 +1,6 @@ 'use strict' -/* global winston */ +/* global winston, ROOTPATH, appconfig */ const Promise = require('bluebird') const crypto = require('crypto') diff --git a/server/views/configure/index.pug b/server/views/configure/index.pug index 974fb89b..bf412654 100644 --- a/server/views/configure/index.pug +++ b/server/views/configure/index.pug @@ -26,7 +26,7 @@ block body .panel-content.form-sections section p - svg.icons.is-18.is-outlined.has-right-pad.is-text: use(xlink:href="#nc-cd-reader") + svg.icons.is-18.is-outlined.has-right-pad.is-text: use(xlink:href='#nc-cd-reader') span You are about to install Wiki.js #[strong= packageObj.version]. section p.control.is-fullwidth @@ -51,14 +51,14 @@ block body span System Check i(v-if='loading') .panel-content.is-text - p(v-if='loading') #[svg.icons.is-24.is-text: use(xlink:href="#nc-ms-dots")] Checking your system for compatibility... + p(v-if='loading') #[svg.icons.is-24.is-text: use(xlink:href='#nc-ms-dots')] Checking your system for compatibility... p(v-if='!loading && syscheck.ok') ul - li(v-for='rs in syscheck.results') #[svg.icons.is-18.is-text: use(xlink:href="#nc-check-bold")] {{rs}} + li(v-for='rs in syscheck.results') #[svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold')] {{rs}} p(v-if='!loading && syscheck.ok') - svg.icons.is-18.is-text: use(xlink:href="#nc-check-bold") + svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold') strong Looks good! No issues so far. - p(v-if='!loading && !syscheck.ok') #[svg.icons.is-18.is-text: use(xlink:href="#nc-square-remove-12")] Error: {{ syscheck.error }} + p(v-if='!loading && !syscheck.ok') #[svg.icons.is-18.is-text: use(xlink:href='#nc-square-remove-12')] Error: {{ syscheck.error }} .panel-footer .progress-bar: div(v-bind:style='{width: currentProgress}') button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToWelcome', v-bind:disabled='loading') Back @@ -218,14 +218,14 @@ block body span Git Repository Check i(v-if='loading') .panel-content.is-text - p(v-if='loading') #[svg.icons.is-24.is-text: use(xlink:href="#nc-ms-dots")] Verifying Git repository settings... + p(v-if='loading') #[svg.icons.is-24.is-text: use(xlink:href='#nc-ms-dots')] Verifying Git repository settings... p(v-if='!loading && gitcheck.ok') ul - li(v-for='rs in gitcheck.results') #[svg.icons.is-18.is-text: use(xlink:href="#nc-check-bold")] {{rs}} + li(v-for='rs in gitcheck.results') #[svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold')] {{rs}} p(v-if='!loading && gitcheck.ok') - svg.icons.is-18.is-text: use(xlink:href="#nc-check-bold") + svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold') strong Git settings are correct! - p(v-if='!loading && !gitcheck.ok') #[svg.icons.is-18.is-text: use(xlink:href="#nc-square-remove-12")] Error: {{ gitcheck.error }} + p(v-if='!loading && !gitcheck.ok') #[svg.icons.is-18.is-text: use(xlink:href='#nc-square-remove-12')] Error: {{ gitcheck.error }} .panel-footer .progress-bar: div(v-bind:style='{width: currentProgress}') button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToGit', v-bind:disabled='loading') Back @@ -280,11 +280,11 @@ block body section p.control.is-fullwidth label.label Connection String to Wiki.js 1.x MongoDB database - input(type='text', placeholder='mongodb://', v-model='conf.mongo', data-vv-scope='mongo', name='ipt-mongo', v-validate='{ required: true, min: 2 }') + input(type='text', placeholder='mongodb://', v-model='conf.mongo', data-vv-scope='upgrade', name='ipt-mongo', v-validate='{ required: true, min: 2 }') span.desc A MongoDB database connection string where a Wiki.js 1.x installation is located. #[strong No alterations will be made to this database. ] section p.control.is-fullwidth - input#ipt-public(type='checkbox', v-model='conf.public', data-vv-scope='general', name='ipt-public') + input#ipt-public(type='checkbox', v-model='conf.public', data-vv-scope='upgrade', name='ipt-public') label.label(for='ipt-public') Create groups based on individual permissions span.desc User groups will be created based on existing users permissions. If multiple users have the exact same permission rules, they will be put in the same user group. .panel-footer @@ -332,4 +332,4 @@ block body .footer small Wiki.js Installation Wizard - small(v-if='conf.telemetry') Telemetry Client ID: !{telemetryClientID} \ No newline at end of file + small(v-if='conf.telemetry') Telemetry Client ID: !{telemetryClientID} diff --git a/test/lint.js b/test/lint.js index 0a8f91bf..b6fea94b 100644 --- a/test/lint.js +++ b/test/lint.js @@ -59,12 +59,12 @@ expect.extend({ }) describe('Code Linting', () => { - it('should pass ESLint validation', () => { - const CLIEngine = require('eslint').CLIEngine - const cli = new CLIEngine() - let report = cli.executeOnFiles(['**/*.js']) - expect(report).toESLint() - }) + // it('should pass ESLint validation', () => { + // const CLIEngine = require('eslint').CLIEngine + // const cli = new CLIEngine() + // let report = cli.executeOnFiles(['**/*.js', '**/*.vue']) + // expect(report).toESLint() + // }) it('should pass PugLint validation', () => { const PugLint = require('pug-lint') diff --git a/tools/fuse_tasks.js b/tools/fuse_tasks.js index c9d0ee03..fec343dd 100644 --- a/tools/fuse_tasks.js +++ b/tools/fuse_tasks.js @@ -1,6 +1,3 @@ -'use strict' - -const _ = require('lodash') const Promise = require('bluebird') const colors = require('colors/safe') const fs = Promise.promisifyAll(require('fs-extra')) diff --git a/yarn.lock b/yarn.lock index efae57f7..c2264ba7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2575,6 +2575,13 @@ eslint-plugin-standard@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2" +eslint-plugin-vue@3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-3.13.1.tgz#875dc47a90c2e4034013b6ce1b915e5a5c6e9bf9" + dependencies: + requireindex "^1.1.0" + vue-eslint-parser "^2.0.1-beta.1" + eslint-scope@^3.7.1: version "3.7.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" @@ -2624,7 +2631,7 @@ eslint@4.10.0: table "^4.0.1" text-table "~0.2.0" -espree@^3.5.1: +espree@^3.3.2, espree@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e" dependencies: @@ -6727,6 +6734,10 @@ require_optional@~1.0.0: resolve-from "^2.0.0" semver "^5.1.0" +requireindex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162" + resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" @@ -7799,6 +7810,16 @@ vue-clipboards@1.1.0: dependencies: clipboard "^1.7.1" +vue-eslint-parser@^2.0.1-beta.1: + version "2.0.1-beta.1" + resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.1-beta.1.tgz#7e1b3c0865905264605169497fe9e42d27c1ae60" + dependencies: + debug "^3.0.0" + eslint-scope "^3.7.1" + espree "^3.3.2" + esquery "^1.0.0" + lodash "^4.17.4" + vue-hot-reload-api@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.2.0.tgz#9a21b35ced3634434a43ee80efb7350ea8fb206d"