Skip to content

Instantly share code, notes, and snippets.

@cimfalab
cimfalab / javascript-static-analysis-tools.md
Last active November 13, 2017 03:00 — forked from listochkin/javascript-static-analysis-tools.md
JavaScript Static Analysis Tools

JavaScript Static Analysis Tools

Most people are familiar with these three tools:

  1. [JSHint][1]
  2. [JSLint][2]
  3. [Google Closure Linter][3]

The first one is more popular among developers because it is style-agnostic. The other two enforce rules of [Crockford Style][4] and [Google Code Style][5] respectively.

@cimfalab
cimfalab / webPageTestPoller.js
Last active August 12, 2017 07:25
webPageTestPoller.js
WebPageTestPoller.prototype.poll = function() {
WebPageTestPoller.super_.prototype.poll.call(this);
this.debug('WebPageTest start test [target='+this.target+']');
this.wpt.runTest(this.target, config.webPageTest.testOptions | {}, this.onTestStartedCallback.bind(this));
};
@cimfalab
cimfalab / alert.js
Created August 12, 2017 07:03
alert.js
notificationReceived: function(notification, payload, sender) {
if (notification === "SHOW_ALERT") {
if (typeof payload.type === "undefined") { payload.type = "alert"; }
if (payload.type == "alert") {
this.show_alert(payload, sender);
} else if (payload.type = "notification") {
this.show_notification(payload);
}
} else if (notification === "HIDE_ALERT") {
this.hide_alert(sender);
@cimfalab
cimfalab / vb.js
Created August 12, 2017 06:10
vb.js
function dedent(_stream, state) {
state.currentIndent--;
}
function tokenLexer(stream, state) {
...
if (indentInfo === 'dedent') {
if (dedent(stream, state)) {
return ERRORCLASS;
}
@cimfalab
cimfalab / popup.alignment.js
Created August 12, 2017 04:28
popup.alignment.js
_getAlignment: function() {
var ar, align;
if ( this.options.align ) {
ar = this.options.align.split( "," );
}
if ( ar && ar.length > 0 ) {
align = {
x: parseFloat( ar[ 0 ] ),
@cimfalab
cimfalab / HTMLInstrumentation.js
Created August 12, 2017 04:12
HTMLInstrumentation.js
function _getMarkerAtDocumentPos(editor, pos, preferParent, markCache) {
var marks, match;
markCache = markCache || {};
marks = _getSortedTagMarks(editor._codeMirror.findMarksAt(pos), markCache);
if (!marks.length) {
return null;
}
// The mark with the latest start is the innermost one.
@cimfalab
cimfalab / serverValidator.js
Created August 11, 2017 11:29
serverValidator.js
loadRecommendationsSuccess: function(data) {
if (!data) {
console.warn('error while loading default config values');
}
this._saveRecommendedValues(data);
var configObject = data.resources[0].recommendations.blueprint.configurations;
if (configObject) this.updateInitialValue(configObject);
this.set("recommendationsConfigs", Em.get(data.resources[0] , "recommendations.blueprint.configurations"));
},
@cimfalab
cimfalab / markdown.js
Last active August 11, 2017 11:01
markdown.js
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) {
childElement = element.childNodes[i];
...
}
}
@cimfalab
cimfalab / main.js
Created August 11, 2017 10:30
main.js
UrlCodeHints.prototype._getUrlList = function (query) {
...
if (this.cachedHints) {
// use cached hints
unfiltered = this.cachedHints.unfiltered;
} else {
directory = FileSystem.getDirectoryForPath(targetDir);
self = this;
@cimfalab
cimfalab / bulk_operations_controller.js
Last active August 11, 2017 10:15
bulk_operations_controller.js
_getComponentsFromServerForHostComponentsDecommissionCallBack: function (operationData, data) {
...
if (components.length) {
...
if (turn_off) {
// For recommession
if (svcName === "YARN" || svcName === "HBASE" || svcName === "HDFS") {
App.router.get('mainHostDetailsController').doRecommissionAndStart(hostNames, svcName, masterName, slaveName);
}
} else {