main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
739 bytes
|
Rev | Line | |
---|
[d565449] | 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 range = opts.node.rangeBy(opts)
|
---|
| 10 | this.line = range.start.line
|
---|
| 11 | this.column = range.start.column
|
---|
| 12 | this.endLine = range.end.line
|
---|
| 13 | this.endColumn = range.end.column
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | for (let opt in opts) this[opt] = opts[opt]
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | toString() {
|
---|
| 20 | if (this.node) {
|
---|
| 21 | return this.node.error(this.text, {
|
---|
| 22 | index: this.index,
|
---|
| 23 | plugin: this.plugin,
|
---|
| 24 | word: this.word
|
---|
| 25 | }).message
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | if (this.plugin) {
|
---|
| 29 | return this.plugin + ': ' + this.text
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | return this.text
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | module.exports = Warning
|
---|
| 37 | Warning.default = Warning
|
---|
Note:
See
TracBrowser
for help on using the repository browser.