All files / src/plugins/utils messageCarrier.js

100% Statements 11/11
100% Branches 6/6
100% Functions 8/8
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58    55x   2342x                 1x       2659x       2783x       2028x       2028x           1673x 1658x                     9x 6x                  
'use strict';
 
module.exports = class MessageCarrier {
  constructor() {
    this._messages = {
      error: [],
      warning: [],
      info: [],
      hint: []
    };
  }
 
  get messages() {
    return this._messages;
  }
 
  get errors() {
    return this._messages.error;
  }
 
  get warnings() {
    return this._messages.warning;
  }
 
  get infos() {
    return this._messages.info;
  }
 
  get hints() {
    return this._messages.hint;
  }
 
  // status should be 'off', 'error', 'warning', 'info', or 'hint'
  // rule is the name of the configOption, 'builtin' by default
  addMessage(path, message, status, rule = 'builtin') {
    if (this._messages[status]) {
      this._messages[status].push({
        path,
        message,
        rule
      });
    }
  }
 
  // status should be 'off', 'error', 'warning'
  // rule is the name of the configOption, 'builtin' by default
  addMessageWithAuthId(path, message, authId, status, rule = 'builtin') {
    if (this._messages[status]) {
      this._messages[status].push({
        path,
        message,
        authId,
        rule
      });
    }
  }
};