Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
format () {
const context = this.codeEditor.getValue()
let code = /^http(s)?/.test(context)
? context
: jsBeautify.js_beautify(context, { indent_size: 2 })
this.codeEditor.setValue(code)
},
onChange () {
.map(rule => `{ test: ${rule.test}, use: ${rule.use} }`)
.join(',\n\n')}]
}`
}
if (plugins.length > 0) {
code += `,
plugins: [
${plugins.map(plugin => plugin.init).join(',\n')}
]`
}
code += `};`
code = beautify(code, {
indent_size: 2
})
return hljs.highlight('javascript', code).value
}
lint: (instance) => {
const { reformat } = this;
let { code } = instance;
if (reformat === 'minify') {
code = minify(code);
} else if (reformat === 'beautify_tabs') {
code = beautify.js_beautify(code, {
indent_with_tabs: true
});
} else if (reformat === 'beautify_2') {
code = beautify.js_beautify(code, {
indent_size: 2
});
} else if (reformat === 'beautify_4') {
code = beautify.js_beautify(code, {
indent_size: 4
});
}
instance.set({ code }, {
fromReformat: true
});
},
lintRemoteStart: () => {
js: getJavaScriptEntities(response).map(o => jsBeautify.js_beautify(o, { indent_size: 2 })),
oc: getObjectiveCEntities(response)