1 | import { RangePosition } from './css-syntax-error.js'
|
---|
2 | import Node from './node.js'
|
---|
3 |
|
---|
4 | declare namespace Warning {
|
---|
5 | export interface WarningOptions {
|
---|
6 | /**
|
---|
7 | * End position, exclusive, in CSS node string that caused the warning.
|
---|
8 | */
|
---|
9 | end?: RangePosition
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * End index, exclusive, in CSS node string that caused the warning.
|
---|
13 | */
|
---|
14 | endIndex?: number
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Start index, inclusive, in CSS node string that caused the warning.
|
---|
18 | */
|
---|
19 | index?: number
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * CSS node that caused the warning.
|
---|
23 | */
|
---|
24 | node?: Node
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Name of the plugin that created this warning. `Result#warn` fills
|
---|
28 | * this property automatically.
|
---|
29 | */
|
---|
30 | plugin?: string
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Start position, inclusive, in CSS node string that caused the warning.
|
---|
34 | */
|
---|
35 | start?: RangePosition
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Word in CSS source that caused the warning.
|
---|
39 | */
|
---|
40 | word?: string
|
---|
41 | }
|
---|
42 |
|
---|
43 | // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
---|
44 | export { Warning_ as default }
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Represents a plugin’s warning. It can be created using `Node#warn`.
|
---|
49 | *
|
---|
50 | * ```js
|
---|
51 | * if (decl.important) {
|
---|
52 | * decl.warn(result, 'Avoid !important', { word: '!important' })
|
---|
53 | * }
|
---|
54 | * ```
|
---|
55 | */
|
---|
56 | declare class Warning_ {
|
---|
57 | /**
|
---|
58 | * Column for inclusive start position in the input file with this warning’s source.
|
---|
59 | *
|
---|
60 | * ```js
|
---|
61 | * warning.column //=> 6
|
---|
62 | * ```
|
---|
63 | */
|
---|
64 | column: number
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Column for exclusive end position in the input file with this warning’s source.
|
---|
68 | *
|
---|
69 | * ```js
|
---|
70 | * warning.endColumn //=> 4
|
---|
71 | * ```
|
---|
72 | */
|
---|
73 | endColumn?: number
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Line for exclusive end position in the input file with this warning’s source.
|
---|
77 | *
|
---|
78 | * ```js
|
---|
79 | * warning.endLine //=> 6
|
---|
80 | * ```
|
---|
81 | */
|
---|
82 | endLine?: number
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Line for inclusive start position in the input file with this warning’s source.
|
---|
86 | *
|
---|
87 | * ```js
|
---|
88 | * warning.line //=> 5
|
---|
89 | * ```
|
---|
90 | */
|
---|
91 | line: number
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Contains the CSS node that caused the warning.
|
---|
95 | *
|
---|
96 | * ```js
|
---|
97 | * warning.node.toString() //=> 'color: white !important'
|
---|
98 | * ```
|
---|
99 | */
|
---|
100 | node: Node
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * The name of the plugin that created this warning.
|
---|
104 | * When you call `Node#warn` it will fill this property automatically.
|
---|
105 | *
|
---|
106 | * ```js
|
---|
107 | * warning.plugin //=> 'postcss-important'
|
---|
108 | * ```
|
---|
109 | */
|
---|
110 | plugin: string
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * The warning message.
|
---|
114 | *
|
---|
115 | * ```js
|
---|
116 | * warning.text //=> 'Try to avoid !important'
|
---|
117 | * ```
|
---|
118 | */
|
---|
119 | text: string
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Type to filter warnings from `Result#messages`.
|
---|
123 | * Always equal to `"warning"`.
|
---|
124 | */
|
---|
125 | type: 'warning'
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * @param text Warning message.
|
---|
129 | * @param opts Warning options.
|
---|
130 | */
|
---|
131 | constructor(text: string, opts?: Warning.WarningOptions)
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Returns a warning position and message.
|
---|
135 | *
|
---|
136 | * ```js
|
---|
137 | * warning.toString() //=> 'postcss-lint:a.css:10:14: Avoid !important'
|
---|
138 | * ```
|
---|
139 | *
|
---|
140 | * @return Warning position and message.
|
---|
141 | */
|
---|
142 | toString(): string
|
---|
143 | }
|
---|
144 |
|
---|
145 | declare class Warning extends Warning_ {}
|
---|
146 |
|
---|
147 | export = Warning
|
---|