From 547f3065d37b7be64e116a7c90efbaec90cef387 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Thu, 9 Feb 2017 20:24:28 -0500 Subject: [PATCH] Converted all client code to Standard JS compliant --- .editorconfig | 11 ++ .eslintrc.json | 174 +++++++++++++++++++++++ .pug-lintrc.json | 16 +++ .vscode/settings.json | 5 +- CHANGELOG.md | 6 +- assets/js/app.js | 4 +- client/js/app.js | 51 ++++--- client/js/components/alerts.js | 60 ++++---- client/js/components/editor-codeblock.js | 3 +- client/js/components/editor-file.js | 53 +++---- client/js/components/editor-image.js | 59 ++++---- client/js/components/editor-video.js | 13 +- client/js/components/editor.js | 42 +++--- client/js/components/search.js | 8 +- client/js/helpers/form.js | 3 + client/js/helpers/pages.js | 4 + client/js/login.js | 2 + client/js/modals/admin-users-create.js | 1 + client/js/modals/admin-users-delete.js | 1 + client/js/modals/create.js | 5 +- client/js/modals/move.js | 5 +- client/js/pages/admin.js | 9 +- client/js/pages/create.js | 9 +- client/js/pages/edit.js | 9 +- client/js/pages/source.js | 9 +- client/js/pages/view.js | 9 +- package.json | 8 +- wiki.sublime-project | 12 -- 28 files changed, 418 insertions(+), 173 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc.json create mode 100644 .pug-lintrc.json delete mode 100644 wiki.sublime-project diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..3ef077bc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{jade,pug}] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..2ebccbf6 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,174 @@ +{ + "parserOptions": { + "ecmaVersion": 8, + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + }, + "sourceType": "module" + }, + + "env": { + "es6": true, + "node": true + }, + + "plugins": [ + "standard", + "promise" + ], + + "globals": { + "document": false, + "navigator": false, + "window": false, + "app": true, + "appconfig": true, + "appdata": true, + "db": true, + "entries": true, + "git": true, + "lang": true, + "lcdata": true, + "mark": true, + "rights": true, + "upl": true, + "winston": true, + "ws": true, + "Mongoose": true, + "CORE_PATH": true, + "ROOTPATH": true, + "IS_DEBUG": true, + "PROCNAME": true, + "WSInternalKey": true + }, + + "rules": { + "accessor-pairs": 2, + "arrow-spacing": [2, { "before": true, "after": true }], + "block-spacing": [2, "always"], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2, { "properties": "never" }], + "comma-dangle": [2, "never"], + "comma-spacing": [2, { "before": false, "after": true }], + "comma-style": [2, "last"], + "constructor-super": 2, + "curly": [2, "multi-line"], + "dot-location": [2, "property"], + "eol-last": 2, + "eqeqeq": [2, "always", {"null": "ignore"}], + "func-call-spacing": [2, "never"], + "handle-callback-err": [2, "^(err|error)$" ], + "indent": [2, 2, { "SwitchCase": 1 }], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "keyword-spacing": [2, { "before": true, "after": true }], + "new-cap": [2, { "newIsCap": true, "capIsNew": false }], + "new-parens": 2, + "no-array-constructor": 2, + "no-caller": 2, + "no-class-assign": 2, + "no-cond-assign": 2, + "no-const-assign": 2, + "no-constant-condition": [2, { "checkLoops": false }], + "no-control-regex": 2, + "no-debugger": 2, + "no-delete-var": 2, + "no-dupe-args": 2, + "no-dupe-class-members": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-duplicate-imports": 2, + "no-empty-character-class": 2, + "no-empty-pattern": 2, + "no-eval": 2, + "no-ex-assign": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": [2, "functions"], + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-func-assign": 2, + "no-global-assign": 2, + "no-implied-eval": 2, + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-iterator": 2, + "no-label-var": 2, + "no-labels": [2, { "allowLoop": false, "allowSwitch": false }], + "no-lone-blocks": 2, + "no-mixed-spaces-and-tabs": 2, + "no-multi-spaces": 2, + "no-multi-str": 2, + "no-multiple-empty-lines": [2, { "max": 1 }], + "no-negated-in-lhs": 2, + "no-new": 2, + "no-new-func": 2, + "no-new-object": 2, + "no-new-require": 2, + "no-new-symbol": 2, + "no-new-wrappers": 2, + "no-obj-calls": 2, + "no-octal": 2, + "no-octal-escape": 2, + "no-path-concat": 2, + "no-proto": 2, + "no-redeclare": 2, + "no-regex-spaces": 2, + "no-return-assign": [2, "except-parens"], + "no-self-assign": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-shadow-restricted-names": 2, + "no-sparse-arrays": 2, + "no-tabs": 2, + "no-template-curly-in-string": 2, + "no-this-before-super": 2, + "no-throw-literal": 2, + "no-trailing-spaces": 2, + "no-undef": 2, + "no-undef-init": 2, + "no-unexpected-multiline": 2, + "no-unmodified-loop-condition": 2, + "no-unneeded-ternary": [2, { "defaultAssignment": false }], + "no-unreachable": 2, + "no-unsafe-finally": 2, + "no-unsafe-negation": 2, + "no-unused-vars": [2, { "vars": "all", "args": "none" }], + "no-useless-call": 2, + "no-useless-computed-key": 2, + "no-useless-constructor": 2, + "no-useless-escape": 2, + "no-useless-rename": 2, + "no-whitespace-before-property": 2, + "no-with": 2, + "object-property-newline": [2, { "allowMultiplePropertiesPerLine": true }], + "one-var": [2, { "initialized": "never" }], + "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }], + "padded-blocks": [2, "never"], + "quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }], + "rest-spread-spacing": [2, "never"], + "semi": [2, "never"], + "semi-spacing": [2, { "before": false, "after": true }], + "space-before-blocks": [2, "always"], + "space-before-function-paren": [2, "always"], + "space-in-parens": [2, "never"], + "space-infix-ops": 2, + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-comment": [2, "always", { "line": { "markers": ["*package", "!", ","] }, "block": { "balanced": true, "markers": ["*package", "!", ","], "exceptions": ["*"] } }], + "template-curly-spacing": [2, "never"], + "unicode-bom": [2, "never"], + "use-isnan": 2, + "valid-typeof": 2, + "wrap-iife": [2, "any", { "functionPrototypeMethods": true }], + "yield-star-spacing": [2, "both"], + "yoda": [2, "never"], + + "standard/object-curly-even-spacing": [2, "either"], + "standard/array-bracket-even-spacing": [2, "either"], + "standard/computed-property-even-spacing": [2, "even"], + + "promise/param-names": 2 + } +} diff --git a/.pug-lintrc.json b/.pug-lintrc.json new file mode 100644 index 00000000..13f6ab47 --- /dev/null +++ b/.pug-lintrc.json @@ -0,0 +1,16 @@ +{ + "disallowDuplicateAttributes": true, + "disallowIdAttributeWithStaticValue": true, + "disallowMultipleLineBreaks": true, + "requireClassLiteralsBeforeAttributes": true, + "requireIdLiteralsBeforeAttributes": true, + "requireLineFeedAtFileEnd": true, + "requireLowerCaseAttributes": true, + "requireLowerCaseTags": true, + "requireSpaceAfterCodeOperator": true, + "requireStrictEqualityOperators": true, + "validateAttributeQuoteMarks": true, + "validateAttributeSeparator": ", ", + "validateDivTags": true, + "validateIndentation": 2 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index a92f73ff..c4b054c8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "eslint.enable": false -} \ No newline at end of file + "eslint.enable": true, + "puglint.enable": true +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 1493ca68..2e483123 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,15 @@ # Change Log -All notable changes to this project will be documented in this file. +All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - Change log +- Added .editorconfig, .eslintrc.json and .pug-lintrc.json for code linting ### Fixed - Fixed issue with social accounts with empty name +- Fixed standard error page styling ### Changed - Updated dependencies + snyk policy @@ -21,4 +23,4 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Updated dependencies + snyk policy [Unreleased]: https://github.com/Requarks/wiki/compare/v1.0-beta.2...HEAD -[v1.0-beta.2]: https://github.com/Requarks/wiki/releases/tag/v1.0-beta.2 \ No newline at end of file +[v1.0-beta.2]: https://github.com/Requarks/wiki/releases/tag/v1.0-beta.2 diff --git a/assets/js/app.js b/assets/js/app.js index d1490a1d..b25f28df 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,2 +1,2 @@ -"use strict";function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}function setInputSelection(e,o,t){if(e.focus(),"undefined"!=typeof e.selectionStart)e.selectionStart=o,e.selectionEnd=t;else if(document.selection&&document.selection.createRange){e.select();var n=document.selection.createRange();n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",o),n.select()}}function makeSafePath(e){var o=_.split(_.trim(e),"/");return o=_.map(o,function(e){return _.kebabCase(_.deburr(_.trim(e)))}),_.join(_.filter(o,function(e){return!_.isEmpty(e)}),"/")}var _createClass=function(){function e(e,o){for(var t=0;t=3?(i.searchactive=!0,i.searchload++,n.emit("search",{terms:e},function(e){i.searchres=e.match,i.searchsuggest=e.suggest,i.searchmovearr=_.concat([],i.searchres,i.searchsuggest),i.searchload>0&&i.searchload--})):(i.searchactive=!1,i.searchres=[],i.searchsuggest=[],i.searchmovearr=[],i.searchload=0)},searchmoveidx:function(e,o){e>0?i.searchmovekey=i.searchmovearr[e-1]?"res."+i.searchmovearr[e-1]._id:"sug."+i.searchmovearr[e-1]:i.searchmovekey=""}},methods:{useSuggestion:function(e){i.searchq=e},closeSearch:function(){i.searchq=""},moveSelectSearch:function(){if(!(i.searchmoveidx<1)){var e=i.searchmoveidx-1;i.searchmovearr[e]?window.location.assign("/"+i.searchmovearr[e]._id):i.searchq=i.searchmovearr[e]}},moveDownSearch:function(){i.searchmoveidx0&&i.searchmoveidx--}}});e("main").on("click",i.closeSearch)}if(e("#page-type-view").length&&!function(){var o="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath"):"",n=o+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(n),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),o.length+1,n.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(o){13===o.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(o){var t=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(t)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+t))}),""!==o&&e(".btn-move-prompt").removeClass("is-hidden");var i=_.lastIndexOf(o,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(o),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),i,o.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(o){13===o.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(n){var i=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(i)||i===o||"home"===i?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:i},dataType:"json",method:"PUT"}).then(function(e,o,n){e.ok?window.location.assign("/"+i):t.pushError("Something went wrong",e.error)},function(e,o,n){t.pushError("Something went wrong","Save operation failed.")}))})}(),e("#page-type-create").length){var a;!function(){var i=e("#page-type-create").data("entrypath");e(".btn-create-discard").on("click",function(o){e("#modal-create-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var r=!1;Vue.filter("filesize",function(e){return _.toUpper(filesize(e))});var l=new Vue({el:"#modal-editor-image",data:{isLoading:!1,isLoadingText:"",newFolderName:"",newFolderShow:!1,newFolderError:!1,fetchFromUrlURL:"",fetchFromUrlShow:!1,folders:[],currentFolder:"",currentImage:"",currentAlign:"left",images:[],uploadSucceeded:!1,postUploadChecks:0,renameImageShow:!1,renameImageId:"",renameImageFilename:"",deleteImageShow:!1,deleteImageId:"",deleteImageFilename:""},methods:{open:function(){r=!0,e("#modal-editor-image").addClass("is-active"),l.refreshFolders()},cancel:function(o){r=!1,e("#modal-editor-image").removeClass("is-active")},selectImage:function(e){l.currentImage=e},insertImage:function(e){a.codemirror.doc.somethingSelected()&&a.codemirror.execCommand("singleSelection");var o=_.find(l.images,["_id",l.currentImage]);o.normalizedPath="f:"===o.folder?o.filename:o.folder.slice(2)+"/"+o.filename,o.titleGuess=_.startCase(o.basename);var t="!["+o.titleGuess+"](/uploads/"+o.normalizedPath+' "'+o.titleGuess+'")';switch(l.currentAlign){case"center":t+="{.align-center}";break;case"right":t+="{.align-right}";break;case"logo":t+="{.pagelogo}"}a.codemirror.doc.replaceSelection(t),l.cancel()},newFolder:function(o){l.newFolderName="",l.newFolderError=!1,l.newFolderShow=!0,_.delay(function(){e("#txt-editor-image-newfoldername").focus()},400)},newFolderDiscard:function(e){l.newFolderShow=!1},newFolderCreate:function(e){var o=new RegExp("^[a-z0-9][a-z0-9-]*[a-z0-9]$");return l.newFolderName=_.kebabCase(_.trim(l.newFolderName)),_.isEmpty(l.newFolderName)||!o.test(l.newFolderName)?void(l.newFolderError=!0):(l.newFolderDiscard(),l.isLoadingText="Creating new folder...",l.isLoading=!0,void Vue.nextTick(function(){n.emit("uploadsCreateFolder",{foldername:l.newFolderName},function(e){l.folders=e,l.currentFolder=l.newFolderName,l.images=[],l.isLoading=!1})}))},fetchFromUrl:function(o){l.fetchFromUrlURL="",l.fetchFromUrlShow=!0,_.delay(function(){e("#txt-editor-image-fetchurl").focus()},400)},fetchFromUrlDiscard:function(e){l.fetchFromUrlShow=!1},fetchFromUrlGo:function(e){l.fetchFromUrlDiscard(),l.isLoadingText="Fetching image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsFetchFileFromURL",{folder:l.currentFolder,fetchUrl:l.fetchFromUrlURL},function(e){e.ok?l.waitChangeComplete(l.images.length,!0):(l.isLoading=!1,t.pushError("Upload error",e.msg))})})},renameImage:function(){var o=_.find(l.images,["_id",l.renameImageId]);l.renameImageFilename=o.basename||"",l.renameImageShow=!0,_.delay(function(){e("#txt-editor-image-rename").focus(),_.defer(function(){e("#txt-editor-image-rename").select()})},400)},renameImageDiscard:function(){l.renameImageShow=!1},renameImageGo:function(){l.renameImageDiscard(),l.isLoadingText="Renaming image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsRenameFile",{uid:l.renameImageId,folder:l.currentFolder,filename:l.renameImageFilename},function(e){e.ok?l.waitChangeComplete(l.images.length,!1):(l.isLoading=!1,t.pushError("Rename error",e.msg))})})},moveImage:function(e,o){l.isLoadingText="Moving image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsMoveFile",{uid:e,folder:o},function(e){e.ok?l.loadImages():(l.isLoading=!1,t.pushError("Rename error",e.msg))})})},deleteImageWarn:function(e){if(e){var o=_.find(l.images,["_id",l.deleteImageId]);l.deleteImageFilename=o.filename||"this image"}l.deleteImageShow=e},deleteImageGo:function(){l.deleteImageWarn(!1),l.isLoadingText="Deleting image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsDeleteFile",{uid:l.deleteImageId},function(e){l.loadImages()})})},selectFolder:function(e){l.currentFolder=e,l.loadImages()},refreshFolders:function(){l.isLoadingText="Fetching folders list...",l.isLoading=!0,l.currentFolder="",l.currentImage="",Vue.nextTick(function(){n.emit("uploadsGetFolders",{},function(e){l.folders=e,l.loadImages()})})},loadImages:function(e){return e||(l.isLoadingText="Fetching images...",l.isLoading=!0),new Promise(function(o,t){Vue.nextTick(function(){n.emit("uploadsGetImages",{folder:l.currentFolder},function(t){l.images=t,e||(l.isLoading=!1),l.attachContextMenus(),o(!0)})})})},waitChangeComplete:function(e,o){o=!_.isBoolean(o)||o,l.postUploadChecks++,l.isLoadingText="Processing...",Vue.nextTick(function(){l.loadImages(!0).then(function(){l.images.length!==e===o?(l.postUploadChecks=0,l.isLoading=!1):l.postUploadChecks>5?(l.postUploadChecks=0,l.isLoading=!1,t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){l.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(l.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(l.folders,o);l.moveImage(n,i)}}});e.contextMenu("destroy",".editor-modal-image-choices > figure"),e.contextMenu({selector:".editor-modal-image-choices > figure",appendTo:".editor-modal-image-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/2,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){l.renameImageId=_.toString(o.$trigger[0].dataset.uid),l.renameImage()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){l.deleteImageId=_.toString(o.$trigger[0].dataset.uid),l.deleteImageWarn(!0)}}}})}}});e("#btn-editor-image-upload input").on("change",function(n){var i=l.images.length;e(n.currentTarget).simpleUpload("/uploads/img",{name:"imgfile",data:{folder:l.currentFolder},limit:20,expect:"json",allowedExts:["jpg","jpeg","gif","png","webp"],allowedTypes:["image/png","image/jpeg","image/gif","image/webp"],maxFileSize:3145728,init:function(e){l.uploadSucceeded=!1,l.isLoadingText="Preparing to upload...",l.isLoading=!0},progress:function(e){l.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length5?(d.postUploadChecks=0,d.isLoading=!1,t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){d.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(d.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(d.folders,o);d.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){d.renameFileId=_.toString(o.$trigger[0].dataset.uid),d.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){d.deleteFileId=_.toString(o.$trigger[0].dataset.uid),d.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(n){var i=d.files.length;e(n.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:d.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){d.uploadSucceeded=!1,d.isLoadingText="Preparing to upload...",d.isLoading=!0},progress:function(e){d.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length5?(l.postUploadChecks=0,l.isLoading=!1,t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){l.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(l.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(l.folders,o);l.moveImage(n,i)}}});e.contextMenu("destroy",".editor-modal-image-choices > figure"),e.contextMenu({selector:".editor-modal-image-choices > figure",appendTo:".editor-modal-image-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/2,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){l.renameImageId=_.toString(o.$trigger[0].dataset.uid),l.renameImage()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){l.deleteImageId=_.toString(o.$trigger[0].dataset.uid),l.deleteImageWarn(!0)}}}})}}});e("#btn-editor-image-upload input").on("change",function(n){var i=l.images.length;e(n.currentTarget).simpleUpload("/uploads/img",{name:"imgfile",data:{folder:l.currentFolder},limit:20,expect:"json",allowedExts:["jpg","jpeg","gif","png","webp"],allowedTypes:["image/png","image/jpeg","image/gif","image/webp"],maxFileSize:3145728,init:function(e){l.uploadSucceeded=!1,l.isLoadingText="Preparing to upload...",l.isLoading=!0},progress:function(e){l.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length5?(d.postUploadChecks=0,d.isLoading=!1, -t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){d.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(d.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(d.folders,o);d.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){d.renameFileId=_.toString(o.$trigger[0].dataset.uid),d.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){d.deleteFileId=_.toString(o.$trigger[0].dataset.uid),d.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(n){var i=d.files.length;e(n.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:d.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){d.uploadSucceeded=!1,d.isLoadingText="Preparing to upload...",d.isLoading=!0},progress:function(e){d.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length=0&&n&&(n.class+=" exit",Vue.set(o.mdl.children,t,n),_.delay(function(){o.mdl.children.splice(t,1)},500))}}]),e}(); \ No newline at end of file +"use strict";function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}function setInputSelection(e,o,t){if(e.focus(),"undefined"!=typeof e.selectionStart)e.selectionStart=o,e.selectionEnd=t;else if(document.selection&&document.selection.createRange){e.select();var n=document.selection.createRange();n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",o),n.select()}}function makeSafePath(e){var o=_.split(_.trim(e),"/");return o=_.map(o,function(e){return _.kebabCase(_.deburr(_.trim(e)))}),_.join(_.filter(o,function(e){return!_.isEmpty(e)}),"/")}var _createClass=function(){function e(e,o){for(var t=0;t=3?(i.searchactive=!0,i.searchload++,n.emit("search",{terms:e},function(e){i.searchres=e.match,i.searchsuggest=e.suggest,i.searchmovearr=_.concat([],i.searchres,i.searchsuggest),i.searchload>0&&i.searchload--})):(i.searchactive=!1,i.searchres=[],i.searchsuggest=[],i.searchmovearr=[],i.searchload=0)},searchmoveidx:function(e,o){e>0?i.searchmovekey=i.searchmovearr[e-1]?"res."+i.searchmovearr[e-1]._id:"sug."+i.searchmovearr[e-1]:i.searchmovekey=""}},methods:{useSuggestion:function(e){i.searchq=e},closeSearch:function(){i.searchq=""},moveSelectSearch:function(){if(!(i.searchmoveidx<1)){var e=i.searchmoveidx-1;i.searchmovearr[e]?window.location.assign("/"+i.searchmovearr[e]._id):i.searchq=i.searchmovearr[e]}},moveDownSearch:function(){i.searchmoveidx0&&i.searchmoveidx--}}});e("main").on("click",i.closeSearch)}if(e("#page-type-view").length&&!function(){var o="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath"):"",n=o+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(n),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),o.length+1,n.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(o){13===o.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(o){var t=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(t)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+t))}),""!==o&&e(".btn-move-prompt").removeClass("is-hidden");var i=_.lastIndexOf(o,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(o),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),i,o.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(o){13===o.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(n){var i=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(i)||i===o||"home"===i?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:i},dataType:"json",method:"PUT"}).then(function(e,o,n){e.ok?window.location.assign("/"+i):t.pushError("Something went wrong",e.error)},function(e,o,n){t.pushError("Something went wrong","Save operation failed.")}))})}(),e("#page-type-create").length){var a;!function(){var i=e("#page-type-create").data("entrypath");e(".btn-create-discard").on("click",function(o){e("#modal-create-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var r=!1;Vue.filter("filesize",function(e){return _.toUpper(filesize(e))});var l=new Vue({el:"#modal-editor-image",data:{isLoading:!1,isLoadingText:"",newFolderName:"",newFolderShow:!1,newFolderError:!1,fetchFromUrlURL:"",fetchFromUrlShow:!1,folders:[],currentFolder:"",currentImage:"",currentAlign:"left",images:[],uploadSucceeded:!1,postUploadChecks:0,renameImageShow:!1,renameImageId:"",renameImageFilename:"",deleteImageShow:!1,deleteImageId:"",deleteImageFilename:""},methods:{open:function(){r=!0,e("#modal-editor-image").addClass("is-active"),l.refreshFolders()},cancel:function(o){r=!1,e("#modal-editor-image").removeClass("is-active")},selectImage:function(e){l.currentImage=e},insertImage:function(e){a.codemirror.doc.somethingSelected()&&a.codemirror.execCommand("singleSelection");var o=_.find(l.images,["_id",l.currentImage]);o.normalizedPath="f:"===o.folder?o.filename:o.folder.slice(2)+"/"+o.filename,o.titleGuess=_.startCase(o.basename);var t="!["+o.titleGuess+"](/uploads/"+o.normalizedPath+' "'+o.titleGuess+'")';switch(l.currentAlign){case"center":t+="{.align-center}";break;case"right":t+="{.align-right}";break;case"logo":t+="{.pagelogo}"}a.codemirror.doc.replaceSelection(t),l.cancel()},newFolder:function(o){l.newFolderName="",l.newFolderError=!1,l.newFolderShow=!0,_.delay(function(){e("#txt-editor-image-newfoldername").focus()},400)},newFolderDiscard:function(e){l.newFolderShow=!1},newFolderCreate:function(e){var o=new RegExp("^[a-z0-9][a-z0-9-]*[a-z0-9]$");return l.newFolderName=_.kebabCase(_.trim(l.newFolderName)),_.isEmpty(l.newFolderName)||!o.test(l.newFolderName)?void(l.newFolderError=!0):(l.newFolderDiscard(),l.isLoadingText="Creating new folder...",l.isLoading=!0,void Vue.nextTick(function(){n.emit("uploadsCreateFolder",{foldername:l.newFolderName},function(e){l.folders=e,l.currentFolder=l.newFolderName,l.images=[],l.isLoading=!1})}))},fetchFromUrl:function(o){l.fetchFromUrlURL="",l.fetchFromUrlShow=!0,_.delay(function(){e("#txt-editor-image-fetchurl").focus()},400)},fetchFromUrlDiscard:function(e){l.fetchFromUrlShow=!1},fetchFromUrlGo:function(e){l.fetchFromUrlDiscard(),l.isLoadingText="Fetching image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsFetchFileFromURL",{folder:l.currentFolder,fetchUrl:l.fetchFromUrlURL},function(e){e.ok?l.waitChangeComplete(l.images.length,!0):(l.isLoading=!1,t.pushError("Upload error",e.msg))})})},renameImage:function(){var o=_.find(l.images,["_id",l.renameImageId]);l.renameImageFilename=o.basename||"",l.renameImageShow=!0,_.delay(function(){e("#txt-editor-image-rename").focus(),_.defer(function(){e("#txt-editor-image-rename").select()})},400)},renameImageDiscard:function(){l.renameImageShow=!1},renameImageGo:function(){l.renameImageDiscard(),l.isLoadingText="Renaming image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsRenameFile",{uid:l.renameImageId,folder:l.currentFolder,filename:l.renameImageFilename},function(e){e.ok?l.waitChangeComplete(l.images.length,!1):(l.isLoading=!1,t.pushError("Rename error",e.msg))})})},moveImage:function(e,o){l.isLoadingText="Moving image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsMoveFile",{uid:e,folder:o},function(e){e.ok?l.loadImages():(l.isLoading=!1,t.pushError("Rename error",e.msg))})})},deleteImageWarn:function(e){if(e){var o=_.find(l.images,["_id",l.deleteImageId]);l.deleteImageFilename=o.filename||"this image"}l.deleteImageShow=e},deleteImageGo:function(){l.deleteImageWarn(!1),l.isLoadingText="Deleting image...",l.isLoading=!0,Vue.nextTick(function(){n.emit("uploadsDeleteFile",{uid:l.deleteImageId},function(e){l.loadImages()})})},selectFolder:function(e){l.currentFolder=e,l.loadImages()},refreshFolders:function(){l.isLoadingText="Fetching folders list...",l.isLoading=!0,l.currentFolder="",l.currentImage="",Vue.nextTick(function(){n.emit("uploadsGetFolders",{},function(e){l.folders=e,l.loadImages()})})},loadImages:function(e){return e||(l.isLoadingText="Fetching images...",l.isLoading=!0),new Promise(function(o,t){Vue.nextTick(function(){n.emit("uploadsGetImages",{folder:l.currentFolder},function(t){l.images=t,e||(l.isLoading=!1),l.attachContextMenus(),o(!0)})})})},waitChangeComplete:function(e,o){o=!_.isBoolean(o)||o,l.postUploadChecks++,l.isLoadingText="Processing...",Vue.nextTick(function(){l.loadImages(!0).then(function(){l.images.length!==e===o?(l.postUploadChecks=0,l.isLoading=!1):l.postUploadChecks>5?(l.postUploadChecks=0,l.isLoading=!1,t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){l.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(l.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(l.folders,o);l.moveImage(n,i)}}});e.contextMenu("destroy",".editor-modal-image-choices > figure"),e.contextMenu({selector:".editor-modal-image-choices > figure",appendTo:".editor-modal-image-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/2,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){l.renameImageId=_.toString(o.$trigger[0].dataset.uid),l.renameImage()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){l.deleteImageId=_.toString(o.$trigger[0].dataset.uid),l.deleteImageWarn(!0)}}}})}}});e("#btn-editor-image-upload input").on("change",function(n){var i=l.images.length;e(n.currentTarget).simpleUpload("/uploads/img",{name:"imgfile",data:{folder:l.currentFolder},limit:20,expect:"json",allowedExts:["jpg","jpeg","gif","png","webp"],allowedTypes:["image/png","image/jpeg","image/gif","image/webp"],maxFileSize:3145728,init:function(e){l.uploadSucceeded=!1,l.isLoadingText="Preparing to upload...",l.isLoading=!0},progress:function(e){l.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length5?(d.postUploadChecks=0,d.isLoading=!1,t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){d.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(d.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(d.folders,o);d.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){d.renameFileId=_.toString(o.$trigger[0].dataset.uid),d.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){d.deleteFileId=_.toString(o.$trigger[0].dataset.uid),d.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(n){var i=d.files.length;e(n.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:d.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){d.uploadSucceeded=!1,d.isLoadingText="Preparing to upload...",d.isLoading=!0},progress:function(e){d.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length5?(l.postUploadChecks=0,l.isLoading=!1,t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){l.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(l.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(l.folders,o);l.moveImage(n,i)}}});e.contextMenu("destroy",".editor-modal-image-choices > figure"),e.contextMenu({selector:".editor-modal-image-choices > figure",appendTo:".editor-modal-image-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/2,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){l.renameImageId=_.toString(o.$trigger[0].dataset.uid),l.renameImage()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){l.deleteImageId=_.toString(o.$trigger[0].dataset.uid),l.deleteImageWarn(!0)}}}})}}});e("#btn-editor-image-upload input").on("change",function(n){var i=l.images.length;e(n.currentTarget).simpleUpload("/uploads/img",{name:"imgfile",data:{folder:l.currentFolder},limit:20,expect:"json",allowedExts:["jpg","jpeg","gif","png","webp"],allowedTypes:["image/png","image/jpeg","image/gif","image/webp"],maxFileSize:3145728,init:function(e){l.uploadSucceeded=!1,l.isLoadingText="Preparing to upload...",l.isLoading=!0},progress:function(e){l.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length5?(d.postUploadChecks=0,d.isLoading=!1, +t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){d.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){var o=_.map(d.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){var n=_.toString(e(t.$trigger).data("uid")),i=_.nth(d.folders,o);d.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");var i=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){d.renameFileId=_.toString(o.$trigger[0].dataset.uid),d.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){d.deleteFileId=_.toString(o.$trigger[0].dataset.uid),d.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(n){var i=d.files.length;e(n.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:d.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){d.uploadSucceeded=!1,d.isLoadingText="Preparing to upload...",d.isLoading=!0},progress:function(e){d.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){var o=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length=0&&n&&(n.class+=" exit",Vue.set(o.mdl.children,t,n),_.delay(function(){o.mdl.children.splice(t,1)},500))}}]),e}(); \ No newline at end of file diff --git a/client/js/app.js b/client/js/app.js index b5a0517f..695a57e5 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -1,20 +1,23 @@ 'use strict' +/* global jQuery, _, io, Sticky, alertsData, Alerts */ +/* eslint-disable spaced-comment */ + jQuery(document).ready(function ($) { - // ==================================== - // Scroll - // ==================================== + // ==================================== + // Scroll + // ==================================== $('a').smoothScroll({ speed: 400, offset: -70 }) - var sticky = new Sticky('.stickyscroll') + var sticky = new Sticky('.stickyscroll') // eslint-disable-line no-unused-vars - // ==================================== - // Notifications - // ==================================== + // ==================================== + // Notifications + // ==================================== $(window).bind('beforeunload', () => { $('#notifload').addClass('active') @@ -32,26 +35,28 @@ jQuery(document).ready(function ($) { }) } - // ==================================== - // Establish WebSocket connection - // ==================================== + // ==================================== + // Establish WebSocket connection + // ==================================== - var socket = io(window.location.origin) + var socket = io(window.location.origin) // eslint-disable-line no-unused-vars - // =include components/search.js + //=include components/search.js - // ==================================== - // Pages logic - // ==================================== + // ==================================== + // Pages logic + // ==================================== - // =include pages/view.js - // =include pages/create.js - // =include pages/edit.js - // =include pages/source.js - // =include pages/admin.js + //=include pages/view.js + //=include pages/create.js + //=include pages/edit.js + //=include pages/source.js + //=include pages/admin.js }) -// =include helpers/form.js -// =include helpers/pages.js +//=include helpers/form.js +//=include helpers/pages.js -// =include components/alerts.js +//=include components/alerts.js + +/* eslint-enable spaced-comment */ diff --git a/client/js/components/alerts.js b/client/js/components/alerts.js index 65034cb1..2538ef71 100644 --- a/client/js/components/alerts.js +++ b/client/js/components/alerts.js @@ -1,15 +1,17 @@ 'use strict' +/* global Vue, _ */ + /** * Alerts */ -class Alerts { +class Alerts { // eslint-disable-line no-unused-vars - /** - * Constructor - * - * @class - */ + /** + * Constructor + * + * @class + */ constructor () { let self = this @@ -28,12 +30,12 @@ class Alerts { self.uidNext = 1 } - /** - * Show a new Alert - * - * @param {Object} options Alert properties - * @return {null} Void - */ + /** + * Show a new Alert + * + * @param {Object} options Alert properties + * @return {null} Void + */ push (options) { let self = this @@ -56,12 +58,12 @@ class Alerts { self.uidNext++ } - /** - * Shorthand method for pushing errors - * - * @param {String} title The title - * @param {String} message The message - */ + /** + * Shorthand method for pushing errors + * + * @param {String} title The title + * @param {String} message The message + */ pushError (title, message) { this.push({ class: 'error', @@ -71,12 +73,12 @@ class Alerts { }) } - /** - * Shorthand method for pushing success messages - * - * @param {String} title The title - * @param {String} message The message - */ + /** + * Shorthand method for pushing success messages + * + * @param {String} title The title + * @param {String} message The message + */ pushSuccess (title, message) { this.push({ class: 'success', @@ -86,11 +88,11 @@ class Alerts { }) } - /** - * Close an alert - * - * @param {Integer} uid The unique ID of the alert - */ + /** + * Close an alert + * + * @param {Integer} uid The unique ID of the alert + */ close (uid) { let self = this diff --git a/client/js/components/editor-codeblock.js b/client/js/components/editor-codeblock.js index 4d6f8768..a8fdc574 100644 --- a/client/js/components/editor-codeblock.js +++ b/client/js/components/editor-codeblock.js @@ -1,3 +1,4 @@ +/* global $, Vue, ace, mde, _ */ let modelist = ace.require('ace/ext/modelist') let codeEditor = null @@ -57,7 +58,7 @@ let vueCodeBlock = new Vue({ }, 300) }, cancel: (ev) => { - mdeModalOpenState = false + mdeModalOpenState = false // eslint-disable-line no-undef $('#modal-editor-codeblock').removeClass('is-active') vueCodeBlock.initContent = '' }, diff --git a/client/js/components/editor-file.js b/client/js/components/editor-file.js index a7238198..6cdc2ffe 100644 --- a/client/js/components/editor-file.js +++ b/client/js/components/editor-file.js @@ -1,3 +1,4 @@ +/* global $, Vue, _, alerts, mde, socket */ let vueFile = new Vue({ el: '#modal-editor-file', @@ -23,18 +24,18 @@ let vueFile = new Vue({ methods: { open: () => { - mdeModalOpenState = true + mdeModalOpenState = true // eslint-disable-line no-undef $('#modal-editor-file').addClass('is-active') vueFile.refreshFolders() }, cancel: (ev) => { - mdeModalOpenState = false + mdeModalOpenState = false // eslint-disable-line no-undef $('#modal-editor-file').removeClass('is-active') }, - // ------------------------------------------- - // INSERT LINK TO FILE - // ------------------------------------------- + // ------------------------------------------- + // INSERT LINK TO FILE + // ------------------------------------------- selectFile: (fileId) => { vueFile.currentFile = fileId @@ -54,9 +55,9 @@ let vueFile = new Vue({ vueFile.cancel() }, - // ------------------------------------------- - // NEW FOLDER - // ------------------------------------------- + // ------------------------------------------- + // NEW FOLDER + // ------------------------------------------- newFolder: (ev) => { vueFile.newFolderName = '' @@ -68,7 +69,7 @@ let vueFile = new Vue({ vueFile.newFolderShow = false }, newFolderCreate: (ev) => { - let regFolderName = new RegExp('^[a-z0-9][a-z0-9\-]*[a-z0-9]$') + let regFolderName = new RegExp('^[a-z0-9][a-z0-9-]*[a-z0-9]$') vueFile.newFolderName = _.kebabCase(_.trim(vueFile.newFolderName)) if (_.isEmpty(vueFile.newFolderName) || !regFolderName.test(vueFile.newFolderName)) { @@ -90,12 +91,12 @@ let vueFile = new Vue({ }) }, - // ------------------------------------------- - // RENAME FILE - // ------------------------------------------- + // ------------------------------------------- + // RENAME FILE + // ------------------------------------------- renameFile: () => { - let c = _.find(vueFile.files, ['_id', vueFile.renameFileId ]) + let c = _.find(vueFile.files, [ '_id', vueFile.renameFileId ]) vueFile.renameFileFilename = c.basename || '' vueFile.renameFileShow = true _.delay(() => { @@ -123,9 +124,9 @@ let vueFile = new Vue({ }) }, - // ------------------------------------------- - // MOVE FILE - // ------------------------------------------- + // ------------------------------------------- + // MOVE FILE + // ------------------------------------------- moveFile: (uid, fld) => { vueFile.isLoadingText = 'Moving file...' @@ -142,13 +143,13 @@ let vueFile = new Vue({ }) }, - // ------------------------------------------- - // DELETE FILE - // ------------------------------------------- + // ------------------------------------------- + // DELETE FILE + // ------------------------------------------- deleteFileWarn: (show) => { if (show) { - let c = _.find(vueFile.files, ['_id', vueFile.deleteFileId ]) + let c = _.find(vueFile.files, [ '_id', vueFile.deleteFileId ]) vueFile.deleteFileFilename = c.filename || 'this file' } vueFile.deleteFileShow = show @@ -164,9 +165,9 @@ let vueFile = new Vue({ }) }, - // ------------------------------------------- - // LOAD FROM REMOTE - // ------------------------------------------- + // ------------------------------------------- + // LOAD FROM REMOTE + // ------------------------------------------- selectFolder: (fldName) => { vueFile.currentFolder = fldName @@ -229,9 +230,9 @@ let vueFile = new Vue({ }) }, - // ------------------------------------------- - // IMAGE CONTEXT MENU - // ------------------------------------------- + // ------------------------------------------- + // IMAGE CONTEXT MENU + // ------------------------------------------- attachContextMenus: () => { let moveFolders = _.map(vueFile.folders, (f) => { diff --git a/client/js/components/editor-image.js b/client/js/components/editor-image.js index b40907c3..5d34f56a 100644 --- a/client/js/components/editor-image.js +++ b/client/js/components/editor-image.js @@ -1,3 +1,4 @@ +/* global $, Vue, mde, _, alerts, socket */ let vueImage = new Vue({ el: '#modal-editor-image', @@ -26,18 +27,18 @@ let vueImage = new Vue({ methods: { open: () => { - mdeModalOpenState = true + mdeModalOpenState = true // eslint-disable-line no-undef $('#modal-editor-image').addClass('is-active') vueImage.refreshFolders() }, cancel: (ev) => { - mdeModalOpenState = false + mdeModalOpenState = false // eslint-disable-line no-undef $('#modal-editor-image').removeClass('is-active') }, - // ------------------------------------------- - // INSERT IMAGE - // ------------------------------------------- + // ------------------------------------------- + // INSERT IMAGE + // ------------------------------------------- selectImage: (imageId) => { vueImage.currentImage = imageId @@ -68,9 +69,9 @@ let vueImage = new Vue({ vueImage.cancel() }, - // ------------------------------------------- - // NEW FOLDER - // ------------------------------------------- + // ------------------------------------------- + // NEW FOLDER + // ------------------------------------------- newFolder: (ev) => { vueImage.newFolderName = '' @@ -82,7 +83,7 @@ let vueImage = new Vue({ vueImage.newFolderShow = false }, newFolderCreate: (ev) => { - let regFolderName = new RegExp('^[a-z0-9][a-z0-9\-]*[a-z0-9]$') + let regFolderName = new RegExp('^[a-z0-9][a-z0-9-]*[a-z0-9]$') vueImage.newFolderName = _.kebabCase(_.trim(vueImage.newFolderName)) if (_.isEmpty(vueImage.newFolderName) || !regFolderName.test(vueImage.newFolderName)) { @@ -104,9 +105,9 @@ let vueImage = new Vue({ }) }, - // ------------------------------------------- - // FETCH FROM URL - // ------------------------------------------- + // ------------------------------------------- + // FETCH FROM URL + // ------------------------------------------- fetchFromUrl: (ev) => { vueImage.fetchFromUrlURL = '' @@ -133,12 +134,12 @@ let vueImage = new Vue({ }) }, - // ------------------------------------------- - // RENAME IMAGE - // ------------------------------------------- + // ------------------------------------------- + // RENAME IMAGE + // ------------------------------------------- renameImage: () => { - let c = _.find(vueImage.images, ['_id', vueImage.renameImageId ]) + let c = _.find(vueImage.images, [ '_id', vueImage.renameImageId ]) vueImage.renameImageFilename = c.basename || '' vueImage.renameImageShow = true _.delay(() => { @@ -166,9 +167,9 @@ let vueImage = new Vue({ }) }, - // ------------------------------------------- - // MOVE IMAGE - // ------------------------------------------- + // ------------------------------------------- + // MOVE IMAGE + // ------------------------------------------- moveImage: (uid, fld) => { vueImage.isLoadingText = 'Moving image...' @@ -185,13 +186,13 @@ let vueImage = new Vue({ }) }, - // ------------------------------------------- - // DELETE IMAGE - // ------------------------------------------- + // ------------------------------------------- + // DELETE IMAGE + // ------------------------------------------- deleteImageWarn: (show) => { if (show) { - let c = _.find(vueImage.images, ['_id', vueImage.deleteImageId ]) + let c = _.find(vueImage.images, [ '_id', vueImage.deleteImageId ]) vueImage.deleteImageFilename = c.filename || 'this image' } vueImage.deleteImageShow = show @@ -207,9 +208,9 @@ let vueImage = new Vue({ }) }, - // ------------------------------------------- - // LOAD FROM REMOTE - // ------------------------------------------- + // ------------------------------------------- + // LOAD FROM REMOTE + // ------------------------------------------- selectFolder: (fldName) => { vueImage.currentFolder = fldName @@ -272,9 +273,9 @@ let vueImage = new Vue({ }) }, - // ------------------------------------------- - // IMAGE CONTEXT MENU - // ------------------------------------------- + // ------------------------------------------- + // IMAGE CONTEXT MENU + // ------------------------------------------- attachContextMenus: () => { let moveFolders = _.map(vueImage.folders, (f) => { diff --git a/client/js/components/editor-video.js b/client/js/components/editor-video.js index 7ba99ee7..f20a14de 100644 --- a/client/js/components/editor-video.js +++ b/client/js/components/editor-video.js @@ -1,8 +1,9 @@ +/* global $, Vue, mde, _ */ const videoRules = { - 'youtube': new RegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/, 'i'), - 'vimeo': new RegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/, 'i'), - 'dailymotion': new RegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/, 'i') + 'youtube': new RegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|&v(?:i)?=))([^#&?]*).*/, 'i'), + 'vimeo': new RegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/, 'i'), + 'dailymotion': new RegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/, 'i') } // Vue Video instance @@ -18,7 +19,7 @@ let vueVideo = new Vue({ $('#modal-editor-video input').focus() }, cancel: (ev) => { - mdeModalOpenState = false + mdeModalOpenState = false // eslint-disable-line no-undef $('#modal-editor-video').removeClass('is-active') vueVideo.link = '' }, @@ -27,7 +28,7 @@ let vueVideo = new Vue({ mde.codemirror.execCommand('singleSelection') } - // Guess video type + // Guess video type let videoType = _.findKey(videoRules, (vr) => { return vr.test(vueVideo.link) @@ -36,7 +37,7 @@ let vueVideo = new Vue({ videoType = 'video' } - // Insert video tag + // Insert video tag let videoText = '[video](' + vueVideo.link + '){.' + videoType + '}\n' diff --git a/client/js/components/editor.js b/client/js/components/editor.js index 016902e2..e1e0f500 100644 --- a/client/js/components/editor.js +++ b/client/js/components/editor.js @@ -1,3 +1,6 @@ +'use strict' + +/* global $, Vue, _, filesize, SimpleMDE, alerts, vueImage, vueFile, vueVideo, vueCodeBlock */ // ==================================== // Markdown Editor @@ -5,16 +8,18 @@ if ($('#mk-editor').length === 1) { let mdeModalOpenState = false - let mdeCurrentEditor = null + let mdeCurrentEditor = null // eslint-disable-line no-unused-vars Vue.filter('filesize', (v) => { return _.toUpper(filesize(v)) }) - // =include editor-image.js - // =include editor-file.js - // =include editor-video.js - // =include editor-codeblock.js + /* eslint-disable spaced-comment */ + //=include editor-image.js + //=include editor-file.js + //=include editor-video.js + //=include editor-codeblock.js + /* eslint-enable spaced-comment */ var mde = new SimpleMDE({ autofocus: true, @@ -23,12 +28,13 @@ if ($('#mk-editor').length === 1) { placeholder: 'Enter Markdown formatted content here...', spellChecker: false, status: false, - toolbar: [{ - name: 'bold', - action: SimpleMDE.toggleBold, - className: 'icon-bold', - title: 'Bold' - }, + toolbar: [ + { + name: 'bold', + action: SimpleMDE.toggleBold, + className: 'icon-bold', + title: 'Bold' + }, { name: 'italic', action: SimpleMDE.toggleItalic, @@ -83,10 +89,10 @@ if ($('#mk-editor').length === 1) { { name: 'link', action: (editor) => { - /* if(!mdeModalOpenState) { - mdeModalOpenState = true; - $('#modal-editor-link').slideToggle(); - } */ + /* if(!mdeModalOpenState) { + mdeModalOpenState = true; + $('#modal-editor-link').slideToggle(); + } */ }, className: 'icon-link2', title: 'Insert Link' @@ -157,7 +163,7 @@ if ($('#mk-editor').length === 1) { { name: 'table', action: (editor) => { - // todo + // todo }, className: 'icon-table', title: 'Insert Table' @@ -175,7 +181,7 @@ if ($('#mk-editor').length === 1) { } }) - // -> Save + // -> Save let saveCurrentDocument = (ev) => { $.ajax(window.location.href, { @@ -186,7 +192,7 @@ if ($('#mk-editor').length === 1) { method: 'PUT' }).then((rData, rStatus, rXHR) => { if (rData.ok) { - window.location.assign('/' + pageEntryPath) + window.location.assign('/' + pageEntryPath) // eslint-disable-line no-undef } else { alerts.pushError('Something went wrong', rData.error) } diff --git a/client/js/components/search.js b/client/js/components/search.js index 40fb3cf7..ab67f278 100644 --- a/client/js/components/search.js +++ b/client/js/components/search.js @@ -1,5 +1,7 @@ 'use strict' +/* global $, Vue, _, socket */ + if ($('#search-input').length) { $('#search-input').focus() @@ -39,9 +41,9 @@ if ($('#search-input').length) { }, searchmoveidx: (val, oldVal) => { if (val > 0) { - vueHeader.searchmovekey = (vueHeader.searchmovearr[val - 1]) ? - 'res.' + vueHeader.searchmovearr[val - 1]._id : - 'sug.' + vueHeader.searchmovearr[val - 1] + vueHeader.searchmovekey = (vueHeader.searchmovearr[val - 1]) + ? 'res.' + vueHeader.searchmovearr[val - 1]._id + : 'sug.' + vueHeader.searchmovearr[val - 1] } else { vueHeader.searchmovekey = '' } diff --git a/client/js/helpers/form.js b/client/js/helpers/form.js index d34bf9c8..77bf4099 100644 --- a/client/js/helpers/form.js +++ b/client/js/helpers/form.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ function setInputSelection (input, startPos, endPos) { input.focus() @@ -14,3 +15,5 @@ function setInputSelection (input, startPos, endPos) { range.select() } } + +/* eslint-enable no-unused-vars */ diff --git a/client/js/helpers/pages.js b/client/js/helpers/pages.js index 8e754297..f15c8666 100644 --- a/client/js/helpers/pages.js +++ b/client/js/helpers/pages.js @@ -1,3 +1,5 @@ +/* global _ */ +/* eslint-disable no-unused-vars */ function makeSafePath (rawPath) { let rawParts = _.split(_.trim(rawPath), '/') @@ -7,3 +9,5 @@ function makeSafePath (rawPath) { return _.join(_.filter(rawParts, (r) => { return !_.isEmpty(r) }), '/') } + +/* eslint-enable no-unused-vars */ diff --git a/client/js/login.js b/client/js/login.js index c0a2d34d..3a2bf620 100644 --- a/client/js/login.js +++ b/client/js/login.js @@ -1,5 +1,7 @@ 'use strict' +/* global jQuery */ + jQuery(document).ready(function ($) { $('#login-user').focus() }) diff --git a/client/js/modals/admin-users-create.js b/client/js/modals/admin-users-create.js index 955c749e..dda598f5 100644 --- a/client/js/modals/admin-users-create.js +++ b/client/js/modals/admin-users-create.js @@ -1,3 +1,4 @@ +/* global $, Vue */ // Vue Create User instance diff --git a/client/js/modals/admin-users-delete.js b/client/js/modals/admin-users-delete.js index 8443ba6f..55e034ef 100644 --- a/client/js/modals/admin-users-delete.js +++ b/client/js/modals/admin-users-delete.js @@ -1,3 +1,4 @@ +/* global $, Vue */ // Vue Delete User instance diff --git a/client/js/modals/create.js b/client/js/modals/create.js index 2dd4d4fd..f856869f 100644 --- a/client/js/modals/create.js +++ b/client/js/modals/create.js @@ -1,3 +1,4 @@ +/* global $, _, currentBasePath */ // -> Create New Document @@ -6,7 +7,7 @@ let suggestedCreatePath = currentBasePath + '/new-page' $('.btn-create-prompt').on('click', (ev) => { $('#txt-create-prompt').val(suggestedCreatePath) $('#modal-create-prompt').toggleClass('is-active') - setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length) + setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length) // eslint-disable-line no-undef $('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden') }) @@ -17,7 +18,7 @@ $('#txt-create-prompt').on('keypress', (ev) => { }) $('.btn-create-go').on('click', (ev) => { - let newDocPath = makeSafePath($('#txt-create-prompt').val()) + let newDocPath = makeSafePath($('#txt-create-prompt').val()) // eslint-disable-line no-undef if (_.isEmpty(newDocPath)) { $('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden') } else { diff --git a/client/js/modals/move.js b/client/js/modals/move.js index 48abc568..d8bb51e8 100644 --- a/client/js/modals/move.js +++ b/client/js/modals/move.js @@ -1,3 +1,4 @@ +/* global $, _, alerts, currentBasePath */ // -> Move Existing Document @@ -10,7 +11,7 @@ let moveInitialDocument = _.lastIndexOf(currentBasePath, '/') + 1 $('.btn-move-prompt').on('click', (ev) => { $('#txt-move-prompt').val(currentBasePath) $('#modal-move-prompt').toggleClass('is-active') - setInputSelection($('#txt-move-prompt').get(0), moveInitialDocument, currentBasePath.length) + setInputSelection($('#txt-move-prompt').get(0), moveInitialDocument, currentBasePath.length) // eslint-disable-line no-undef $('#txt-move-prompt').removeClass('is-danger').next().addClass('is-hidden') }) @@ -21,7 +22,7 @@ $('#txt-move-prompt').on('keypress', (ev) => { }) $('.btn-move-go').on('click', (ev) => { - let newDocPath = makeSafePath($('#txt-move-prompt').val()) + let newDocPath = makeSafePath($('#txt-move-prompt').val()) // eslint-disable-line no-undef if (_.isEmpty(newDocPath) || newDocPath === currentBasePath || newDocPath === 'home') { $('#txt-move-prompt').addClass('is-danger').next().removeClass('is-hidden') } else { diff --git a/client/js/pages/admin.js b/client/js/pages/admin.js index a46176a0..b2cf5577 100644 --- a/client/js/pages/admin.js +++ b/client/js/pages/admin.js @@ -1,3 +1,4 @@ +/* global $, Vue, alerts, _, usrData, usrDataName */ if ($('#page-type-admin-profile').length) { let vueProfile = new Vue({ @@ -29,7 +30,9 @@ if ($('#page-type-admin-profile').length) { }) } else if ($('#page-type-admin-users').length) { - // =include ../modals/admin-users-create.js + /* eslint-disable spaced-comment */ + //=include ../modals/admin-users-create.js + /* eslint-enable spaced-comment */ } else if ($('#page-type-admin-users-edit').length) { let vueEditUser = new Vue({ @@ -92,5 +95,7 @@ if ($('#page-type-admin-profile').length) { } }) - // =include ../modals/admin-users-delete.js + /* eslint-disable spaced-comment */ + //=include ../modals/admin-users-delete.js + /* eslint-enable spaced-comment */ } diff --git a/client/js/pages/create.js b/client/js/pages/create.js index 24bc5c93..127ffe51 100644 --- a/client/js/pages/create.js +++ b/client/js/pages/create.js @@ -1,12 +1,15 @@ +/* global $ */ if ($('#page-type-create').length) { - let pageEntryPath = $('#page-type-create').data('entrypath') + let pageEntryPath = $('#page-type-create').data('entrypath') // eslint-disable-line no-unused-vars - // -> Discard + // -> Discard $('.btn-create-discard').on('click', (ev) => { $('#modal-create-discard').toggleClass('is-active') }) - // =include ../components/editor.js + /* eslint-disable spaced-comment */ + //=include ../components/editor.js + /* eslint-enable spaced-comment */ } diff --git a/client/js/pages/edit.js b/client/js/pages/edit.js index e8618f7b..cd48f431 100644 --- a/client/js/pages/edit.js +++ b/client/js/pages/edit.js @@ -1,12 +1,15 @@ +/* global $ */ if ($('#page-type-edit').length) { - let pageEntryPath = $('#page-type-edit').data('entrypath') + let pageEntryPath = $('#page-type-edit').data('entrypath') // eslint-disable-line no-unused-vars - // -> Discard + // -> Discard $('.btn-edit-discard').on('click', (ev) => { $('#modal-edit-discard').toggleClass('is-active') }) - // =include ../components/editor.js + /* eslint-disable spaced-comment */ + //=include ../components/editor.js + /* eslint-enable spaced-comment */ } diff --git a/client/js/pages/source.js b/client/js/pages/source.js index c42c33ec..c3b8a90f 100644 --- a/client/js/pages/source.js +++ b/client/js/pages/source.js @@ -1,3 +1,4 @@ +/* global $, ace */ if ($('#page-type-source').length) { var scEditor = ace.edit('source-display') @@ -9,8 +10,10 @@ if ($('#page-type-source').length) { scEditor.setReadOnly(true) scEditor.renderer.updateFull() - let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : '' + let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : '' // eslint-disable-line no-unused-vars - // =include ../modals/create.js - // =include ../modals/move.js + /* eslint-disable spaced-comment */ + //=include ../modals/create.js + //=include ../modals/move.js + /* eslint-enable spaced-comment */ } diff --git a/client/js/pages/view.js b/client/js/pages/view.js index 4fd21db8..d12cfe0c 100644 --- a/client/js/pages/view.js +++ b/client/js/pages/view.js @@ -1,7 +1,10 @@ +/* global $ */ if ($('#page-type-view').length) { - let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : '' + let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : '' // eslint-disable-line no-unused-vars - // =include ../modals/create.js - // =include ../modals/move.js + /* eslint-disable spaced-comment */ + //=include ../modals/create.js + //=include ../modals/move.js + /* eslint-enable spaced-comment */ } diff --git a/package.json b/package.json index 36a346a8..132ecf8f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "start": "node server", "dev": "gulp dev", - "test": "snyk test && istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec ./tests/index.js && cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage && rm -rf ./coverage", + "test": "snyk test && standard && pug-lint ./views", "snyk-protect": "snyk protect", "__prepublish": "npm run snyk-protect" }, @@ -101,6 +101,9 @@ "chai": "^3.5.0", "chai-as-promised": "^6.0.0", "codacy-coverage": "^2.0.0", + "eslint": "^3.15.0", + "eslint-plugin-promise": "^3.4.1", + "eslint-plugin-standard": "^2.0.1", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-clean-css": "^3.0.0", @@ -123,6 +126,7 @@ "mocha": "^3.2.0", "mocha-lcov-reporter": "^1.2.0", "nodemon": "^1.11.0", + "pug-lint": "^2.4.0", "run-sequence": "^1.2.2", "snyk": "^1.24.6", "sticky-js": "^1.1.9", @@ -130,7 +134,7 @@ "vue": "^2.1.10" }, "standard": { - "globals": [ + "globals": [ "app", "appconfig", "appdata", diff --git a/wiki.sublime-project b/wiki.sublime-project deleted file mode 100644 index 0a644944..00000000 --- a/wiki.sublime-project +++ /dev/null @@ -1,12 +0,0 @@ -{ - "folders": - [ - { - "file_exclude_patterns": - [ - "wiki.sublime-project" - ], - "path": "." - } - ] -}