Use ESLint instead of JSCS
This commit is contained in:
parent
e0b8b4a53f
commit
2f53bf777e
15 changed files with 379 additions and 124 deletions
344
.eslintrc
Normal file
344
.eslintrc
Normal file
|
|
@ -0,0 +1,344 @@
|
||||||
|
{
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 6,
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"experimentalObjectRestSpread": true,
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"node": true,
|
||||||
|
"browser": true,
|
||||||
|
"commonjs": true,
|
||||||
|
"jquery": true,
|
||||||
|
"phantomjs": true,
|
||||||
|
"jasmine": true,
|
||||||
|
"mocha": true,
|
||||||
|
"amd": true,
|
||||||
|
"worker": true,
|
||||||
|
"qunit": true
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"standard",
|
||||||
|
"promise"
|
||||||
|
],
|
||||||
|
"globals": {
|
||||||
|
"document": false,
|
||||||
|
"navigator": false,
|
||||||
|
"window": false
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"accessor-pairs": 2,
|
||||||
|
"arrow-spacing": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"before": true,
|
||||||
|
"after": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"block-spacing": [
|
||||||
|
2,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"brace-style": [
|
||||||
|
2,
|
||||||
|
"1tbs",
|
||||||
|
{
|
||||||
|
"allowSingleLine": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"camelcase": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"properties": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"comma-dangle": [
|
||||||
|
2,
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"comma-spacing": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"before": false,
|
||||||
|
"after": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"comma-style": [
|
||||||
|
2,
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"constructor-super": 2,
|
||||||
|
"curly": [
|
||||||
|
2,
|
||||||
|
"multi-line"
|
||||||
|
],
|
||||||
|
"dot-location": [
|
||||||
|
2,
|
||||||
|
"property"
|
||||||
|
],
|
||||||
|
"eol-last": 2,
|
||||||
|
"eqeqeq": [
|
||||||
|
2,
|
||||||
|
"allow-null"
|
||||||
|
],
|
||||||
|
"generator-star-spacing": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"before": true,
|
||||||
|
"after": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"handle-callback-err": [
|
||||||
|
2,
|
||||||
|
"^(err|error)$"
|
||||||
|
],
|
||||||
|
"indent": [
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"SwitchCase": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"jsx-quotes": [
|
||||||
|
2,
|
||||||
|
"prefer-single"
|
||||||
|
],
|
||||||
|
"key-spacing": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"beforeColon": false,
|
||||||
|
"afterColon": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"keyword-spacing": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"before": true,
|
||||||
|
"after": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"new-cap": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"newIsCap": true,
|
||||||
|
"capIsNew": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"new-parens": 2,
|
||||||
|
"no-array-constructor": 2,
|
||||||
|
"no-caller": 2,
|
||||||
|
"no-class-assign": 2,
|
||||||
|
"no-cond-assign": 2,
|
||||||
|
"no-const-assign": 2,
|
||||||
|
"no-control-regex": 2,
|
||||||
|
"no-debugger": 2,
|
||||||
|
"no-delete-var": 2,
|
||||||
|
"no-dupe-args": 2,
|
||||||
|
"no-dupe-class-members": 2,
|
||||||
|
"no-dupe-keys": 2,
|
||||||
|
"no-duplicate-case": 2,
|
||||||
|
"no-duplicate-imports": 2,
|
||||||
|
"no-empty-character-class": 2,
|
||||||
|
"no-empty-pattern": 2,
|
||||||
|
"no-eval": 2,
|
||||||
|
"no-ex-assign": 2,
|
||||||
|
"no-extend-native": 2,
|
||||||
|
"no-extra-bind": 2,
|
||||||
|
"no-extra-boolean-cast": 2,
|
||||||
|
"no-extra-parens": [
|
||||||
|
2,
|
||||||
|
"functions"
|
||||||
|
],
|
||||||
|
"no-fallthrough": 2,
|
||||||
|
"no-floating-decimal": 2,
|
||||||
|
"no-func-assign": 2,
|
||||||
|
"no-implied-eval": 2,
|
||||||
|
"no-inner-declarations": [
|
||||||
|
2,
|
||||||
|
"functions"
|
||||||
|
],
|
||||||
|
"no-invalid-regexp": 2,
|
||||||
|
"no-irregular-whitespace": 2,
|
||||||
|
"no-iterator": 2,
|
||||||
|
"no-label-var": 2,
|
||||||
|
"no-labels": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"allowLoop": false,
|
||||||
|
"allowSwitch": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-lone-blocks": 2,
|
||||||
|
"no-mixed-spaces-and-tabs": 2,
|
||||||
|
"no-multi-spaces": 2,
|
||||||
|
"no-multi-str": 2,
|
||||||
|
"no-multiple-empty-lines": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"max": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-native-reassign": 2,
|
||||||
|
"no-negated-in-lhs": 2,
|
||||||
|
"no-new": 2,
|
||||||
|
"no-new-func": 2,
|
||||||
|
"no-new-object": 2,
|
||||||
|
"no-new-require": 2,
|
||||||
|
"no-new-symbol": 2,
|
||||||
|
"no-new-wrappers": 2,
|
||||||
|
"no-obj-calls": 2,
|
||||||
|
"no-octal": 2,
|
||||||
|
"no-octal-escape": 2,
|
||||||
|
"no-path-concat": 2,
|
||||||
|
"no-proto": 2,
|
||||||
|
"no-redeclare": 2,
|
||||||
|
"no-regex-spaces": 2,
|
||||||
|
"no-return-assign": [
|
||||||
|
2,
|
||||||
|
"except-parens"
|
||||||
|
],
|
||||||
|
"no-self-assign": 2,
|
||||||
|
"no-self-compare": 2,
|
||||||
|
"no-sequences": 2,
|
||||||
|
"no-shadow-restricted-names": 2,
|
||||||
|
"no-spaced-func": 2,
|
||||||
|
"no-sparse-arrays": 2,
|
||||||
|
"no-this-before-super": 2,
|
||||||
|
"no-throw-literal": 2,
|
||||||
|
"no-trailing-spaces": 2,
|
||||||
|
"no-undef": 2,
|
||||||
|
"no-undef-init": 2,
|
||||||
|
"no-unexpected-multiline": 2,
|
||||||
|
"no-unmodified-loop-condition": 2,
|
||||||
|
"no-unneeded-ternary": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"defaultAssignment": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-unreachable": 2,
|
||||||
|
"no-unsafe-finally": 2,
|
||||||
|
"no-unused-vars": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"vars": "all",
|
||||||
|
"args": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-useless-call": 2,
|
||||||
|
"no-useless-computed-key": 2,
|
||||||
|
"no-useless-constructor": 2,
|
||||||
|
"no-useless-escape": 2,
|
||||||
|
"no-whitespace-before-property": 2,
|
||||||
|
"no-with": 2,
|
||||||
|
"one-var": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"initialized": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"operator-linebreak": [
|
||||||
|
2,
|
||||||
|
"after",
|
||||||
|
{
|
||||||
|
"overrides": {
|
||||||
|
"?": "before",
|
||||||
|
":": "before"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"padded-blocks": [
|
||||||
|
2,
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
2,
|
||||||
|
"single",
|
||||||
|
"avoid-escape"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
2,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"semi-spacing": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"before": false,
|
||||||
|
"after": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"space-before-blocks": [
|
||||||
|
2,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"space-before-function-paren": [
|
||||||
|
2,
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"space-in-parens": [
|
||||||
|
2,
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"space-infix-ops": 2,
|
||||||
|
"space-unary-ops": [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"words": true,
|
||||||
|
"nonwords": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"spaced-comment": [
|
||||||
|
2,
|
||||||
|
"always",
|
||||||
|
{
|
||||||
|
"markers": [
|
||||||
|
"global",
|
||||||
|
"globals",
|
||||||
|
"eslint",
|
||||||
|
"eslint-disable",
|
||||||
|
"*package",
|
||||||
|
"!",
|
||||||
|
","
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"template-curly-spacing": [
|
||||||
|
2,
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"use-isnan": 2,
|
||||||
|
"valid-typeof": 2,
|
||||||
|
"wrap-iife": [
|
||||||
|
2,
|
||||||
|
"any"
|
||||||
|
],
|
||||||
|
"yield-star-spacing": [
|
||||||
|
2,
|
||||||
|
"both"
|
||||||
|
],
|
||||||
|
"yoda": [
|
||||||
|
2,
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"standard/object-curly-even-spacing": [
|
||||||
|
2,
|
||||||
|
"either"
|
||||||
|
],
|
||||||
|
"standard/array-bracket-even-spacing": [
|
||||||
|
2,
|
||||||
|
"either"
|
||||||
|
],
|
||||||
|
"standard/computed-property-even-spacing": [
|
||||||
|
2,
|
||||||
|
"even"
|
||||||
|
],
|
||||||
|
"promise/param-names": 2,
|
||||||
|
"linebreak-style": [
|
||||||
|
2,
|
||||||
|
"unix"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
49
.jscsrc
49
.jscsrc
|
|
@ -1,49 +0,0 @@
|
||||||
{
|
|
||||||
"disallowKeywords": [
|
|
||||||
"with"
|
|
||||||
],
|
|
||||||
"disallowKeywordsOnNewLine": [
|
|
||||||
"else"
|
|
||||||
],
|
|
||||||
"disallowMixedSpacesAndTabs": true,
|
|
||||||
"disallowMultipleVarDecl": {
|
|
||||||
"allExcept": [
|
|
||||||
"undefined"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"disallowNewlineBeforeBlockStatements": true,
|
|
||||||
"disallowSpaceAfterObjectKeys": true,
|
|
||||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
|
||||||
"disallowSpacesInFunction": {
|
|
||||||
"beforeOpeningRoundBrace": true
|
|
||||||
},
|
|
||||||
"disallowSpacesInsideParentheses": true,
|
|
||||||
"disallowTrailingWhitespace": true,
|
|
||||||
"maximumLineLength": 130,
|
|
||||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
|
||||||
"requireCapitalizedConstructors": true,
|
|
||||||
"requireSpaceAfterKeywords": [
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"for",
|
|
||||||
"while",
|
|
||||||
"do",
|
|
||||||
"switch",
|
|
||||||
"case",
|
|
||||||
"return",
|
|
||||||
"try",
|
|
||||||
"catch",
|
|
||||||
"typeof"
|
|
||||||
],
|
|
||||||
"requireSpaceAfterLineComment": true,
|
|
||||||
"requireSpaceAfterBinaryOperators": true,
|
|
||||||
"requireSpaceBeforeBinaryOperators": true,
|
|
||||||
"requireSpaceBeforeBlockStatements": true,
|
|
||||||
"requireSpaceBeforeObjectValues": true,
|
|
||||||
"requireSpacesInFunction": {
|
|
||||||
"beforeOpeningCurlyBrace": true
|
|
||||||
},
|
|
||||||
"requireTrailingComma": null,
|
|
||||||
"validateIndentation": 2,
|
|
||||||
"validateLineBreaks": "LF"
|
|
||||||
}
|
|
||||||
|
|
@ -61,9 +61,11 @@
|
||||||
"browserify": "^13.0.1",
|
"browserify": "^13.0.1",
|
||||||
"clean-css": "^3.4.18",
|
"clean-css": "^3.4.18",
|
||||||
"codacy-coverage": "^1.1.3",
|
"codacy-coverage": "^1.1.3",
|
||||||
|
"eslint": "^3.0.1",
|
||||||
|
"eslint-plugin-promise": "^1.3.2",
|
||||||
|
"eslint-plugin-standard": "^1.3.2",
|
||||||
"fast-html-parser": "^1.0.1",
|
"fast-html-parser": "^1.0.1",
|
||||||
"istanbul": "^0.4.4",
|
"istanbul": "^0.4.4",
|
||||||
"jscs": "^3.0.6",
|
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"mocha": "^2.5.3",
|
"mocha": "^2.5.3",
|
||||||
"nopt": "^3.0.6",
|
"nopt": "^3.0.6",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var utils = require('./utils.js').Utils;
|
var utils = require('./utils.js').Utils;
|
||||||
|
|
||||||
var LINE_TYPE = {
|
var LINE_TYPE = {
|
||||||
|
|
@ -82,17 +81,17 @@
|
||||||
* number of lines is optional, if omited consider 0
|
* number of lines is optional, if omited consider 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line)) {
|
if ((values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line))) {
|
||||||
currentFile.isCombined = false;
|
currentFile.isCombined = false;
|
||||||
oldLine = values[1];
|
oldLine = values[1];
|
||||||
newLine = values[2];
|
newLine = values[2];
|
||||||
} else if (values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line)) {
|
} else if ((values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line))) {
|
||||||
currentFile.isCombined = true;
|
currentFile.isCombined = true;
|
||||||
oldLine = values[1];
|
oldLine = values[1];
|
||||||
oldLine2 = values[2];
|
oldLine2 = values[2];
|
||||||
newLine = values[3];
|
newLine = values[3];
|
||||||
} else {
|
} else {
|
||||||
console.error("Failed to parse lines, starting in 0!");
|
console.error('Failed to parse lines, starting in 0!');
|
||||||
oldLine = 0;
|
oldLine = 0;
|
||||||
newLine = 0;
|
newLine = 0;
|
||||||
currentFile.isCombined = false;
|
currentFile.isCombined = false;
|
||||||
|
|
@ -123,7 +122,6 @@
|
||||||
currentLine.newNumber = newLine++;
|
currentLine.newNumber = newLine++;
|
||||||
|
|
||||||
currentBlock.lines.push(currentLine);
|
currentBlock.lines.push(currentLine);
|
||||||
|
|
||||||
} else if (utils.startsWith(line, delLinePrefixes)) {
|
} else if (utils.startsWith(line, delLinePrefixes)) {
|
||||||
currentFile.deletedLines++;
|
currentFile.deletedLines++;
|
||||||
|
|
||||||
|
|
@ -132,7 +130,6 @@
|
||||||
currentLine.newNumber = null;
|
currentLine.newNumber = null;
|
||||||
|
|
||||||
currentBlock.lines.push(currentLine);
|
currentBlock.lines.push(currentLine);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
currentLine.type = LINE_TYPE.CONTEXT;
|
currentLine.type = LINE_TYPE.CONTEXT;
|
||||||
currentLine.oldNumber = oldLine++;
|
currentLine.oldNumber = oldLine++;
|
||||||
|
|
@ -219,7 +216,6 @@
|
||||||
(utils.startsWith(line, newFileNameHeader) &&
|
(utils.startsWith(line, newFileNameHeader) &&
|
||||||
utils.startsWith(prevLine, oldFileNameHeader) && utils.startsWith(nxtLine, hunkHeaderPrefix))
|
utils.startsWith(prevLine, oldFileNameHeader) && utils.startsWith(nxtLine, hunkHeaderPrefix))
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* --- Date Timestamp[FractionalSeconds] TimeZone
|
* --- Date Timestamp[FractionalSeconds] TimeZone
|
||||||
* --- 2002-02-21 23:30:39.942229878 -0800
|
* --- 2002-02-21 23:30:39.942229878 -0800
|
||||||
|
|
@ -241,7 +237,6 @@
|
||||||
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentFile && utils.startsWith(line, hunkHeaderPrefix)) {
|
if (currentFile && utils.startsWith(line, hunkHeaderPrefix)) {
|
||||||
|
|
@ -325,7 +320,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSrcFilename(line, cfg) {
|
function getSrcFilename(line, cfg) {
|
||||||
var prefixes = ["a/", "i/", "w/", "c/", "o/"];
|
var prefixes = ['a/', 'i/', 'w/', 'c/', 'o/'];
|
||||||
|
|
||||||
if (cfg.srcPrefix) {
|
if (cfg.srcPrefix) {
|
||||||
prefixes.push(cfg.srcPrefix);
|
prefixes.push(cfg.srcPrefix);
|
||||||
|
|
@ -335,7 +330,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDstFilename(line, cfg) {
|
function getDstFilename(line, cfg) {
|
||||||
var prefixes = ["b/", "i/", "w/", "c/", "o/"];
|
var prefixes = ['b/', 'i/', 'w/', 'c/', 'o/'];
|
||||||
|
|
||||||
if (cfg.dstPrefix) {
|
if (cfg.dstPrefix) {
|
||||||
prefixes.push(cfg.dstPrefix);
|
prefixes.push(cfg.dstPrefix);
|
||||||
|
|
@ -365,5 +360,4 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.DiffParser = new DiffParser();
|
module.exports.DiffParser = new DiffParser();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var diffParser = require('./diff-parser.js').DiffParser;
|
var diffParser = require('./diff-parser.js').DiffParser;
|
||||||
var fileLister = require('./file-list-printer.js').FileListPrinter;
|
var fileLister = require('./file-list-printer.js').FileListPrinter;
|
||||||
var htmlPrinter = require('./html-printer.js').HtmlPrinter;
|
var htmlPrinter = require('./html-printer.js').HtmlPrinter;
|
||||||
|
|
@ -57,7 +56,6 @@
|
||||||
return fileList + diffOutput;
|
return fileList + diffOutput;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deprecated methods - The following methods exist only to maintain compatibility with previous versions
|
* Deprecated methods - The following methods exist only to maintain compatibility with previous versions
|
||||||
*/
|
*/
|
||||||
|
|
@ -107,5 +105,4 @@
|
||||||
|
|
||||||
// Expose diff2html in the browser
|
// Expose diff2html in the browser
|
||||||
global.Diff2Html = diffObject;
|
global.Diff2Html = diffObject;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
||||||
|
|
||||||
var hoganUtils = require('./hoganjs-utils.js').HoganJsUtils;
|
var hoganUtils = require('./hoganjs-utils.js').HoganJsUtils;
|
||||||
|
|
@ -40,5 +39,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.FileListPrinter = new FileListPrinter();
|
module.exports.FileListPrinter = new FileListPrinter();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
|
@ -75,5 +74,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.HoganJsUtils = new HoganJsUtils();
|
module.exports.HoganJsUtils = new HoganJsUtils();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var LineByLinePrinter = require('./line-by-line-printer.js').LineByLinePrinter;
|
var LineByLinePrinter = require('./line-by-line-printer.js').LineByLinePrinter;
|
||||||
var SideBySidePrinter = require('./side-by-side-printer.js').SideBySidePrinter;
|
var SideBySidePrinter = require('./side-by-side-printer.js').SideBySidePrinter;
|
||||||
|
|
||||||
|
|
@ -24,5 +23,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.HtmlPrinter = new HtmlPrinter();
|
module.exports.HtmlPrinter = new HtmlPrinter();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var diffParser = require('./diff-parser.js').DiffParser;
|
var diffParser = require('./diff-parser.js').DiffParser;
|
||||||
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
||||||
var utils = require('./utils.js').Utils;
|
var utils = require('./utils.js').Utils;
|
||||||
|
|
@ -79,7 +78,6 @@
|
||||||
LineByLinePrinter.prototype._generateFileHtml = function(file) {
|
LineByLinePrinter.prototype._generateFileHtml = function(file) {
|
||||||
var that = this;
|
var that = this;
|
||||||
return file.blocks.map(function(block) {
|
return file.blocks.map(function(block) {
|
||||||
|
|
||||||
var lines = that.makeColumnLineNumberHtml(block);
|
var lines = that.makeColumnLineNumberHtml(block);
|
||||||
var oldLines = [];
|
var oldLines = [];
|
||||||
var newLines = [];
|
var newLines = [];
|
||||||
|
|
@ -209,5 +207,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.LineByLinePrinter = LineByLinePrinter;
|
module.exports.LineByLinePrinter = LineByLinePrinter;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var jsDiff = require('diff');
|
var jsDiff = require('diff');
|
||||||
var utils = require('./utils.js').Utils;
|
var utils = require('./utils.js').Utils;
|
||||||
var Rematch = require('./rematch.js').Rematch;
|
var Rematch = require('./rematch.js').Rematch;
|
||||||
|
|
@ -85,7 +84,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldFilename + ' → ' + newFilename;
|
return oldFilename + ' → ' + newFilename;
|
||||||
|
|
||||||
} else if (newFilename && !isDevNullName(newFilename)) {
|
} else if (newFilename && !isDevNullName(newFilename)) {
|
||||||
return newFilename;
|
return newFilename;
|
||||||
} else if (oldFilename) {
|
} else if (oldFilename) {
|
||||||
|
|
@ -217,5 +215,4 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.PrinterUtils = new PrinterUtils();
|
module.exports.PrinterUtils = new PrinterUtils();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var Rematch = {};
|
var Rematch = {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -23,10 +22,10 @@
|
||||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
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) {
|
function levenshtein(a, b) {
|
||||||
if (a.length == 0) {
|
if (a.length === 0) {
|
||||||
return b.length;
|
return b.length;
|
||||||
}
|
}
|
||||||
if (b.length == 0) {
|
if (b.length === 0) {
|
||||||
return a.length;
|
return a.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +46,7 @@
|
||||||
// Fill in the rest of the matrix
|
// Fill in the rest of the matrix
|
||||||
for (i = 1; i <= b.length; i++) {
|
for (i = 1; i <= b.length; i++) {
|
||||||
for (j = 1; j <= a.length; j++) {
|
for (j = 1; j <= a.length; j++) {
|
||||||
if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
||||||
matrix[i][j] = matrix[i - 1][j - 1];
|
matrix[i][j] = matrix[i - 1][j - 1];
|
||||||
} else {
|
} else {
|
||||||
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // Substitution
|
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // Substitution
|
||||||
|
|
@ -73,12 +72,6 @@
|
||||||
|
|
||||||
Rematch.rematch = function rematch(distanceFunction) {
|
Rematch.rematch = function rematch(distanceFunction) {
|
||||||
function findBestMatch(a, b, cache) {
|
function findBestMatch(a, b, cache) {
|
||||||
var cachecount = 0;
|
|
||||||
|
|
||||||
for (var key in cache) {
|
|
||||||
cachecount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
var bestMatchDist = Infinity;
|
var bestMatchDist = Infinity;
|
||||||
var bestMatch;
|
var bestMatch;
|
||||||
for (var i = 0; i < a.length; ++i) {
|
for (var i = 0; i < a.length; ++i) {
|
||||||
|
|
@ -102,7 +95,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function group(a, b, level, cache) {
|
function group(a, b, level, cache) {
|
||||||
if (typeof (cache) === "undefined") {
|
if (typeof (cache) === 'undefined') {
|
||||||
cache = {};
|
cache = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,5 +138,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.Rematch = Rematch;
|
module.exports.Rematch = Rematch;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var diffParser = require('./diff-parser.js').DiffParser;
|
var diffParser = require('./diff-parser.js').DiffParser;
|
||||||
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
||||||
var utils = require('./utils.js').Utils;
|
var utils = require('./utils.js').Utils;
|
||||||
|
|
@ -81,7 +80,6 @@
|
||||||
fileHtml.right = '';
|
fileHtml.right = '';
|
||||||
|
|
||||||
file.blocks.forEach(function(block) {
|
file.blocks.forEach(function(block) {
|
||||||
|
|
||||||
fileHtml.left += that.makeSideHtml(block.header);
|
fileHtml.left += that.makeSideHtml(block.header);
|
||||||
fileHtml.right += that.makeSideHtml('');
|
fileHtml.right += that.makeSideHtml('');
|
||||||
|
|
||||||
|
|
@ -244,5 +242,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.SideBySidePrinter = SideBySidePrinter;
|
module.exports.SideBySidePrinter = SideBySidePrinter;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,10 @@
|
||||||
/*global $, hljs, Diff2Html*/
|
/*global $, hljs, Diff2Html*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var highlightJS = require('./highlight.js-internals.js').HighlightJS;
|
var highlightJS = require('./highlight.js-internals.js').HighlightJS;
|
||||||
|
|
||||||
var diffJson = null;
|
var diffJson = null;
|
||||||
var defaultTarget = "body";
|
var defaultTarget = 'body';
|
||||||
var currentSelectionColumnId = -1;
|
var currentSelectionColumnId = -1;
|
||||||
|
|
||||||
function Diff2HtmlUI(config) {
|
function Diff2HtmlUI(config) {
|
||||||
|
|
@ -40,13 +39,11 @@
|
||||||
|
|
||||||
function synchronisedScroll($target, config) {
|
function synchronisedScroll($target, config) {
|
||||||
if (config.synchronisedScroll) {
|
if (config.synchronisedScroll) {
|
||||||
|
$target.find('.d2h-file-side-diff').scroll(function() {
|
||||||
$target.find(".d2h-file-side-diff").scroll(function() {
|
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
$this.closest(".d2h-file-wrapper").find(".d2h-file-side-diff")
|
$this.closest('.d2h-file-wrapper').find('.d2h-file-side-diff')
|
||||||
.scrollLeft($this.scrollLeft());
|
.scrollLeft($this.scrollLeft());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,9 +52,9 @@
|
||||||
|
|
||||||
var hashTag = this._getHashTag();
|
var hashTag = this._getHashTag();
|
||||||
|
|
||||||
var $showBtn = $target.find(".d2h-show");
|
var $showBtn = $target.find('.d2h-show');
|
||||||
var $hideBtn = $target.find(".d2h-hide");
|
var $hideBtn = $target.find('.d2h-hide');
|
||||||
var $fileList = $target.find(".d2h-file-list");
|
var $fileList = $target.find('.d2h-file-list');
|
||||||
|
|
||||||
if (hashTag === 'files-summary-show') show();
|
if (hashTag === 'files-summary-show') show();
|
||||||
else if (hashTag === 'files-summary-hide') hide();
|
else if (hashTag === 'files-summary-hide') hide();
|
||||||
|
|
@ -86,22 +83,22 @@
|
||||||
var $target = that._getTarget(targetId);
|
var $target = that._getTarget(targetId);
|
||||||
|
|
||||||
// collect all the diff files and execute the highlight on their lines
|
// collect all the diff files and execute the highlight on their lines
|
||||||
var $files = $target.find(".d2h-file-wrapper");
|
var $files = $target.find('.d2h-file-wrapper');
|
||||||
$files.map(function(_i, file) {
|
$files.map(function(_i, file) {
|
||||||
var oldLinesState;
|
var oldLinesState;
|
||||||
var newLinesState;
|
var newLinesState;
|
||||||
var $file = $(file);
|
var $file = $(file);
|
||||||
var language = $file.data("lang");
|
var language = $file.data('lang');
|
||||||
|
|
||||||
// collect all the code lines and execute the highlight on them
|
// collect all the code lines and execute the highlight on them
|
||||||
var $codeLines = $file.find(".d2h-code-line-ctn");
|
var $codeLines = $file.find('.d2h-code-line-ctn');
|
||||||
$codeLines.map(function(_j, line) {
|
$codeLines.map(function(_j, line) {
|
||||||
var $line = $(line);
|
var $line = $(line);
|
||||||
var text = line.textContent;
|
var text = line.textContent;
|
||||||
var lineParent = line.parentNode;
|
var lineParent = line.parentNode;
|
||||||
|
|
||||||
var lineState;
|
var lineState;
|
||||||
if (lineParent.className.indexOf("d2h-del") !== -1) {
|
if (lineParent.className.indexOf('d2h-del') !== -1) {
|
||||||
lineState = oldLinesState;
|
lineState = oldLinesState;
|
||||||
} else {
|
} else {
|
||||||
lineState = newLinesState;
|
lineState = newLinesState;
|
||||||
|
|
@ -109,9 +106,9 @@
|
||||||
|
|
||||||
var result = hljs.getLanguage(language) ? hljs.highlight(language, text, true, lineState) : hljs.highlightAuto(text);
|
var result = hljs.getLanguage(language) ? hljs.highlight(language, text, true, lineState) : hljs.highlightAuto(text);
|
||||||
|
|
||||||
if (lineParent.className.indexOf("d2h-del") !== -1) {
|
if (lineParent.className.indexOf('d2h-del') !== -1) {
|
||||||
oldLinesState = result.top;
|
oldLinesState = result.top;
|
||||||
} else if (lineParent.className.indexOf("d2h-ins") !== -1) {
|
} else if (lineParent.className.indexOf('d2h-ins') !== -1) {
|
||||||
newLinesState = result.top;
|
newLinesState = result.top;
|
||||||
} else {
|
} else {
|
||||||
oldLinesState = result.top;
|
oldLinesState = result.top;
|
||||||
|
|
@ -125,7 +122,7 @@
|
||||||
result.value = highlightJS.mergeStreams(originalStream, highlightJS.nodeStream(resultNode), text);
|
result.value = highlightJS.mergeStreams(originalStream, highlightJS.nodeStream(resultNode), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
$line.addClass("hljs");
|
$line.addClass('hljs');
|
||||||
$line.addClass(result.language);
|
$line.addClass(result.language);
|
||||||
$line.html(result.value);
|
$line.html(result.value);
|
||||||
});
|
});
|
||||||
|
|
@ -141,7 +138,7 @@
|
||||||
$target = $(targetId);
|
$target = $(targetId);
|
||||||
} else {
|
} else {
|
||||||
console.error("Wrong target provided! Falling back to default value 'body'.");
|
console.error("Wrong target provided! Falling back to default value 'body'.");
|
||||||
console.log("Please provide a jQuery object or a valid DOM query string.");
|
console.log('Please provide a jQuery object or a valid DOM query string.');
|
||||||
$target = $(defaultTarget);
|
$target = $(defaultTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +190,6 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._getSelectedText = function() {
|
Diff2HtmlUI.prototype._getSelectedText = function() {
|
||||||
var sel = window.getSelection();
|
var sel = window.getSelection();
|
||||||
var range = sel.getRangeAt(0);
|
var range = sel.getRangeAt(0);
|
||||||
|
|
@ -218,5 +214,4 @@
|
||||||
|
|
||||||
// Expose diff2html in the browser
|
// Expose diff2html in the browser
|
||||||
global.Diff2HtmlUI = Diff2HtmlUI;
|
global.Diff2HtmlUI = Diff2HtmlUI;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
function HighlightJS() {
|
function HighlightJS() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,9 +30,9 @@
|
||||||
var result = [];
|
var result = [];
|
||||||
(function _nodeStream(node, offset) {
|
(function _nodeStream(node, offset) {
|
||||||
for (var child = node.firstChild; child; child = child.nextSibling) {
|
for (var child = node.firstChild; child; child = child.nextSibling) {
|
||||||
if (child.nodeType == 3)
|
if (child.nodeType === 3) {
|
||||||
offset += child.nodeValue.length;
|
offset += child.nodeValue.length;
|
||||||
else if (child.nodeType == 1) {
|
} else if (child.nodeType === 1) {
|
||||||
result.push({
|
result.push({
|
||||||
event: 'start',
|
event: 'start',
|
||||||
offset: offset,
|
offset: offset,
|
||||||
|
|
@ -66,7 +65,7 @@
|
||||||
if (!original.length || !highlighted.length) {
|
if (!original.length || !highlighted.length) {
|
||||||
return original.length ? original : highlighted;
|
return original.length ? original : highlighted;
|
||||||
}
|
}
|
||||||
if (original[0].offset != highlighted[0].offset) {
|
if (original[0].offset !== highlighted[0].offset) {
|
||||||
return (original[0].offset < highlighted[0].offset) ? original : highlighted;
|
return (original[0].offset < highlighted[0].offset) ? original : highlighted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +82,7 @@
|
||||||
return highlighted;
|
return highlighted;
|
||||||
... which is collapsed to:
|
... which is collapsed to:
|
||||||
*/
|
*/
|
||||||
return highlighted[0].event == 'start' ? original : highlighted;
|
return highlighted[0].event === 'start' ? original : highlighted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(node) {
|
function open(node) {
|
||||||
|
|
@ -99,15 +98,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function render(event) {
|
function render(event) {
|
||||||
(event.event == 'start' ? open : close)(event.node);
|
(event.event === 'start' ? open : close)(event.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (original.length || highlighted.length) {
|
while (original.length || highlighted.length) {
|
||||||
var stream = selectStream();
|
var stream = selectStream();
|
||||||
result += escape(value.substr(processed, stream[0].offset - processed));
|
result += escape(value.substr(processed, stream[0].offset - processed));
|
||||||
processed = stream[0].offset;
|
processed = stream[0].offset;
|
||||||
if (stream == original) {
|
if (stream === original) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
On any opening or closing tag of the original markup we first close
|
On any opening or closing tag of the original markup we first close
|
||||||
the entire highlighted node stack, then render the original tag along
|
the entire highlighted node stack, then render the original tag along
|
||||||
|
|
@ -118,10 +116,10 @@
|
||||||
do {
|
do {
|
||||||
render(stream.splice(0, 1)[0]);
|
render(stream.splice(0, 1)[0]);
|
||||||
stream = selectStream();
|
stream = selectStream();
|
||||||
} while (stream == original && stream.length && stream[0].offset == processed);
|
} while (stream === original && stream.length && stream[0].offset === processed);
|
||||||
nodeStack.reverse().forEach(open);
|
nodeStack.reverse().forEach(open);
|
||||||
} else {
|
} else {
|
||||||
if (stream[0].event == 'start') {
|
if (stream[0].event === 'start') {
|
||||||
nodeStack.push(stream[0].node);
|
nodeStack.push(stream[0].node);
|
||||||
} else {
|
} else {
|
||||||
nodeStack.pop();
|
nodeStack.pop();
|
||||||
|
|
@ -135,5 +133,4 @@
|
||||||
/* **** Highlight.js Private API **** */
|
/* **** Highlight.js Private API **** */
|
||||||
|
|
||||||
module.exports.HighlightJS = new HighlightJS();
|
module.exports.HighlightJS = new HighlightJS();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
function Utils() {
|
function Utils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,9 +37,8 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Utils.prototype.valueOrEmpty = function(value) {
|
Utils.prototype.valueOrEmpty = function(value) {
|
||||||
return value ? value : '';
|
return value || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.Utils = new Utils();
|
module.exports.Utils = new Utils();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue