warning.d.ts
1.89 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import Node from './node.js'
export interface WarningOptions {
/**
* CSS node that caused the warning.
*/
node?: Node
/**
* Word in CSS source that caused the warning.
*/
word?: string
/**
* Index in CSS node string that caused the warning.
*/
index?: number
/**
* Name of the plugin that created this warning. `Result#warn` fills
* this property automatically.
*/
plugin?: string
}
/**
* Represents a plugin’s warning. It can be created using `Node#warn`.
*
* ```js
* if (decl.important) {
* decl.warn(result, 'Avoid !important', { word: '!important' })
* }
* ```
*/
export default class Warning {
/**
* Type to filter warnings from `Result#messages`.
* Always equal to `"warning"`.
*/
type: 'warning'
/**
* The warning message.
*
* ```js
* warning.text //=> 'Try to avoid !important'
* ```
*/
text: string
/**
* The name of the plugin that created this warning.
* When you call `Node#warn` it will fill this property automatically.
*
* ```js
* warning.plugin //=> 'postcss-important'
* ```
*/
plugin: string
/**
* Contains the CSS node that caused the warning.
*
* ```js
* warning.node.toString() //=> 'color: white !important'
* ```
*/
node: Node
/**
* Line in the input file with this warning’s source.
*
* ```js
* warning.line //=> 5
* ```
*/
line: number
/**
* Column in the input file with this warning’s source.
*
* ```js
* warning.column //=> 6
* ```
*/
column: number
/**
* @param text Warning message.
* @param opts Warning options.
*/
constructor(text: string, opts?: WarningOptions)
/**
* Returns a warning position and message.
*
* ```js
* warning.toString() //=> 'postcss-lint:a.css:10:14: Avoid !important'
* ```
*
* @return Warning position and message.
*/
toString(): string
}