Force JSCS style
This commit is contained in:
parent
7244f07e0a
commit
f3d2946aa4
7 changed files with 63 additions and 43 deletions
|
|
@ -6,9 +6,12 @@
|
|||
"else"
|
||||
],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleVarDecl": "exceptUndefined",
|
||||
"disallowMultipleVarDecl": {
|
||||
"allExcept": [
|
||||
"undefined"
|
||||
]
|
||||
},
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowQuotedKeysInObjects": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpacesInFunction": {
|
||||
|
|
@ -16,7 +19,7 @@
|
|||
},
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"maximumLineLength": 120,
|
||||
"maximumLineLength": 130,
|
||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
||||
"requireCapitalizedComments": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
|
|
@ -44,6 +47,5 @@
|
|||
},
|
||||
"requireTrailingComma": null,
|
||||
"validateIndentation": 2,
|
||||
"validateLineBreaks": "LF",
|
||||
"validateQuoteMarks": "'"
|
||||
"validateLineBreaks": "LF"
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
|
||||
FileListPrinter.prototype.generateFileList = function(diffFiles) {
|
||||
var hideId = utils.getRandomId('d2h-hide'); //necessary if there are 2 elements like this in the same page
|
||||
var hideId = utils.getRandomId('d2h-hide'); // Necessary if there are 2 elements like this in the same page
|
||||
var showId = utils.getRandomId('d2h-show');
|
||||
return '<div class="d2h-file-list-wrapper">\n' +
|
||||
' <div class="d2h-file-list-header">Files changed (' + diffFiles.length + ')  </div>\n' +
|
||||
|
|
@ -32,7 +32,8 @@
|
|||
' <td class="d2h-lines-deleted">\n' +
|
||||
' <span>-' + file.deletedLines + '</span>\n' +
|
||||
' </td>\n' +
|
||||
' <td class="d2h-file-name"><a href="#' + printerUtils.getHtmlId(file) + '"> ' + printerUtils.getDiffName(file) + '</a></td>\n' +
|
||||
' <td class="d2h-file-name"><a href="#' + printerUtils.getHtmlId(file) + '">' +
|
||||
' ' + printerUtils.getDiffName(file) + '</a></td>\n' +
|
||||
' </tr>\n';
|
||||
}).join('\n') +
|
||||
'</table></div>\n';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
var i, chr, len;
|
||||
var hash = 0;
|
||||
|
||||
if (text.length === 0) return hash;
|
||||
if (text.length === 0) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
for (i = 0, len = text.length; i < len; i++) {
|
||||
chr = text.charCodeAt(i);
|
||||
|
|
|
|||
|
|
@ -19,23 +19,33 @@
|
|||
|
||||
/*
|
||||
Copyright (c) 2011 Andrei Mackenzie
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
function levenshtein(a, b) {
|
||||
if (a.length == 0) return b.length;
|
||||
if (b.length == 0) return a.length;
|
||||
if (a.length == 0) {
|
||||
return b.length;
|
||||
}
|
||||
if (b.length == 0) {
|
||||
return a.length;
|
||||
}
|
||||
|
||||
var matrix = [];
|
||||
|
||||
// increment along the first column of each row
|
||||
// Increment along the first column of each row
|
||||
var i;
|
||||
for (i = 0; i <= b.length; i++) {
|
||||
matrix[i] = [i];
|
||||
}
|
||||
|
||||
// increment each column in the first row
|
||||
// Increment each column in the first row
|
||||
var j;
|
||||
for (j = 0; j <= a.length; j++) {
|
||||
matrix[0][j] = j;
|
||||
|
|
@ -47,9 +57,9 @@
|
|||
if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
||||
matrix[i][j] = matrix[i - 1][j - 1];
|
||||
} else {
|
||||
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // substitution
|
||||
Math.min(matrix[i][j - 1] + 1, // insertion
|
||||
matrix[i - 1][j] + 1)); // deletion
|
||||
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // Substitution
|
||||
Math.min(matrix[i][j - 1] + 1, // Insertion
|
||||
matrix[i - 1][j] + 1)); // Deletion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,14 +123,14 @@
|
|||
return [[a, b]];
|
||||
}
|
||||
|
||||
var a1 = a.slice(0, bm.indexA),
|
||||
b1 = b.slice(0, bm.indexB),
|
||||
aMatch = [a[bm.indexA]],
|
||||
bMatch = [b[bm.indexB]],
|
||||
tailA = bm.indexA + 1,
|
||||
tailB = bm.indexB + 1,
|
||||
a2 = a.slice(tailA),
|
||||
b2 = b.slice(tailB);
|
||||
var a1 = a.slice(0, bm.indexA);
|
||||
var b1 = b.slice(0, bm.indexB);
|
||||
var aMatch = [a[bm.indexA]];
|
||||
var bMatch = [b[bm.indexB]];
|
||||
var tailA = bm.indexA + 1;
|
||||
var tailB = bm.indexB + 1;
|
||||
var a2 = a.slice(tailA);
|
||||
var b2 = b.slice(tailB);
|
||||
|
||||
var group1 = group(a1, b1, level + 1, cache);
|
||||
var groupMatch = group(aMatch, bMatch, level + 1, cache);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@
|
|||
var utils = require('./utils.js').Utils;
|
||||
var Rematch = require('./rematch.js').Rematch;
|
||||
|
||||
var matcher = Rematch.rematch(function(a, b) {
|
||||
var amod = a.content.substr(1);
|
||||
var bmod = b.content.substr(1);
|
||||
|
||||
return Rematch.distance(amod, bmod);
|
||||
});
|
||||
|
||||
function SideBySidePrinter(config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
|
@ -65,12 +72,6 @@
|
|||
'</div>\n';
|
||||
};
|
||||
|
||||
var matcher = Rematch.rematch(function(a, b) {
|
||||
var amod = a.content.substr(1),
|
||||
bmod = b.content.substr(1);
|
||||
return Rematch.distance(amod, bmod);
|
||||
});
|
||||
|
||||
SideBySidePrinter.prototype.generateSideBySideFileHtml = function(file) {
|
||||
var that = this;
|
||||
var fileHtml = {};
|
||||
|
|
|
|||
|
|
@ -105,15 +105,19 @@ describe('SideBySidePrinter', function() {
|
|||
|
||||
var HTMLParser = require('fast-html-parser');
|
||||
|
||||
var prefixTag = '.d2h-code-line-prefix';
|
||||
|
||||
var parsedExpectedRight = HTMLParser.parse(expectedRight);
|
||||
var parsedFileRight = HTMLParser.parse(fileHtml.right);
|
||||
assert.equal(parsedExpectedRight.querySelectorAll(".d2h-code-line-prefix").length > 0, true);
|
||||
assert.equal(parsedExpectedRight.querySelectorAll(".d2h-code-line-prefix").length, parsedFileRight.querySelectorAll(".d2h-code-line-prefix").length);
|
||||
assert.equal(parsedExpectedRight.querySelectorAll(prefixTag).length > 0, true);
|
||||
assert.equal(parsedExpectedRight.querySelectorAll(prefixTag).length,
|
||||
parsedFileRight.querySelectorAll(prefixTag).length);
|
||||
|
||||
var parsedExpectedLeft = HTMLParser.parse(expectedLeft);
|
||||
var parsedFileLeft = HTMLParser.parse(fileHtml.left);
|
||||
assert.equal(parsedExpectedLeft.querySelectorAll(".d2h-code-line-prefix").length > 0, true);
|
||||
assert.equal(parsedExpectedLeft.querySelectorAll(".d2h-code-line-prefix").length, parsedFileLeft.querySelectorAll(".d2h-code-line-prefix").length);
|
||||
assert.equal(parsedExpectedLeft.querySelectorAll(prefixTag).length > 0, true);
|
||||
assert.equal(parsedExpectedLeft.querySelectorAll(prefixTag).length,
|
||||
parsedFileLeft.querySelectorAll(prefixTag).length);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue