import { merge } from '../utils/object-utils.js';
import { INFO } from './rule-levels.js';
export default class Rule {
    name;
    level;
    comment;
    constructor(args) {
        if (!args?.name) {
            throw new Error('A rule must at least have a name.');
        }
        const merged = merge(defaults(), args);
        this.name = merged.name;
        this.level = merged.level;
        this.comment = merged.comment;
    }
    compareTo(otherRule) {
        if (!otherRule) {
            throw new Error('A rule has to be passed so as to be compared.');
        }
        if (this.level.priority === otherRule.level.priority) {
            return 0;
        }
        if (this.level.priority > otherRule.level.priority) {
            return 1;
        }
        return -1;
    }
}
function defaults() {
    return {
        level: INFO,
    };
}
