Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
648 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | class Warning {
|
---|
| 4 | constructor(text, opts = {}) {
|
---|
| 5 | this.type = 'warning'
|
---|
| 6 | this.text = text
|
---|
| 7 |
|
---|
| 8 | if (opts.node && opts.node.source) {
|
---|
| 9 | let pos = opts.node.positionBy(opts)
|
---|
| 10 | this.line = pos.line
|
---|
| 11 | this.column = pos.column
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | for (let opt in opts) this[opt] = opts[opt]
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | toString() {
|
---|
| 18 | if (this.node) {
|
---|
| 19 | return this.node.error(this.text, {
|
---|
| 20 | plugin: this.plugin,
|
---|
| 21 | index: this.index,
|
---|
| 22 | word: this.word
|
---|
| 23 | }).message
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | if (this.plugin) {
|
---|
| 27 | return this.plugin + ': ' + this.text
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | return this.text
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | module.exports = Warning
|
---|
| 35 | Warning.default = Warning
|
---|
Note:
See
TracBrowser
for help on using the repository browser.