Urara-Blog/node_modules/.pnpm-store/v3/files/13/63a0b8ae24d252e58d61334deb8f7cc05303d8e54adb4be72daa9289b037873278f83326f8843b9c9d8140fb7a572737833ef7df2cfebb031915d4bcdbfbf4
2022-08-14 01:14:53 +08:00

37 lines
739 B
Text

'use strict'
class Warning {
constructor(text, opts = {}) {
this.type = 'warning'
this.text = text
if (opts.node && opts.node.source) {
let range = opts.node.rangeBy(opts)
this.line = range.start.line
this.column = range.start.column
this.endLine = range.end.line
this.endColumn = range.end.column
}
for (let opt in opts) this[opt] = opts[opt]
}
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
}
}
module.exports = Warning
Warning.default = Warning