From a2a0d25fcb6734ff83b786e7f3b1ff627bb71998 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 22 Jun 2020 14:01:24 -0600 Subject: [PATCH] Lint --- index.js | 24 ++++++------- src/wc-monaco-editor.js | 78 ++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/index.js b/index.js index acf9e5f..4770093 100644 --- a/index.js +++ b/index.js @@ -12,45 +12,45 @@ const monacoDir = new URL('monaco/', import.meta.url); self.MonacoEnvironment = { getWorkerUrl: function (moduleId, label) { if (label === 'json') { - return `${monacoDir}json.worker.js`; + return `${monacoDir}json.worker.js` } if (label === 'css') { - return `${monacoDir}css.worker.js`; + return `${monacoDir}css.worker.js` } if (label === 'html') { - return `${monacoDir}html.worker.js`; + return `${monacoDir}html.worker.js` } if (label === 'typescript' || label === 'javascript') { - return `${monacoDir}ts.worker.js`; + return `${monacoDir}ts.worker.js` } - return `${monacoDir}editor.worker.js`; + return `${monacoDir}editor.worker.js` } }; class WCMonacoEditor extends HTMLElement { static get observedAttributes () { - return ['src', 'value']; + return ['src', 'value'] } attributeChangedCallback (name, oldValue, newValue) { - if (!this.__initialized) { return; } + if (!this.__initialized) { return } if (oldValue !== newValue) { this[name] = newValue; } } - get src () { return this.getAttribute('src'); } + get src () { return this.getAttribute('src') } set src (value) { this.setAttribute('src', value); this.setSrc(); } - get value () { return this.editor.getValue(); } + get value () { return this.editor.getValue() } set value (value) { this.editor.setValue(value); } - get tabSize () { return this.editor.getModel()._options.tabSize; } + get tabSize () { return this.editor.getModel()._options.tabSize } set tabSize (value) { this.editor.getModel().updateOptions({ tabSize: value }); } @@ -102,12 +102,12 @@ class WCMonacoEditor extends HTMLElement { async fetchSrc (src) { const response = await fetch(src); - return response.text(); + return response.text() } async fetchConfig (config) { const response = await fetch(config); - return response.json(); + return response.json() } } diff --git a/src/wc-monaco-editor.js b/src/wc-monaco-editor.js index 88ee5a1..28f66c0 100644 --- a/src/wc-monaco-editor.js +++ b/src/wc-monaco-editor.js @@ -1,70 +1,70 @@ /* eslint no-undef: 0 */ -import '../monaco/editor.main.js'; +import '../monaco/editor.main.js' -const monacoDir = new URL('monaco/', import.meta.url); +const monacoDir = new URL('monaco/', import.meta.url) // eslint-disable-next-line self.MonacoEnvironment = { getWorkerUrl: function (moduleId, label) { if (label === 'json') { - return `${monacoDir}json.worker.js`; + return `${monacoDir}json.worker.js` } if (label === 'css') { - return `${monacoDir}css.worker.js`; + return `${monacoDir}css.worker.js` } if (label === 'html') { - return `${monacoDir}html.worker.js`; + return `${monacoDir}html.worker.js` } if (label === 'typescript' || label === 'javascript') { - return `${monacoDir}ts.worker.js`; + return `${monacoDir}ts.worker.js` } - return `${monacoDir}editor.worker.js`; + return `${monacoDir}editor.worker.js` } -}; +} export class WCMonacoEditor extends HTMLElement { static get observedAttributes () { - return ['src', 'value']; + return ['src', 'value'] } attributeChangedCallback (name, oldValue, newValue) { - if (!this.__initialized) { return; } + if (!this.__initialized) { return } if (oldValue !== newValue) { - this[name] = newValue; + this[name] = newValue } } - get src () { return this.getAttribute('src'); } + get src () { return this.getAttribute('src') } set src (value) { - this.setAttribute('src', value); - this.setSrc(); + this.setAttribute('src', value) + this.setSrc() } - get value () { return this.editor.getValue(); } + get value () { return this.editor.getValue() } set value (value) { - this.editor.setValue(value); + this.editor.setValue(value) } - get tabSize () { return this.editor.getModel()._options.tabSize; } + get tabSize () { return this.editor.getModel()._options.tabSize } set tabSize (value) { - this.editor.getModel().updateOptions({ tabSize: value }); + this.editor.getModel().updateOptions({ tabSize: value }) } constructor () { - super(); - this.__initialized = false; - this.editor = null; + super() + this.__initialized = false + this.editor = null } async connectedCallback () { - this.style.display = 'block'; - if (!this.id) { this.id = 'editor'; } - if (!this.style.width) { this.style.width = '100%'; } - if (!this.style.height) { this.style.height = '100%'; } + this.style.display = 'block' + if (!this.id) { this.id = 'editor' } + if (!this.style.width) { this.style.width = '100%' } + if (!this.style.height) { this.style.height = '100%' } if (this.hasAttribute('config')) { - const config = await this.fetchConfig(this.getAttribute('config')); - this.editor = monaco.editor.create(document.getElementById(this.id), config); + const config = await this.fetchConfig(this.getAttribute('config')) + this.editor = monaco.editor.create(document.getElementById(this.id), config) } else { this.editor = monaco.editor.create(document.getElementById(this.id), { language: this.getAttribute('language'), @@ -76,34 +76,34 @@ export class WCMonacoEditor extends HTMLElement { minimap: { enabled: !this.hasAttribute('no-minimap') }, wordWrap: this.hasAttribute('word-wrap'), wrappingIndent: this.getAttribute('wrap-indent') - }); + }) } if (this.hasAttribute('tab-size')) { - this.tabSize = this.getAttribute('tab-size'); + this.tabSize = this.getAttribute('tab-size') } if (this.hasAttribute('src')) { - this.setSrc(); + this.setSrc() } - this.__initialized = true; + this.__initialized = true } async setSrc () { - const src = this.getAttribute('src'); - const contents = await this.fetchSrc(src); - this.editor.setValue(contents); + const src = this.getAttribute('src') + const contents = await this.fetchSrc(src) + this.editor.setValue(contents) } async fetchSrc (src) { - const response = await fetch(src); - return response.text(); + const response = await fetch(src) + return response.text() } async fetchConfig (config) { - const response = await fetch(config); - return response.json(); + const response = await fetch(config) + return response.json() } } -customElements.define('wc-monaco-editor', WCMonacoEditor); +customElements.define('wc-monaco-editor', WCMonacoEditor)