Fix lint errors

Remove commonFramework build from gulpfile
This commit is contained in:
Berkeley Martinez
2016-05-31 15:26:24 -07:00
parent a0efb99ea8
commit 515051d817
11 changed files with 19 additions and 274 deletions

View File

@@ -1,70 +0,0 @@
document.addEventListener('DOMContentLoaded', function() {
var common = parent.__common;
var Rx = parent.Rx;
common.getJsOutput = function evalJs(source = '') {
if (window.__err || !common.shouldRun()) {
return window.__err || 'source disabled';
}
let output;
try {
/* eslint-disable no-eval */
output = eval(source);
/* eslint-enable no-eval */
} catch (e) {
window.__err = e;
}
return output;
};
common.runTests$ = function runTests$({ tests = [], source }) {
const editor = { getValue() { return source; } };
if (window.__err) {
return Rx.Observable.throw(window.__err);
}
// Iterate through the test one at a time
// on new stacks
return Rx.Observable.from(tests, null, null, Rx.Scheduler.default)
// add delay here for firefox to catch up
.delay(100)
.map(({ text, testString }) => {
const newTest = { text, testString };
let test;
try {
/* eslint-disable no-eval */
test = eval(testString);
/* eslint-enable no-eval */
if (typeof test === 'function') {
// maybe sync/promise/observable
if (test.length === 0) {
test();
}
// callback test
if (test.length === 1) {
console.log('callback test');
}
}
} catch (e) {
newTest.err = e.message.split(':').shift();
}
return newTest;
})
// gather tests back into an array
.toArray();
};
// used when updating preview without running tests
common.checkPreview$ = function checkPreview$(args) {
if (window.__err) {
return Rx.Observable.throw(window.__err);
}
return Rx.Observable.just(args);
};
// now that the runPreviewTest$ is defined
// we set the subject to true
// this will let the updatePreview
// script now that we are ready.
common.testFrameReady$.onNext(true);
});

View File

@@ -1,97 +0,0 @@
/* eslint-disable no-eval */
/* global importScripts, application */
// executes the given code and handles the result
function importScript(url, error) {
try {
importScripts(url);
} catch (e) {
error = e;
}
return error;
}
function run(code, cb) {
var err = null;
var result = {};
try {
var codeExec = runHidden(code);
result.type = typeof codeExec;
result.output = stringify(codeExec);
} catch (e) {
err = e.message;
}
if (err) {
cb(err, null);
} else {
cb(null, result);
}
self.close();
}
// protects even the worker scope from being accessed
function runHidden(code) {
/* eslint-disable no-unused-vars */
var indexedDB = null;
var location = null;
var navigator = null;
var onerror = null;
var onmessage = null;
var performance = null;
var self = null;
var webkitIndexedDB = null;
var postMessage = null;
var close = null;
var openDatabase = null;
var openDatabaseSync = null;
var webkitRequestFileSystem = null;
var webkitRequestFileSystemSync = null;
var webkitResolveLocalFileSystemSyncURL = null;
var webkitResolveLocalFileSystemURL = null;
var addEventListener = null;
var dispatchEvent = null;
var removeEventListener = null;
var dump = null;
var onoffline = null;
var ononline = null;
/* eslint-enable no-unused-vars */
var error = null;
error = importScript(
'https://cdnjs.cloudflare.com/ajax/libs/chai/2.2.0/chai.min.js'
);
/* eslint-disable*/
var assert = chai.assert;
/* eslint-enable */
if (error) {
return error;
}
return eval(code);
}
// converts the output into a string
function stringify(output) {
var result;
if (typeof output === 'undefined') {
result = 'undefined';
} else if (output === null) {
result = 'null';
} else {
result = JSON.stringify(output) || output.toString();
}
return result;
}
application.setInterface({ run: run });

View File

@@ -4,6 +4,7 @@ import { ajax$ } from '../../common/utils/ajax-stream';
import throwers from '../rechallenge/throwers';
import transformers from '../rechallenge/transformers';
import types from '../../common/app/routes/challenges/redux/types';
import { createErrorObservable } from '../../common/app/redux/actions';
import {
frameMain,
frameTests,
@@ -43,7 +44,7 @@ function cacheScript({ src } = {}) {
})
.map(({ response }) => response)
.map(script => `<script>${script}</script>`)
.catch(e => (console.error(e), Observable.just('')))
.catch(createErrorObservable)
.shareReplay();
scriptCache.set(src, script$);
@@ -126,9 +127,6 @@ export default function executeChallengeSaga(action$, getState) {
initOutput('// running test') :
null
))
.catch(error => Observable.just({
type: 'app.error',
error
}));
.catch(createErrorObservable);
});
}

View File

@@ -101,9 +101,7 @@ export default function frameSaga(actions$, getState, { window, document }) {
});
return Observable.merge(
proxyLogger$.map(args => {
return updateOutput(args);
}),
proxyLogger$.map(updateOutput),
runTests$.flatMap(() => {
const { frame } = getFrameDocument(document, testId);
const { tests } = getState().challengesApp;