lint ALL the things

This commit is contained in:
Amrit Panesar committed 2017-03-23 12:40:29 -07:00
1 parent c0c057b756
commit fe06168084
3 files changed
+46 -41

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" /> <excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/public_html" />
<excludeFolder url="file://$MODULE_DIR$/temp" /> <excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" /> <excludeFolder url="file://$MODULE_DIR$/tmp" />
</content> </content>
+6 -6
View File
@@ -3,14 +3,14 @@
*/ */
// debugging code // debugging code
(function() { (function () {
if (typeof window.debug !== 'object') { if (typeof window.debug !== 'object') {
window.debug = { window.debug = {
log: window.console.log.bind(window.console, '%s'), log: window.console.log.bind(window.console, '%s'),
type: window.console.log.bind(window.console, '%s: %s'), type: window.console.log.bind(window.console, '%s: %s'),
error: window.console.error.bind(window.console, 'error: %s'), error: window.console.error.bind(window.console, 'error: %s'),
info: window.console.info.bind(window.console, 'info: %s'), info: window.console.info.bind(window.console, 'info: %s'),
warn: window.console.warn.bind(window.console, 'warn: %s') warn: window.console.warn.bind(window.console, 'warn: %s')
}; };
} }
})(); })();
+39 -35
View File
@@ -3,14 +3,19 @@
*/ */
// debug shim // debug shim
(function() { (function () {
if (typeof window.debug !== 'object') { if (typeof window.debug !== 'object') {
window.debug = { window.debug = {
log: function() {}, log: function () {
type: function() {}, },
error: function() {}, type: function () {
warn: function() {}, },
info: function() {} error: function () {
},
warn: function () {
},
info: function () {
}
}; };
} }
})(); })();
@@ -52,7 +57,7 @@ var beautify_sql = require('sql-formatter');
* JSON linting! * JSON linting!
* @param json * @param json
*/ */
var jsonLint = function(json) { var jsonLint = function (json) {
if (typeof json !== 'string') { if (typeof json !== 'string') {
return JSON.stringify(json, undefined, 4); return JSON.stringify(json, undefined, 4);
} else { } else {
@@ -70,9 +75,9 @@ var hashShim = {
* @return {{type: string, code: string, hash: string}} * @return {{type: string, code: string, hash: string}}
*/ */
getHash: function (hashIn, separator, doHash) { getHash: function (hashIn, separator, doHash) {
hashIn = typeof hashIn !== 'string' ? hasher.getHash() : hashIn; hashIn = typeof hashIn !== 'string' ? hasher.getHash() : hashIn;
separator = typeof separator !== 'string' ? hasher.separator : separator; separator = typeof separator !== 'string' ? hasher.separator : separator;
doHash = typeof doHash !== 'boolean' ? false : doHash; doHash = typeof doHash !== 'boolean' ? false : doHash;
var out = { var out = {
'type': '', 'type': '',
@@ -106,8 +111,8 @@ var hashShim = {
* @param separator * @param separator
* @returns {boolean} * @returns {boolean}
*/ */
hashTypeCompare: function(one, two, separator) { hashTypeCompare: function (one, two, separator) {
separator = typeof separator !== 'string' ? hasher.separator : separator; separator = typeof separator !== 'string' ? hasher.separator : separator;
var oneS = one.split(separator, 1)[0]; var oneS = one.split(separator, 1)[0];
var twoS = two.split(separator, 1)[0]; var twoS = two.split(separator, 1)[0];
@@ -120,7 +125,7 @@ var hashShim = {
/** /**
* Calls hasher.setHash() * Calls hasher.setHash()
*/ */
setHash: function(path) { setHash: function (path) {
debug.type("setHash() in", arguments); debug.type("setHash() in", arguments);
// arguments[0]; // = type // arguments[0]; // = type
@@ -137,7 +142,7 @@ var hashShim = {
/** /**
* Calls hasher.replaceHash() * Calls hasher.replaceHash()
*/ */
replaceHash: function(path) { replaceHash: function (path) {
debug.type("replaceHash() in", arguments); debug.type("replaceHash() in", arguments);
// arguments[0]; // = type // arguments[0]; // = type
@@ -156,16 +161,15 @@ var hashShim = {
$('window').ready(function () { $('window').ready(function () {
// main I/O // main I/O
var input = $('#input'); var input = $('#input');
var output = $('#output'); var output = $('#output');
/** /**
* hasher page changer function * hasher page changer function
* @param type * @param type
* @param setHash * @param setHash
*/ */
var changeType = function(type, setHash) var changeType = function (type, setHash) {
{
setHash = typeof setHash !== 'boolean' ? true : setHash; setHash = typeof setHash !== 'boolean' ? true : setHash;
debug.type('changeType()', 'setHash: ' + (setHash ? 'true' : 'false')); debug.type('changeType()', 'setHash: ' + (setHash ? 'true' : 'false'));
@@ -185,17 +189,17 @@ $('window').ready(function () {
debug.type('changeType()', 'type: ' + type); debug.type('changeType()', 'type: ' + type);
$('#navbar').find('.active').removeClass('active'); $('#navbar').find('.active').removeClass('active');
var tab = $('#'+type+'_tab'); var tab = $('#' + type + '_tab');
tab.addClass('active'); tab.addClass('active');
if (tab.data('extra-highlight') !== '') { if (tab.data('extra-highlight') !== '') {
$('#'+tab.data('extra-highlight')).addClass('active'); $('#' + tab.data('extra-highlight')).addClass('active');
} }
$('#header').text(tab.data('name')); $('#header').text(tab.data('name'));
if (setHash) { if (setHash) {
debug.type('changeType()', 'Calling hasher.sethash with {'+ type +'} : {'+ hash.code +'}'); debug.type('changeType()', 'Calling hasher.sethash with {' + type + '} : {' + hash.code + '}');
hashShim.setHash(type, hash.code); hashShim.setHash(type, hash.code);
} else { } else {
debug.type('changeType()', 'Not calling hasher.sethash'); debug.type('changeType()', 'Not calling hasher.sethash');
@@ -203,7 +207,7 @@ $('window').ready(function () {
break; break;
default: default:
debug.type('changeType()', 'Default Case: Calling hasher.sethash with {html} : {'+ hash.code +'}'); debug.type('changeType()', 'Default Case: Calling hasher.sethash with {html} : {' + hash.code + '}');
hashShim.setHash('html', hash.code); hashShim.setHash('html', hash.code);
} }
@@ -218,11 +222,11 @@ $('window').ready(function () {
var stringOut = ''; var stringOut = '';
try { try {
switch(type) { switch (type) {
case 'html': case 'html':
htmlLint(code).then(function (lintOutput) { htmlLint(code).then(function (lintOutput) {
debug.log(lintOutput); debug.log(lintOutput);
}, function(e) { }, function (e) {
debug.log(e); debug.log(e);
}).catch(function (e) { }).catch(function (e) {
debug.log(e); debug.log(e);
@@ -264,47 +268,47 @@ $('window').ready(function () {
}; };
// hasher setup (now that the function exists) // hasher setup (now that the function exists)
hasher.changed.add(function(newVal, oldVal) { hasher.changed.add(function (newVal, oldVal) {
debug.type('hasher.changed()', 'Old Val: ' + oldVal + ' New Val: ' + newVal); debug.type('hasher.changed()', 'Old Val: ' + oldVal + ' New Val: ' + newVal);
var hash = hashShim.getHash(); var hash = hashShim.getHash();
var doChangeType = !hashShim.hashTypeCompare(newVal, oldVal); var doChangeType = !hashShim.hashTypeCompare(newVal, oldVal);
changeType(hash.type, doChangeType); changeType(hash.type, doChangeType);
debug.type('hasher.changed()', 'Set input value to {'+ hash.code +'}'); debug.type('hasher.changed()', 'Set input value to {' + hash.code + '}');
input.val(hash.code); input.val(hash.code);
debug.type('hasher.changed()', 'Calling beautify with {'+ hash.type +'} : {'+ hash.code +'}'); debug.type('hasher.changed()', 'Calling beautify with {' + hash.type + '} : {' + hash.code + '}');
beautify(hash.type, hash.code); beautify(hash.type, hash.code);
}); });
hasher.initialized.add(function() { hasher.initialized.add(function () {
debug.type('hasher.initialized()', 'Start'); debug.type('hasher.initialized()', 'Start');
var hash = hashShim.getHash(); var hash = hashShim.getHash();
changeType(hash.type, false); changeType(hash.type, false);
debug.type('hasher.initialized()', 'Set input value to {'+ hash.code +'}'); debug.type('hasher.initialized()', 'Set input value to {' + hash.code + '}');
input.val(hash.code); input.val(hash.code);
debug.type('hasher.initialized()', 'Calling beautify with {'+ hash.type +'} : {'+ hash.code +'}'); debug.type('hasher.initialized()', 'Calling beautify with {' + hash.type + '} : {' + hash.code + '}');
beautify(hash.type, hash.code) beautify(hash.type, hash.code)
}); });
hasher.init(); hasher.init();
// hook into the navbar tabs and use hasher for them // hook into the navbar tabs and use hasher for them
var navbar = $('#navbar'); var navbar = $('#navbar');
navbar.find('>ul>li:not(.dropdown)').click(function(e) { navbar.find('>ul>li:not(.dropdown)').click(function (e) {
e.preventDefault(); e.preventDefault();
changeType(this.id.replace('_tab', '')); changeType(this.id.replace('_tab', ''));
}); });
navbar.find('.dropdown>ul>li').click(function(e) { navbar.find('.dropdown>ul>li').click(function (e) {
e.preventDefault(); e.preventDefault();
changeType(this.id.replace('_tab', '')); changeType(this.id.replace('_tab', ''));
}); });
// function main () // function main ()
input.on('input', function(e) { input.on('input', function (e) {
var hash = hashShim.getHash(); var hash = hashShim.getHash();
var code = e.target.value; var code = e.target.value;