From 53e1add23e93c002b9b7d231c4bbf99778e1c4f4 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Wed, 12 Dec 2018 23:21:12 +0100 Subject: [PATCH] =?UTF-8?q?Let=E2=80=99s=20be=20pretty.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/gitlab_service.js | 14 +++++++++----- src/sidebar_tree_item.js | 2 +- src/webview/babel.config.js | 6 ++---- src/webview/postcss.config.js | 6 +++--- src/webview/src/assets/icons.js | 11 +++++++---- src/webview/src/main.js | 10 +++++----- src/webview/vue.config.js | 2 +- src/webview_controller.js | 28 +++++++++++++--------------- 9 files changed, 42 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 8c678f6..a7a8ba3 100644 --- a/package.json +++ b/package.json @@ -229,7 +229,7 @@ "eslint": "eslint --max-warnings 0 --ext .js .", "format": "prettier --write '**/*.{js,json}'", "publish": "vsce publish", - "webview": "cd src/webview && yarn build --watch" + "webview": "cd src/webview ; yarn build --watch" }, "devDependencies": { "@types/mocha": "^5.2.5", diff --git a/src/gitlab_service.js b/src/gitlab_service.js index 46067e5..6f80776 100644 --- a/src/gitlab_service.js +++ b/src/gitlab_service.js @@ -379,9 +379,13 @@ async function fetchDiscussions(issuable) { try { const type = issuable.sha ? 'merge_requests' : 'issues'; - discussions = await fetch(`/projects/${issuable.project_id}/${type}/${issuable.iid}/discussions?sort=asc`); + discussions = await fetch( + `/projects/${issuable.project_id}/${type}/${issuable.iid}/discussions?sort=asc`, + ); } catch (e) { - vscode.window.showInformationMessage('GitLab Workflow: Failed to fetch discussions for this issuable.'); + vscode.window.showInformationMessage( + 'GitLab Workflow: Failed to fetch discussions for this issuable.', + ); } return discussions; @@ -390,7 +394,7 @@ async function fetchDiscussions(issuable) { // TODO: Remove project fetch async function renderMarkdown(markdown) { let rendered = { html: markdown }; - const [ major ] = version.split('.'); + const [major] = version.split('.'); if (parseInt(major, 10) < 11) { return markdown; @@ -403,12 +407,12 @@ async function renderMarkdown(markdown) { project: project.path_with_namespace, gfm: 'true', // Needs to be a string for the API }); - } catch(e) { + } catch (e) { return markdown; } return rendered.html; -}; +} exports.fetchUser = fetchUser; exports.fetchIssuesAssignedToMe = fetchIssuesAssignedToMe; diff --git a/src/sidebar_tree_item.js b/src/sidebar_tree_item.js index e31b39c..c4a1305 100644 --- a/src/sidebar_tree_item.js +++ b/src/sidebar_tree_item.js @@ -8,7 +8,7 @@ class SidebarTreeItem extends vscode.TreeItem { this.command = { command: 'gl.showRichContent', arguments: [data], - } + }; } } } diff --git a/src/webview/babel.config.js b/src/webview/babel.config.js index ba17966..4f45f32 100644 --- a/src/webview/babel.config.js +++ b/src/webview/babel.config.js @@ -1,5 +1,3 @@ module.exports = { - presets: [ - '@vue/app' - ] -} + presets: ['@vue/app'], +}; diff --git a/src/webview/postcss.config.js b/src/webview/postcss.config.js index 961986e..a47ef4f 100644 --- a/src/webview/postcss.config.js +++ b/src/webview/postcss.config.js @@ -1,5 +1,5 @@ module.exports = { plugins: { - autoprefixer: {} - } -} + autoprefixer: {}, + }, +}; diff --git a/src/webview/src/assets/icons.js b/src/webview/src/assets/icons.js index 6221a4b..bd0964b 100644 --- a/src/webview/src/assets/icons.js +++ b/src/webview/src/assets/icons.js @@ -1,5 +1,8 @@ export default { - gitLabLogo: '', - chevronDown:'', - chevronRight: '', -} + gitLabLogo: + '', + chevronDown: + '', + chevronRight: + '', +}; diff --git a/src/webview/src/main.js b/src/webview/src/main.js index fca74cf..77f35b6 100644 --- a/src/webview/src/main.js +++ b/src/webview/src/main.js @@ -1,8 +1,8 @@ -import Vue from 'vue' -import App from './App.vue' +import Vue from 'vue'; +import App from './App.vue'; -Vue.config.productionTip = false +Vue.config.productionTip = false; new Vue({ - render: h => h(App) -}).$mount('#app') + render: h => h(App), +}).$mount('#app'); diff --git a/src/webview/vue.config.js b/src/webview/vue.config.js index df4b4c1..81f1b71 100644 --- a/src/webview/vue.config.js +++ b/src/webview/vue.config.js @@ -1,3 +1,3 @@ module.exports = { filenameHashing: false, -} +}; diff --git a/src/webview_controller.js b/src/webview_controller.js index 408ff7e..b8a2a1c 100644 --- a/src/webview_controller.js +++ b/src/webview_controller.js @@ -5,9 +5,9 @@ const gitLabService = require('./gitlab_service'); let context = null; -const addDeps = (ctx) => { +const addDeps = ctx => { context = ctx; -} +}; const getNonce = () => { let text = ''; @@ -18,7 +18,7 @@ const getNonce = () => { } return text; -} +}; const getResources = () => { const paths = { @@ -26,22 +26,22 @@ const getResources = () => { vendorUri: 'src/webview/dist/js/chunk-vendors.js', styleUri: 'src/webview/dist/css/app.css', devScriptUri: 'src/webview/dist/app.js', - } + }; - Object.keys(paths).forEach((key) => { + Object.keys(paths).forEach(key => { const uri = vscode.Uri.file(path.join(context.extensionPath, paths[key])); paths[key] = uri.with({ scheme: 'vscode-resource' }); }); return paths; -} +}; const getIndexPath = () => { - const isDev = !(fs.existsSync(path.join(context.extensionPath, 'src/webview/dist/js/app.js'))); + const isDev = !fs.existsSync(path.join(context.extensionPath, 'src/webview/dist/js/app.js')); return isDev ? 'src/webview/public/dev.html' : 'src/webview/public/index.html'; -} +}; const replaceResources = () => { const { appScriptUri, vendorUri, styleUri, devScriptUri } = getResources(); @@ -53,18 +53,16 @@ const replaceResources = () => { .replace('{{vendorUri}}', vendorUri) .replace('{{appScriptUri}}', appScriptUri) .replace('{{devScriptUri}}', devScriptUri); -} +}; -const createPanel = (issuable) => { +const createPanel = issuable => { const title = `${issuable.title.slice(0, 20)}...`; return vscode.window.createWebviewPanel('glWorkflow', title, vscode.ViewColumn.One, { enableScripts: true, - localResourceRoots: [ - vscode.Uri.file(path.join(context.extensionPath, 'src')), - ] + localResourceRoots: [vscode.Uri.file(path.join(context.extensionPath, 'src'))], }); -} +}; async function create(issuable) { const panel = createPanel(issuable); @@ -74,7 +72,7 @@ async function create(issuable) { const discussions = await gitLabService.fetchDiscussions(issuable); panel.webview.postMessage({ type: 'issuableFetch', issuable, discussions }); - panel.webview.onDidReceiveMessage(async (message) => { + panel.webview.onDidReceiveMessage(async message => { if (message.command === 'renderMarkdown') { let rendered = await gitLabService.renderMarkdown(message.markdown); rendered = rendered.replace(/ src=".*" alt/gim, ' alt').replace(/" data-src/gim, '" src'); -- GitLab