Skip to content

Commit

Permalink
refactor: Always sort messages
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 authored and matz3 committed Feb 13, 2025
1 parent 50b42d5 commit 4964fd0
Show file tree
Hide file tree
Showing 11 changed files with 670 additions and 669 deletions.
13 changes: 7 additions & 6 deletions src/linter/LinterContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,18 @@ export default class LinterContext {
}

#getFilteredMessages(resourcePath: ResourcePath): RawLintMessage[] {
const sortFn = (a: RawLintMessage, b: RawLintMessage) => {
const aPos = a.position ?? {line: 0, column: 0};
const bPos = b.position ?? {line: 0, column: 0};
return aPos.line === bPos.line ? aPos.column - bPos.column : aPos.line - bPos.line;
};
const rawMessages = this.#rawMessages.get(resourcePath);
if (!rawMessages) {
return [];
}
const metadata = this.#metadata.get(resourcePath);
if (!metadata?.directives?.size) {
return rawMessages;
return rawMessages.sort(sortFn);
}

const filteredMessages: RawLintMessage[] = [];
Expand All @@ -255,11 +260,7 @@ export default class LinterContext {
return false;
}
return true;
}).sort((a, b) => {
const aPos = a.position!;
const bPos = b.position!;
return aPos.line === bPos.line ? aPos.column - bPos.column : aPos.line - bPos.line;
});
}).sort(sortFn);

// Filter messages based on directives
let directiveStack: Directive[] = [];
Expand Down
Loading

0 comments on commit 4964fd0

Please sign in to comment.