1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-10-08 18:17:03 +02:00

eslint fixes.

This commit is contained in:
Kushagra Gour
2016-07-15 02:43:44 +05:30
parent fbbc0cf329
commit 6790f9d90e
4 changed files with 44 additions and 95 deletions

View File

@@ -99,7 +99,7 @@
"no-implicit-coercion": "error",
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
@@ -118,7 +118,7 @@
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-nested-ternary": "error",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
@@ -178,9 +178,9 @@
"no-with": "error",
"object-curly-spacing": [
"error",
"never"
"always"
],
"object-property-newline": "error",
"object-property-newline": "off",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "error",
@@ -195,7 +195,7 @@
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-reflect": "error",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "error",
"prefer-template": "off",
@@ -235,7 +235,7 @@
"error",
"never"
],
"valid-jsdoc": "error",
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-regex": "error",
"yield-star-spacing": "error",
@@ -248,6 +248,17 @@
"chrome": true,
"CodeMirror": true,
"Split": true,
"emmetCodeMirror": true
"emmetCodeMirror": true,
"deferred": true,
"$": true,
"$all": true,
"CoffeeScript": true,
"Babel": true,
"Sass": true,
"less": true,
"marked": true,
"jade": true,
"loadJS": true,
"Promise": true
}
}

View File

@@ -1,4 +1,5 @@
function deferred() {
(function() {
window.deferred = function () {
var d = {};
var promise = new Promise(function (resolve, reject) {
d.resolve = resolve;
@@ -7,4 +8,5 @@ function deferred() {
d.promise = promise;
return Object.assign(d, promise);
}
};
})();

View File

@@ -1,75 +1,6 @@
(function(w) {
// https://github.com/filamentgroup/loadCSS/blob/master/src/loadCSS.js
window.loadCSS = function( href, before, media ){
// Arguments explained:
// `href` [REQUIRED] is the URL for your CSS file.
// `before` [OPTIONAL] is the element the script should use as a reference for injecting our stylesheet <link> before
// By default, loadCSS attempts to inject the link after the last stylesheet or script in the DOM. However, you might desire a more specific location in your document.
// `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all'
var doc = w.document;
var ss = doc.createElement( "link" );
var ref;
if( before ){
ref = before;
}
else {
var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes;
ref = refs[ refs.length - 1];
}
var sheets = doc.styleSheets;
ss.rel = "stylesheet";
ss.href = href;
// temporarily set media to something inapplicable to ensure it'll fetch without blocking render
ss.media = "only x";
// wait until body is defined before injecting link. This ensures a non-blocking load in IE11.
function ready( cb ){
if( doc.body ){
return cb();
}
setTimeout(function(){
ready( cb );
});
}
// Inject link
// Note: the ternary preserves the existing behavior of "before" argument, but we could choose to change the argument to "after" in a later release and standardize on ref.nextSibling for all refs
// Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/
ready( function(){
ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
});
// A method (exposed on return object for external use) that mimics onload by polling document.styleSheets until it includes the new sheet.
var onloadcssdefined = function( cb ){
var resolvedHref = ss.href;
var i = sheets.length;
while( i-- ){
if( sheets[ i ].href === resolvedHref ){
return cb();
}
}
setTimeout(function() {
onloadcssdefined( cb );
});
};
function loadCB(){
if( ss.addEventListener ){
ss.removeEventListener( "load", loadCB );
}
ss.media = media || "all";
}
// once loaded, set link's media back to `all` so that the stylesheet applies once it loads
if( ss.addEventListener ){
ss.addEventListener( "load", loadCB);
}
ss.onloadcssdefined = onloadcssdefined;
onloadcssdefined( loadCB );
return true;
};
window.loadJS = function( src, cb ) {
window.loadJS = function(src) {
var d = deferred();
var ref = w.document.getElementsByTagName("script")[0];
var script = w.document.createElement("script");

View File

@@ -41,6 +41,7 @@
, htmlMode = HtmlModes.HTML
, jsMode = JsModes.JS
, cssMode = CssModes.CSS
, sass
, frame = $('#demo-frame')
, htmlCode = $('#js-html-code')
@@ -151,7 +152,7 @@
loadJS('lib/less.min.js').then(setLoadedFlag);
} else if (mode === CssModes.SCSS) {
loadJS('lib/sass.js').then(function () {
window.sass = new Sass('lib/sass.worker.js');
sass = new Sass('lib/sass.worker.js');
setLoadedFlag();
});
} else if (mode === JsModes.COFFEESCRIPT) {
@@ -240,11 +241,11 @@
};
function createPreviewFile(html, css, js) {
html = '<html>\n<head>\n<style>\n' + css + '\n</style>\n</head>\n<body>\n' + html + '\n<script>\n' + js + '\n</script></body>\n</html>';
var contents = '<html>\n<head>\n<style>\n' + css + '\n</style>\n</head>\n<body>\n' + html + '\n<script>\n' + js + '\n</script></body>\n</html>';
var fileWritten = false;
var blob = new Blob([ html ], {type: "text/plain;charset=UTF-8"});
var blob = new Blob([ contents ], { type: "text/plain;charset=UTF-8" });
function errorHandler() { console.log(arguments); }
@@ -372,9 +373,13 @@
html: editur.cm.html.getValue(),
css: editur.cm.css.getValue(),
js: editur.cm.js.getValue(),
/* eslint-disable camelcase */
html_pre_processor: modes[htmlMode].codepenVal,
css_pre_processor: modes[cssMode].codepenVal,
js_pre_processor: modes[jsMode].codepenVal
/* eslint-enable camelcase */
};
json = JSON.stringify(json)
.replace(/"/g, "&quot;")