mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 16:35:14 +00:00
132 lines
8.5 KiB
JavaScript
132 lines
8.5 KiB
JavaScript
"use strict";
|
||
|
||
exports.__esModule = true;
|
||
exports.default = void 0;
|
||
|
||
/**
|
||
* Represents a plugin’s warning. It can be created using {@link Node#warn}.
|
||
*
|
||
* @example
|
||
* if (decl.important) {
|
||
* decl.warn(result, 'Avoid !important', { word: '!important' })
|
||
* }
|
||
*/
|
||
var Warning = /*#__PURE__*/function () {
|
||
/**
|
||
* @param {string} text Warning message.
|
||
* @param {Object} [opts] Warning options.
|
||
* @param {Node} opts.node CSS node that caused the warning.
|
||
* @param {string} opts.word Word in CSS source that caused the warning.
|
||
* @param {number} opts.index Index in CSS node string that caused
|
||
* the warning.
|
||
* @param {string} opts.plugin Name of the plugin that created
|
||
* this warning. {@link Result#warn} fills
|
||
* this property automatically.
|
||
*/
|
||
function Warning(text, opts) {
|
||
if (opts === void 0) {
|
||
opts = {};
|
||
}
|
||
|
||
/**
|
||
* Type to filter warnings from {@link Result#messages}.
|
||
* Always equal to `"warning"`.
|
||
*
|
||
* @type {string}
|
||
*
|
||
* @example
|
||
* const nonWarning = result.messages.filter(i => i.type !== 'warning')
|
||
*/
|
||
this.type = 'warning';
|
||
/**
|
||
* The warning message.
|
||
*
|
||
* @type {string}
|
||
*
|
||
* @example
|
||
* warning.text //=> 'Try to avoid !important'
|
||
*/
|
||
|
||
this.text = text;
|
||
|
||
if (opts.node && opts.node.source) {
|
||
var pos = opts.node.positionBy(opts);
|
||
/**
|
||
* Line in the input file with this warning’s source.
|
||
* @type {number}
|
||
*
|
||
* @example
|
||
* warning.line //=> 5
|
||
*/
|
||
|
||
this.line = pos.line;
|
||
/**
|
||
* Column in the input file with this warning’s source.
|
||
*
|
||
* @type {number}
|
||
*
|
||
* @example
|
||
* warning.column //=> 6
|
||
*/
|
||
|
||
this.column = pos.column;
|
||
}
|
||
|
||
for (var opt in opts) {
|
||
this[opt] = opts[opt];
|
||
}
|
||
}
|
||
/**
|
||
* Returns a warning position and message.
|
||
*
|
||
* @example
|
||
* warning.toString() //=> 'postcss-lint:a.css:10:14: Avoid !important'
|
||
*
|
||
* @return {string} Warning position and message.
|
||
*/
|
||
|
||
|
||
var _proto = Warning.prototype;
|
||
|
||
_proto.toString = function toString() {
|
||
if (this.node) {
|
||
return this.node.error(this.text, {
|
||
plugin: this.plugin,
|
||
index: this.index,
|
||
word: this.word
|
||
}).message;
|
||
}
|
||
|
||
if (this.plugin) {
|
||
return this.plugin + ': ' + this.text;
|
||
}
|
||
|
||
return this.text;
|
||
}
|
||
/**
|
||
* @memberof Warning#
|
||
* @member {string} plugin The name of the plugin that created
|
||
* it will fill this property automatically.
|
||
* this warning. When you call {@link Node#warn}
|
||
*
|
||
* @example
|
||
* warning.plugin //=> 'postcss-important'
|
||
*/
|
||
|
||
/**
|
||
* @memberof Warning#
|
||
* @member {Node} node Contains the CSS node that caused the warning.
|
||
*
|
||
* @example
|
||
* warning.node.toString() //=> 'color: white !important'
|
||
*/
|
||
;
|
||
|
||
return Warning;
|
||
}();
|
||
|
||
var _default = Warning;
|
||
exports.default = _default;
|
||
module.exports = exports.default;
|
||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndhcm5pbmcuZXM2Il0sIm5hbWVzIjpbIldhcm5pbmciLCJ0ZXh0Iiwib3B0cyIsInR5cGUiLCJub2RlIiwic291cmNlIiwicG9zIiwicG9zaXRpb25CeSIsImxpbmUiLCJjb2x1bW4iLCJvcHQiLCJ0b1N0cmluZyIsImVycm9yIiwicGx1Z2luIiwiaW5kZXgiLCJ3b3JkIiwibWVzc2FnZSJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQTs7Ozs7Ozs7SUFRTUEsTztBQUNKOzs7Ozs7Ozs7OztBQVdBLG1CQUFhQyxJQUFiLEVBQW1CQyxJQUFuQixFQUErQjtBQUFBLFFBQVpBLElBQVk7QUF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xuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcyBwcm9wZXJ0eSBhdXRvbWF0aWNhbGx5LlxuICAgKi9cbiAgY29uc3RydWN0b3IgKHRleHQsIG9wdHMgPSB7IH0pIHtcbiAgICAvKipcbiAgICAgKiBUeXBlIHRvIGZpbHRlciB3YXJuaW5ncyBmcm9tIHtAbGluayBSZXN1bHQjbWVzc2FnZXN9LlxuICAgICAqIEFsd2F5cyBlcXVhbCB0byBgXCJ3YXJuaW5nXCJgLlxuICAgICAqXG4gICAgICogQHR5cGUge3N0cmluZ31cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogY29uc3Qgbm9uV2FybmluZyA9IHJlc3VsdC5tZXNzYWdlcy5maWx0ZXIoaSA9PiBpLnR5cGUgIT09ICd3YXJuaW5nJylcbiAgICAgKi9cbiAgICB0aGlzLnR5cGUgPSAnd2FybmluZydcbiAgICAvKipcbiAgICAgKiBUaGUgd2FybmluZyBtZXNzYWdlLlxuICAgICAqXG4gICAgICogQHR5cGUge3N0cmluZ31cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogd2FybmluZy50ZXh0IC8vPT4gJ1RyeSB0byBhdm9pZCAhaW1wb3J0YW50J1xuICAgICAqL1xuICAgIHRoaXMudGV4dCA9IHRleHRcblxuICAgIGlmIChvcHRzLm5vZGUgJiYgb3B0cy5ub2RlLnNvdXJjZSkge1xuICAgICAgbGV0IHBvcyA9IG9wdHMubm9kZS5wb3NpdGlvbkJ5KG9wdHMpXG4gICAgICAvKipcbiAgICAgICAqIExpbmUgaW4gdGhlIGlucHV0IGZpbGUgd2l0aCB0aGlzIHdhcm5pbmfigJlzIHNvdXJjZS5cbiAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgKlxuICAgICAgICogQGV4YW1wbGVcbiAgICAgICAqIHdhcm5pbmcubGluZSAvLz0+IDVcbiAgICAgICAqL1xuICAgICAgdGhpcy5saW5lID0gcG9zLmxpb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