clean: Prepare for pre release

This commit is contained in:
Rodrigo Fernandes 2019-12-22 18:47:20 +00:00
parent 8f1208eb01
commit 4a159277a2
No known key found for this signature in database
GPG key ID: 67157D2E3D4258B4
5 changed files with 3 additions and 22 deletions

View file

@ -23,7 +23,7 @@ function getFilename(line: string, linePrefix?: string, extraPrefix?: string): s
? new RegExp(`^${escapeForRegExp(linePrefix)} "?(.+?)"?$`) ? new RegExp(`^${escapeForRegExp(linePrefix)} "?(.+?)"?$`)
: new RegExp('^"?(.+?)"?$'); : new RegExp('^"?(.+?)"?$');
const [, filename = ""] = FilenameRegExp.exec(line) || []; // TODO: Check if this is safe const [, filename = ""] = FilenameRegExp.exec(line) || [];
const matchingPrefix = prefixes.find(p => filename.indexOf(p) === 0); const matchingPrefix = prefixes.find(p => filename.indexOf(p) === 0);
const fnameWithoutPrefix = matchingPrefix ? filename.slice(matchingPrefix.length) : filename; const fnameWithoutPrefix = matchingPrefix ? filename.slice(matchingPrefix.length) : filename;
@ -132,7 +132,6 @@ export function parse(diffInput: string, config: DiffParserConfig = {}): DiffFil
saveBlock(); saveBlock();
saveFile(); saveFile();
// TODO: Avoid disabling types
// eslint-disable-next-line // eslint-disable-next-line
// @ts-ignore // @ts-ignore
currentFile = { currentFile = {
@ -183,7 +182,6 @@ export function parse(diffInput: string, config: DiffParserConfig = {}): DiffFil
} }
/* Create block metadata */ /* Create block metadata */
// TODO: Avoid disabling types
// eslint-disable-next-line // eslint-disable-next-line
// @ts-ignore // @ts-ignore
currentBlock = { currentBlock = {
@ -198,7 +196,6 @@ export function parse(diffInput: string, config: DiffParserConfig = {}): DiffFil
function createLine(line: string): void { function createLine(line: string): void {
if (currentFile === null || currentBlock === null || oldLine === null || newLine === null) return; if (currentFile === null || currentBlock === null || oldLine === null || newLine === null) return;
// TODO: Avoid disabling types
// eslint-disable-next-line // eslint-disable-next-line
// @ts-ignore // @ts-ignore
const currentLine: DiffLine = { const currentLine: DiffLine = {
@ -208,7 +205,6 @@ export function parse(diffInput: string, config: DiffParserConfig = {}): DiffFil
const addedPrefixes = currentFile.isCombined ? ["+ ", " +", "++"] : ["+"]; const addedPrefixes = currentFile.isCombined ? ["+ ", " +", "++"] : ["+"];
const deletedPrefixes = currentFile.isCombined ? ["- ", " -", "--"] : ["-"]; const deletedPrefixes = currentFile.isCombined ? ["- ", " -", "--"] : ["-"];
// TODO: Check if this makes sense for combined diff
if (startsWithAny(line, addedPrefixes)) { if (startsWithAny(line, addedPrefixes)) {
currentFile.addedLines++; currentFile.addedLines++;
currentLine.type = LineType.INSERT; currentLine.type = LineType.INSERT;

View file

@ -39,10 +39,5 @@ export function html(diffInput: string | DiffFile[], configuration: Diff2HtmlCon
? new SideBySideRenderer(hoganUtils, config).render(diffJson) ? new SideBySideRenderer(hoganUtils, config).render(diffJson)
: new LineByLineRenderer(hoganUtils, config).render(diffJson); : new LineByLineRenderer(hoganUtils, config).render(diffJson);
// TODO: Review error handling
if (diffOutput === undefined) {
throw new Error("OMG we haz no diff. Why???");
}
return fileList + diffOutput; return fileList + diffOutput;
} }

View file

@ -39,7 +39,7 @@ export default class LineByLineRenderer {
this.config = { ...defaultLineByLineRendererConfig, ...config }; this.config = { ...defaultLineByLineRendererConfig, ...config };
} }
render(diffFiles: DiffFile[]): string | undefined { render(diffFiles: DiffFile[]): string {
const diffsHtml = diffFiles const diffsHtml = diffFiles
.map(file => { .map(file => {
let diffs; let diffs;
@ -55,7 +55,6 @@ export default class LineByLineRenderer {
return this.hoganUtils.render(genericTemplatesPath, "wrapper", { content: diffsHtml }); return this.hoganUtils.render(genericTemplatesPath, "wrapper", { content: diffsHtml });
} }
// TODO: Make this private after improving tests
makeFileDiffHtml(file: DiffFile, diffs: string): string { makeFileDiffHtml(file: DiffFile, diffs: string): string {
if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0) return ""; if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0) return "";
@ -80,7 +79,6 @@ export default class LineByLineRenderer {
}); });
} }
// TODO: Make this private after improving tests
generateEmptyDiff(): string { generateEmptyDiff(): string {
return this.hoganUtils.render(genericTemplatesPath, "empty-diff", { return this.hoganUtils.render(genericTemplatesPath, "empty-diff", {
contentClass: "d2h-code-line", contentClass: "d2h-code-line",
@ -192,7 +190,6 @@ export default class LineByLineRenderer {
return matches; return matches;
} }
// TODO: Make this private after improving tests
processChangedLines(isCombined: boolean, oldLines: DiffLine[], newLines: DiffLine[]): FileHtml { processChangedLines(isCombined: boolean, oldLines: DiffLine[], newLines: DiffLine[]): FileHtml {
const fileHtml = { const fileHtml = {
right: "", right: "",
@ -253,7 +250,6 @@ export default class LineByLineRenderer {
return fileHtml; return fileHtml;
} }
// TODO: Make this private after improving tests
generateLineHtml(oldLine?: DiffPreparedLine, newLine?: DiffPreparedLine): FileHtml { generateLineHtml(oldLine?: DiffPreparedLine, newLine?: DiffPreparedLine): FileHtml {
return { return {
left: this.generateSingleLineHtml(oldLine), left: this.generateSingleLineHtml(oldLine),

View file

@ -113,7 +113,6 @@ export function deconstructLine(line: string, isCombined: boolean): DiffLinePart
* returns "my/path/{to → for}/file.js" * returns "my/path/{to → for}/file.js"
*/ */
export function filenameDiff(file: DiffFileName): string { export function filenameDiff(file: DiffFileName): string {
// TODO: Review this huuuuuge piece of code, do we need this?
// TODO: Move unify path to parsing // TODO: Move unify path to parsing
const oldFilename = unifyPath(file.oldName); const oldFilename = unifyPath(file.oldName);
const newFilename = unifyPath(file.newName); const newFilename = unifyPath(file.newName);

View file

@ -39,7 +39,7 @@ export default class SideBySideRenderer {
this.config = { ...defaultSideBySideRendererConfig, ...config }; this.config = { ...defaultSideBySideRendererConfig, ...config };
} }
render(diffFiles: DiffFile[]): string | undefined { render(diffFiles: DiffFile[]): string {
const diffsHtml = diffFiles const diffsHtml = diffFiles
.map(file => { .map(file => {
let diffs; let diffs;
@ -55,7 +55,6 @@ export default class SideBySideRenderer {
return this.hoganUtils.render(genericTemplatesPath, "wrapper", { content: diffsHtml }); return this.hoganUtils.render(genericTemplatesPath, "wrapper", { content: diffsHtml });
} }
// TODO: Make this private after improving tests
makeFileDiffHtml(file: DiffFile, diffs: FileHtml): string { makeFileDiffHtml(file: DiffFile, diffs: FileHtml): string {
if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0) return ""; if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0) return "";
@ -80,7 +79,6 @@ export default class SideBySideRenderer {
}); });
} }
// TODO: Make this private after improving tests
generateEmptyDiff(): FileHtml { generateEmptyDiff(): FileHtml {
return { return {
right: "", right: "",
@ -207,7 +205,6 @@ export default class SideBySideRenderer {
return matches; return matches;
} }
// TODO: Make this private after improving tests
makeHeaderHtml(blockHeader: string): string { makeHeaderHtml(blockHeader: string): string {
return this.hoganUtils.render(genericTemplatesPath, "block-header", { return this.hoganUtils.render(genericTemplatesPath, "block-header", {
CSSLineClass: renderUtils.CSSLineClass, CSSLineClass: renderUtils.CSSLineClass,
@ -217,7 +214,6 @@ export default class SideBySideRenderer {
}); });
} }
// TODO: Make this private after improving tests
processChangedLines(isCombined: boolean, oldLines: DiffLine[], newLines: DiffLine[]): FileHtml { processChangedLines(isCombined: boolean, oldLines: DiffLine[], newLines: DiffLine[]): FileHtml {
const fileHtml = { const fileHtml = {
right: "", right: "",
@ -276,7 +272,6 @@ export default class SideBySideRenderer {
return fileHtml; return fileHtml;
} }
// TODO: Make this private after improving tests
generateLineHtml(oldLine?: DiffPreparedLine, newLine?: DiffPreparedLine): FileHtml { generateLineHtml(oldLine?: DiffPreparedLine, newLine?: DiffPreparedLine): FileHtml {
return { return {
left: this.generateSingleHtml(oldLine), left: this.generateSingleHtml(oldLine),