lint plugin

This commit is contained in:
Berkeley Martinez
2015-08-27 11:35:41 -07:00
parent ed9e89b51f
commit ce364b472f

View File

@ -1,6 +1,17 @@
/* eslint-disable no-eval */
/* global importScripts, application */
// executes the given code and handles the result // executes the given code and handles the result
var run = function(code) {
function importScript(url, error) {
try {
importScripts(url);
} catch (e) {
error = e;
}
return error;
}
function run(code) {
var result = { var result = {
input: code, input: code,
output: null, output: null,
@ -18,21 +29,13 @@ var run = function(code) {
application.remote.output(result); application.remote.output(result);
self.close(); self.close();
}; }
// protects even the worker scope from being accessed // protects even the worker scope from being accessed
var runHidden = function(code) { function runHidden(code) {
var importScript = function(url) { /* eslint-disable */
var error = null;
try {
importScripts(url);
} catch (e) {
error = e;
console.log('Unable to load %s!', url);
}
};
var indexedDB = null; var indexedDB = null;
var location = null; var location = null;
var navigator = null; var navigator = null;
@ -55,25 +58,34 @@ var runHidden = function(code) {
var dump = null; var dump = null;
var onoffline = null; var onoffline = null;
var ononline = null; var ononline = null;
importScripts(
"https://cdnjs.cloudflare.com/ajax/libs/ramda/0.13.0/ramda.min.js");
importScripts(
"https://cdnjs.cloudflare.com/ajax/libs/chai/2.2.0/chai.min.js"
)
var expect = chai.expect; var expect = chai.expect;
var assert = chai.assert; var assert = chai.assert;
/* eslint-enable */
var error = null;
error = importScript(
error,
'https://cdnjs.cloudflare.com/ajax/libs/ramda/0.13.0/ramda.min.js'
);
error = importScript(
'https://cdnjs.cloudflare.com/ajax/libs/chai/2.2.0/chai.min.js'
);
if (error) {
return error;
}
return eval(code); return eval(code);
} }
// converts the output into a string // converts the output into a string
var stringify = function(output) { function stringify(output) {
var result; var result;
if (typeof output == 'undefined') { if (typeof output === 'undefined') {
result = 'undefined'; result = 'undefined';
} else if (output === null) { } else if (output === null) {
result = 'null'; result = 'null';
@ -84,5 +96,4 @@ var stringify = function(output) {
return result; return result;
} }
application.setInterface({ run: run });
application.setInterface({run:run});