1 | import Input, { FilePosition } from './input.js'
|
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 | export default class CssSyntaxError {
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | constructor (
|
42 | message: string,
|
43 | line?: number,
|
44 | column?: number,
|
45 | source?: string,
|
46 | file?: string,
|
47 | plugin?: string
|
48 | )
|
49 |
|
50 | /**
|
51 | * Always equal to `'CssSyntaxError'`. You should always check error type
|
52 | * by `error.name === 'CssSyntaxError'`
|
53 | * instead of `error instanceof CssSyntaxError`,
|
54 | * because npm could have several PostCSS versions.
|
55 | *
|
56 | * ```js
|
57 | * if (error.name === 'CssSyntaxError') {
|
58 | * error
|
59 | * }
|
60 | * ```
|
61 | */
|
62 | name: 'CssSyntaxError'
|
63 |
|
64 | /**
|
65 | * Error message.
|
66 | *
|
67 | * ```js
|
68 | * error.message
|
69 | * ```
|
70 | */
|
71 | reason: string
|
72 |
|
73 | /**
|
74 | * Full error text in the GNU error format
|
75 | * with plugin, file, line and column.
|
76 | *
|
77 | * ```js
|
78 | * error.message
|
79 | * ```
|
80 | */
|
81 | message: string
|
82 |
|
83 | /**
|
84 | * Absolute path to the broken file.
|
85 | *
|
86 | * ```js
|
87 | * error.file
|
88 | * error.input.file
|
89 | * ```
|
90 | *
|
91 | * PostCSS will use the input source map to detect the original location.
|
92 | * If you need the position in the PostCSS input, use `error.input.file`.
|
93 | */
|
94 | file?: string
|
95 |
|
96 | /**
|
97 | * Source line of the error.
|
98 | *
|
99 | * ```js
|
100 | * error.line
|
101 | * error.input.line
|
102 | * ```
|
103 | *
|
104 | * PostCSS will use the input source map to detect the original location.
|
105 | * If you need the position in the PostCSS input, use `error.input.line`.
|
106 | */
|
107 | line?: number
|
108 |
|
109 | /**
|
110 | * Source column of the error.
|
111 | *
|
112 | * ```js
|
113 | * error.column
|
114 | * error.input.column
|
115 | * ```
|
116 | *
|
117 | * PostCSS will use the input source map to detect the original location.
|
118 | * If you need the position in the PostCSS input, use `error.input.column`.
|
119 | */
|
120 | column?: number
|
121 |
|
122 | /**
|
123 | * Source code of the broken file.
|
124 | *
|
125 | * ```js
|
126 | * error.source
|
127 | * error.input.column
|
128 | * ```
|
129 | */
|
130 | source?: string
|
131 |
|
132 | /**
|
133 | * Plugin name, if error came from plugin.
|
134 | *
|
135 | * ```js
|
136 | * error.plugin
|
137 | * ```
|
138 | */
|
139 | plugin?: string
|
140 |
|
141 | /**
|
142 | * Input object with PostCSS internal information
|
143 | * about input file. If input has source map
|
144 | * from previous tool, PostCSS will use origin
|
145 | * (for example, Sass) source. You can use this
|
146 | * object to get PostCSS input source.
|
147 | *
|
148 | * ```js
|
149 | * error.input.file
|
150 | * error.file
|
151 | * ```
|
152 | */
|
153 | input?: FilePosition
|
154 |
|
155 | /**
|
156 | * Returns error position, message and source code of the broken part.
|
157 | *
|
158 | * ```js
|
159 | * error.toString()
|
160 | *
|
161 | *
|
162 | * ```
|
163 | *
|
164 | * @return Error position, message and source code.
|
165 | */
|
166 | toString (): string
|
167 |
|
168 | /**
|
169 | * Returns a few lines of CSS source that caused the error.
|
170 | *
|
171 | * If the CSS has an input source map without `sourceContent`,
|
172 | * this method will return an empty string.
|
173 | *
|
174 | * ```js
|
175 | * error.showSourceCode()
|
176 | *
|
177 | *
|
178 | *
|
179 | *
|
180 | *
|
181 | * ```
|
182 | *
|
183 | * @param color Whether arrow will be colored red by terminal
|
184 | * color codes. By default, PostCSS will detect
|
185 | * color support by `process.stdout.isTTY`
|
186 | * and `process.env.NODE_DISABLE_COLORS`.
|
187 | * @return Few lines of CSS source that caused the error.
|
188 | */
|
189 | showSourceCode (color?: boolean): string
|
190 | }
|
191 |
|
\ | No newline at end of file |