Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working as expected on first line diagnostic.start #190

Merged
merged 2 commits into from
Dec 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/NormalizedMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class NormalizedMessage {
let character: number | undefined;
if (diagnostic.file) {
file = diagnostic.file.fileName;
if (!diagnostic.start) {
if (typeof diagnostic.start === 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be diagnostic.start === undefined instead please? Marginally more performant and my personal preference.

throw new Error('Expected diagnostics to have start');
}
const position = diagnostic.file.getLineAndCharacterOfPosition(
Expand Down Expand Up @@ -92,7 +92,10 @@ export class NormalizedMessage {
return new NormalizedMessage(json);
}

public static compare(messageA: NormalizedMessage, messageB: NormalizedMessage) {
public static compare(
messageA: NormalizedMessage,
messageB: NormalizedMessage
) {
if (!(messageA instanceof NormalizedMessage)) {
return -1;
}
Expand All @@ -102,18 +105,12 @@ export class NormalizedMessage {

return (
NormalizedMessage.compareTypes(messageA.type, messageB.type) ||
NormalizedMessage.compareOptionalStrings(
messageA.file,
messageB.file
) ||
NormalizedMessage.compareOptionalStrings(messageA.file, messageB.file) ||
NormalizedMessage.compareSeverities(
messageA.severity,
messageB.severity
) ||
NormalizedMessage.compareNumbers(
messageA.line,
messageB.line
) ||
NormalizedMessage.compareNumbers(messageA.line, messageB.line) ||
NormalizedMessage.compareNumbers(
messageA.character,
messageB.character
Expand All @@ -131,7 +128,10 @@ export class NormalizedMessage {
);
}

public static equals(messageA: NormalizedMessage, messageB: NormalizedMessage) {
public static equals(
messageA: NormalizedMessage,
messageB: NormalizedMessage
) {
return this.compare(messageA, messageB) === 0;
}

Expand Down