How to use the @fimbul/ymir.Failure.compare function in @fimbul/ymir

To help you get started, we’ve selected a few @fimbul/ymir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fimbullinter / wotan / packages / mimir / src / formatters / stylish.ts View on Github external
public format(fileName: string, summary: FileSummary): undefined {
        this.fixed += summary.fixes;
        if (summary.failures.length === 0)
            return;
        const mapped: FailureInfo[] = [];
        for (const failure of summary.failures.slice().sort(Failure.compare)) {
            if (failure.fix !== undefined)
                ++this.fixable;
            if (failure.severity.length > this.maxSeverityWidth)
                this.maxSeverityWidth = failure.severity.length;
            if (failure.ruleName.length > this.maxNameWidth)
                this.maxNameWidth = failure.ruleName.length;
            let {character, line} = failure.start;
            if (line !== 0 || character === 0 || !summary.content.startsWith('\uFEFF'))
                character += 1; // avoid incrementing the character position on the first line if BOM is present, editors ignore BOM
            const position = `${line + 1}:${character}`;
            if (position.length > this.maxPositionWidth)
                this.maxPositionWidth = position.length;
            mapped.push({
                position,
                severity: failure.severity,
                ruleName: failure.ruleName,