postcss 8.4.24 → 8.4.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of postcss might be problematic. Click here for more details.

package/lib/node.d.ts CHANGED
@@ -1,34 +1,36 @@
1
- import Declaration, { DeclarationProps } from './declaration.js'
2
- import Comment, { CommentProps } from './comment.js'
3
- import { Stringifier, Syntax } from './postcss.js'
4
1
  import AtRule = require('./at-rule.js')
2
+
5
3
  import { AtRuleProps } from './at-rule.js'
6
- import Rule, { RuleProps } from './rule.js'
7
- import Warning, { WarningOptions } from './warning.js'
4
+ import Comment, { CommentProps } from './comment.js'
5
+ import Container from './container.js'
8
6
  import CssSyntaxError from './css-syntax-error.js'
9
- import Result from './result.js'
7
+ import Declaration, { DeclarationProps } from './declaration.js'
8
+ import Document from './document.js'
10
9
  import Input from './input.js'
10
+ import { Stringifier, Syntax } from './postcss.js'
11
+ import Result from './result.js'
11
12
  import Root from './root.js'
12
- import Document from './document.js'
13
- import Container from './container.js'
13
+ import Rule, { RuleProps } from './rule.js'
14
+ import Warning, { WarningOptions } from './warning.js'
14
15
 
15
16
  declare namespace Node {
16
- export type ChildNode = AtRule.default | Rule | Declaration | Comment
17
+ export type ChildNode = AtRule.default | Comment | Declaration | Rule
17
18
 
18
- export type AnyNode = AtRule.default | Rule | Declaration | Comment | Root | Document
19
+ export type AnyNode =
20
+ | AtRule.default
21
+ | Comment
22
+ | Declaration
23
+ | Document
24
+ | Root
25
+ | Rule
19
26
 
20
27
  export type ChildProps =
21
28
  | AtRuleProps
22
- | RuleProps
23
- | DeclarationProps
24
29
  | CommentProps
30
+ | DeclarationProps
31
+ | RuleProps
25
32
 
26
33
  export interface Position {
27
- /**
28
- * Source offset in file. It starts from 0.
29
- */
30
- offset: number
31
-
32
34
  /**
33
35
  * Source line in file. In contrast to `offset` it starts from 1.
34
36
  */
@@ -38,59 +40,75 @@ declare namespace Node {
38
40
  * Source column in file.
39
41
  */
40
42
  line: number
41
- }
42
43
 
43
- export interface Range {
44
44
  /**
45
- * Start position, inclusive.
45
+ * Source offset in file. It starts from 0.
46
46
  */
47
- start: Position
47
+ offset: number
48
+ }
48
49
 
50
+ export interface Range {
49
51
  /**
50
52
  * End position, exclusive.
51
53
  */
52
54
  end: Position
55
+
56
+ /**
57
+ * Start position, inclusive.
58
+ */
59
+ start: Position
53
60
  }
54
61
 
62
+ /**
63
+ * Source represents an interface for the {@link Node.source} property.
64
+ */
55
65
  export interface Source {
56
66
  /**
57
- * The file source of the node.
67
+ * The inclusive ending position for the source
68
+ * code of a node.
58
69
  */
59
- input: Input
70
+ end?: Position
71
+
60
72
  /**
61
- * The inclusive starting position of the node’s source.
73
+ * The source file from where a node has originated.
62
74
  */
63
- start?: Position
75
+ input: Input
76
+
64
77
  /**
65
- * The inclusive ending position of the node's source.
78
+ * The inclusive starting position for the source
79
+ * code of a node.
66
80
  */
67
- end?: Position
81
+ start?: Position
68
82
  }
69
83
 
84
+ /**
85
+ * Interface represents an interface for an object received
86
+ * as parameter by Node class constructor.
87
+ */
70
88
  export interface NodeProps {
71
89
  source?: Source
72
90
  }
73
91
 
74
92
  export interface NodeErrorOptions {
75
93
  /**
76
- * Plugin name that created this error. PostCSS will set it automatically.
77
- */
78
- plugin?: string
79
- /**
80
- * A word inside a node's string, that should be highlighted as source
81
- * of error.
94
+ * An ending index inside a node's string that should be highlighted as
95
+ * source of error.
82
96
  */
83
- word?: string
97
+ endIndex?: number
84
98
  /**
85
99
  * An index inside a node's string that should be highlighted as source
86
100
  * of error.
87
101
  */
88
102
  index?: number
89
103
  /**
90
- * An ending index inside a node's string that should be highlighted as
91
- * source of error.
104
+ * Plugin name that created this error. PostCSS will set it automatically.
92
105
  */
93
- endIndex?: number
106
+ plugin?: string
107
+ /**
108
+ * A word inside a node's string, that should be highlighted as source
109
+ * of error.
110
+ */
111
+ word?: string
94
112
  }
95
113
 
96
114
  // eslint-disable-next-line @typescript-eslint/no-shadow
@@ -99,200 +117,180 @@ declare namespace Node {
99
117
  }
100
118
 
101
119
  /**
102
- * All node classes inherit the following common methods.
120
+ * It represents an abstract class that handles common
121
+ * methods for other CSS abstract syntax tree nodes.
103
122
  *
104
- * You should not extend this classes to create AST for selector or value
105
- * parser.
123
+ * Any node that represents CSS selector or value should
124
+ * not extend the `Node` class.
106
125
  */
107
126
  declare abstract class Node_ {
108
127
  /**
109
- * tring representing the node’s type. Possible values are `root`, `atrule`,
110
- * `rule`, `decl`, or `comment`.
128
+ * It represents parent of the current node.
111
129
  *
112
130
  * ```js
113
- * new Declaration({ prop: 'color', value: 'black' }).type //=> 'decl'
131
+ * console.log(root.nodes[0].parent === root) //=> true
114
132
  * ```
115
133
  */
116
- type: string
134
+ parent: Container | Document | undefined
117
135
 
118
136
  /**
119
- * The node’s parent node.
137
+ * It represents unnecessary whitespace and characters present
138
+ * in the css source code.
139
+ *
140
+ * Information to generate byte-to-byte equal node string as it was
141
+ * in the origin input.
142
+ *
143
+ * The properties of the raws object are decided by parser,
144
+ * the default parser uses the following properties:
145
+ *
146
+ * * `before`: the space symbols before the node. It also stores `*`
147
+ * and `_` symbols before the declaration (IE hack).
148
+ * * `after`: the space symbols after the last child of the node
149
+ * to the end of the node.
150
+ * * `between`: the symbols between the property and value
151
+ * for declarations, selector and `{` for rules, or last parameter
152
+ * and `{` for at-rules.
153
+ * * `semicolon`: contains true if the last child has
154
+ * an (optional) semicolon.
155
+ * * `afterName`: the space between the at-rule name and its parameters.
156
+ * * `left`: the space symbols between `/*` and the comment’s text.
157
+ * * `right`: the space symbols between the comment’s text
158
+ * and <code>*&#47;</code>.
159
+ * - `important`: the content of the important statement,
160
+ * if it is not just `!important`.
161
+ *
162
+ * PostCSS filters out the comments inside selectors, declaration values
163
+ * and at-rule parameters but it stores the origin content in raws.
120
164
  *
121
165
  * ```js
122
- * root.nodes[0].parent === root
166
+ * const root = postcss.parse('a {\n color:black\n}')
167
+ * console.log(root.first.first.raws) //=> { before: '\n ', between: ':' }
123
168
  * ```
124
169
  */
125
- parent: Document | Container | undefined
170
+ raws: any
126
171
 
127
172
  /**
128
- * The input source of the node.
173
+ * It represents information related to origin of a node and is required
174
+ * for generating source maps.
129
175
  *
130
- * The property is used in source map generation.
176
+ * The nodes that are created manually using the public APIs
177
+ * provided by PostCSS will have `source` undefined and
178
+ * will be absent in the source map.
131
179
  *
132
- * If you create a node manually (e.g., with `postcss.decl()`),
133
- * that node will not have a `source` property and will be absent
134
- * from the source map. For this reason, the plugin developer should
135
- * consider cloning nodes to create new ones (in which case the new node’s
136
- * source will reference the original, cloned node) or setting
137
- * the `source` property manually.
180
+ * For this reason, the plugin developer should consider
181
+ * duplicating nodes as the duplicate node will have the
182
+ * same source as the original node by default or assign
183
+ * source to a node created manually.
138
184
  *
139
185
  * ```js
140
- * decl.source.input.from //=> '/home/ai/a.sass'
141
- * decl.source.start //=> { line: 10, column: 2 }
142
- * decl.source.end //=> { line: 10, column: 12 }
186
+ * console.log(decl.source.input.from) //=> '/home/ai/source.css'
187
+ * console.log(decl.source.start) //=> { line: 10, column: 2 }
188
+ * console.log(decl.source.end) //=> { line: 10, column: 12 }
143
189
  * ```
144
190
  *
145
191
  * ```js
146
- * // Bad
192
+ * // Incorrect method, source not specified!
147
193
  * const prefixed = postcss.decl({
148
194
  * prop: '-moz-' + decl.prop,
149
195
  * value: decl.value
150
196
  * })
151
197
  *
152
- * // Good
153
- * const prefixed = decl.clone({ prop: '-moz-' + decl.prop })
198
+ * // Correct method, source is inherited when duplicating.
199
+ * const prefixed = decl.clone({
200
+ * prop: '-moz-' + decl.prop
201
+ * })
154
202
  * ```
155
203
  *
156
204
  * ```js
157
205
  * if (atrule.name === 'add-link') {
158
- * const rule = postcss.rule({ selector: 'a', source: atrule.source })
159
- * atrule.parent.insertBefore(atrule, rule)
206
+ * const rule = postcss.rule({
207
+ * selector: 'a',
208
+ * source: atrule.source
209
+ * })
210
+ *
211
+ * atrule.parent.insertBefore(atrule, rule)
160
212
  * }
161
213
  * ```
162
214
  */
163
215
  source?: Node.Source
164
216
 
165
217
  /**
166
- * Information to generate byte-to-byte equal node string as it was
167
- * in the origin input.
218
+ * It represents type of a node in
219
+ * an abstract syntax tree.
168
220
  *
169
- * Every parser saves its own properties,
170
- * but the default CSS parser uses:
171
- *
172
- * * `before`: the space symbols before the node. It also stores `*`
173
- * and `_` symbols before the declaration (IE hack).
174
- * * `after`: the space symbols after the last child of the node
175
- * to the end of the node.
176
- * * `between`: the symbols between the property and value
177
- * for declarations, selector and `{` for rules, or last parameter
178
- * and `{` for at-rules.
179
- * * `semicolon`: contains true if the last child has
180
- * an (optional) semicolon.
181
- * * `afterName`: the space between the at-rule name and its parameters.
182
- * * `left`: the space symbols between `/*` and the comment’s text.
183
- * * `right`: the space symbols between the comment’s text
184
- * and <code>*&#47;</code>.
185
- * * `important`: the content of the important statement,
186
- * if it is not just `!important`.
187
- *
188
- * PostCSS cleans selectors, declaration values and at-rule parameters
189
- * from comments and extra spaces, but it stores origin content in raws
190
- * properties. As such, if you don’t change a declaration’s value,
191
- * PostCSS will use the raw value with comments.
221
+ * A type of node helps in identification of a node
222
+ * and perform operation based on it's type.
192
223
  *
193
224
  * ```js
194
- * const root = postcss.parse('a {\n color:black\n}')
195
- * root.first.first.raws //=> { before: '\n ', between: ':' }
225
+ * const declaration = new Declaration({
226
+ * prop: 'color',
227
+ * value: 'black'
228
+ * })
229
+ *
230
+ * console.log(declaration.type) //=> 'decl'
196
231
  * ```
197
232
  */
198
- raws: any
233
+ type: string
199
234
 
200
- /**
201
- * @param defaults Value for node properties.
202
- */
203
235
  constructor(defaults?: object)
204
236
 
205
237
  /**
206
- * Returns a `CssSyntaxError` instance containing the original position
207
- * of the node in the source, showing line and column numbers and also
208
- * a small excerpt to facilitate debugging.
209
- *
210
- * If present, an input source map will be used to get the original position
211
- * of the source, even from a previous compilation step
212
- * (e.g., from Sass compilation).
238
+ * Insert new node after current node to current node’s parent.
213
239
  *
214
- * This method produces very useful error messages.
240
+ * Just alias for `node.parent.insertAfter(node, add)`.
215
241
  *
216
242
  * ```js
217
- * if (!variables[name]) {
218
- * throw decl.error(`Unknown variable ${name}`, { word: name })
219
- * // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
220
- * // color: $black
221
- * // a
222
- * // ^
223
- * // background: white
224
- * }
243
+ * decl.after('color: black')
225
244
  * ```
226
245
  *
227
- * @param message Error description.
228
- * @param opts Options.
229
- *
230
- * @return Error object to throw it.
246
+ * @param newNode New node.
247
+ * @return This node for methods chain.
231
248
  */
232
- error(message: string, options?: Node.NodeErrorOptions): CssSyntaxError
249
+ after(newNode: Node | Node.ChildProps | Node[] | string): this
233
250
 
234
251
  /**
235
- * This method is provided as a convenience wrapper for `Result#warn`.
252
+ * It assigns properties to an existing node instance.
236
253
  *
237
254
  * ```js
238
- * Declaration: {
239
- * bad: (decl, { result }) => {
240
- * decl.warn(result, 'Deprecated property bad')
241
- * }
242
- * }
255
+ * decl.assign({ prop: 'word-wrap', value: 'break-word' })
243
256
  * ```
244
257
  *
245
- * @param result The `Result` instance that will receive the warning.
246
- * @param text Warning message.
247
- * @param opts Warning Options.
258
+ * @param overrides New properties to override the node.
248
259
  *
249
- * @return Created warning object.
260
+ * @return `this` for method chaining.
250
261
  */
251
- warn(result: Result, text: string, opts?: WarningOptions): Warning
262
+ assign(overrides: object): this
252
263
 
253
264
  /**
254
- * Removes the node from its parent and cleans the parent properties
255
- * from the node and its children.
256
- *
257
- * ```js
258
- * if (decl.prop.match(/^-webkit-/)) {
259
- * decl.remove()
260
- * }
261
- * ```
265
+ * Insert new node before current node to current node’s parent.
262
266
  *
263
- * @return Node to make calls chain.
264
- */
265
- remove(): this
266
-
267
- /**
268
- * Returns a CSS string representing the node.
267
+ * Just alias for `node.parent.insertBefore(node, add)`.
269
268
  *
270
269
  * ```js
271
- * new Rule({ selector: 'a' }).toString() //=> "a {}"
270
+ * decl.before('content: ""')
272
271
  * ```
273
272
  *
274
- * @param stringifier A syntax to use in string generation.
275
- * @return CSS string of this node.
273
+ * @param newNode New node.
274
+ * @return This node for methods chain.
276
275
  */
277
- toString(stringifier?: Stringifier | Syntax): string
276
+ before(newNode: Node | Node.ChildProps | Node[] | string): this
278
277
 
279
278
  /**
280
- * Assigns properties to the current node.
279
+ * Clear the code style properties for the node and its children.
281
280
  *
282
281
  * ```js
283
- * decl.assign({ prop: 'word-wrap', value: 'break-word' })
282
+ * node.raws.before //=> ' '
283
+ * node.cleanRaws()
284
+ * node.raws.before //=> undefined
284
285
  * ```
285
286
  *
286
- * @param overrides New properties to override the node.
287
- * @return Current node to methods chain.
287
+ * @param keepBetween Keep the `raws.between` symbols.
288
288
  */
289
- assign(overrides: object): this
289
+ cleanRaws(keepBetween?: boolean): void
290
290
 
291
291
  /**
292
- * Returns an exact clone of the node.
293
- *
294
- * The resulting cloned node and its (cloned) children will retain
295
- * code style properties.
292
+ * It creates clone of an existing node, which includes all the properties
293
+ * and their values, that includes `raws` but not `type`.
296
294
  *
297
295
  * ```js
298
296
  * decl.raws.before //=> "\n "
@@ -302,9 +300,19 @@ declare abstract class Node_ {
302
300
  * ```
303
301
  *
304
302
  * @param overrides New properties to override in the clone.
305
- * @return Clone of the node.
303
+ *
304
+ * @return Duplicate of the node instance.
306
305
  */
307
- clone(overrides?: object): this
306
+ clone(overrides?: object): Node_
307
+
308
+ /**
309
+ * Shortcut to clone the node and insert the resulting cloned node
310
+ * after the current node.
311
+ *
312
+ * @param overrides New properties to override in the clone.
313
+ * @return New node.
314
+ */
315
+ cloneAfter(overrides?: object): this
308
316
 
309
317
  /**
310
318
  * Shortcut to clone the node and insert the resulting cloned node
@@ -321,31 +329,40 @@ declare abstract class Node_ {
321
329
  cloneBefore(overrides?: object): this
322
330
 
323
331
  /**
324
- * Shortcut to clone the node and insert the resulting cloned node
325
- * after the current node.
332
+ * It creates an instance of the class `CssSyntaxError` and parameters passed
333
+ * to this method are assigned to the error instance.
326
334
  *
327
- * @param overrides New properties to override in the clone.
328
- * @return New node.
329
- */
330
- cloneAfter(overrides?: object): this
331
-
332
- /**
333
- * Inserts node(s) before the current node and removes the current node.
335
+ * The error instance will have description for the
336
+ * error, original position of the node in the
337
+ * source, showing line and column number.
338
+ *
339
+ * If any previous map is present, it would be used
340
+ * to get original position of the source.
341
+ *
342
+ * The Previous Map here is referred to the source map
343
+ * generated by previous compilation, example: Less,
344
+ * Stylus and Sass.
345
+ *
346
+ * This method returns the error instance instead of
347
+ * throwing it.
334
348
  *
335
349
  * ```js
336
- * AtRule: {
337
- * mixin: atrule => {
338
- * atrule.replaceWith(mixinRules[atrule.params])
339
- * }
350
+ * if (!variables[name]) {
351
+ * throw decl.error(`Unknown variable ${name}`, { word: name })
352
+ * // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
353
+ * // color: $black
354
+ * // a
355
+ * // ^
356
+ * // background: white
340
357
  * }
341
358
  * ```
342
359
  *
343
- * @param nodes Mode(s) to replace current one.
344
- * @return Current node to methods chain.
360
+ * @param message Description for the error instance.
361
+ * @param options Options for the error instance.
362
+ *
363
+ * @return Error instance is returned.
345
364
  */
346
- replaceWith(
347
- ...nodes: (Node.ChildNode | Node.ChildProps | Node.ChildNode[] | Node.ChildProps[])[]
348
- ): this
365
+ error(message: string, options?: Node.NodeErrorOptions): CssSyntaxError
349
366
 
350
367
  /**
351
368
  * Returns the next child of the node’s parent.
@@ -364,6 +381,22 @@ declare abstract class Node_ {
364
381
  */
365
382
  next(): Node.ChildNode | undefined
366
383
 
384
+ /**
385
+ * Get the position for a word or an index inside the node.
386
+ *
387
+ * @param opts Options.
388
+ * @return Position.
389
+ */
390
+ positionBy(opts?: Pick<WarningOptions, 'index' | 'word'>): Node.Position
391
+
392
+ /**
393
+ * Convert string index to line/column.
394
+ *
395
+ * @param index The symbol number in the node’s string.
396
+ * @return Symbol position in file.
397
+ */
398
+ positionInside(index: number): Node.Position
399
+
367
400
  /**
368
401
  * Returns the previous child of the node’s parent.
369
402
  * Returns `undefined` if the current node is the first child.
@@ -380,76 +413,82 @@ declare abstract class Node_ {
380
413
  prev(): Node.ChildNode | undefined
381
414
 
382
415
  /**
383
- * Insert new node before current node to current node’s parent.
384
- *
385
- * Just alias for `node.parent.insertBefore(node, add)`.
386
- *
387
- * ```js
388
- * decl.before('content: ""')
389
- * ```
416
+ * Get the range for a word or start and end index inside the node.
417
+ * The start index is inclusive; the end index is exclusive.
390
418
  *
391
- * @param newNode New node.
392
- * @return This node for methods chain.
419
+ * @param opts Options.
420
+ * @return Range.
393
421
  */
394
- before(newNode: Node | Node.ChildProps | string | Node[]): this
422
+ rangeBy(
423
+ opts?: Pick<WarningOptions, 'endIndex' | 'index' | 'word'>
424
+ ): Node.Range
395
425
 
396
426
  /**
397
- * Insert new node after current node to current node’s parent.
398
- *
399
- * Just alias for `node.parent.insertAfter(node, add)`.
427
+ * Returns a `raws` value. If the node is missing
428
+ * the code style property (because the node was manually built or cloned),
429
+ * PostCSS will try to autodetect the code style property by looking
430
+ * at other nodes in the tree.
400
431
  *
401
432
  * ```js
402
- * decl.after('color: black')
433
+ * const root = postcss.parse('a { background: white }')
434
+ * root.nodes[0].append({ prop: 'color', value: 'black' })
435
+ * root.nodes[0].nodes[1].raws.before //=> undefined
436
+ * root.nodes[0].nodes[1].raw('before') //=> ' '
403
437
  * ```
404
438
  *
405
- * @param newNode New node.
406
- * @return This node for methods chain.
439
+ * @param prop Name of code style property.
440
+ * @param defaultType Name of default value, it can be missed
441
+ * if the value is the same as prop.
442
+ * @return {string} Code style value.
407
443
  */
408
- after(newNode: Node | Node.ChildProps | string | Node[]): this
444
+ raw(prop: string, defaultType?: string): string
409
445
 
410
446
  /**
411
- * Finds the Root instance of the node’s tree.
447
+ * It removes the node from its parent and deletes its parent property.
412
448
  *
413
449
  * ```js
414
- * root.nodes[0].nodes[0].root() === root
450
+ * if (decl.prop.match(/^-webkit-/)) {
451
+ * decl.remove()
452
+ * }
415
453
  * ```
416
454
  *
417
- * @return Root parent.
455
+ * @return `this` for method chaining.
418
456
  */
419
- root(): Root
457
+ remove(): this
420
458
 
421
459
  /**
422
- * Returns a `Node#raws` value. If the node is missing
423
- * the code style property (because the node was manually built or cloned),
424
- * PostCSS will try to autodetect the code style property by looking
425
- * at other nodes in the tree.
460
+ * Inserts node(s) before the current node and removes the current node.
426
461
  *
427
462
  * ```js
428
- * const root = postcss.parse('a { background: white }')
429
- * root.nodes[0].append({ prop: 'color', value: 'black' })
430
- * root.nodes[0].nodes[1].raws.before //=> undefined
431
- * root.nodes[0].nodes[1].raw('before') //=> ' '
463
+ * AtRule: {
464
+ * mixin: atrule => {
465
+ * atrule.replaceWith(mixinRules[atrule.params])
466
+ * }
467
+ * }
432
468
  * ```
433
469
  *
434
- * @param prop Name of code style property.
435
- * @param defaultType Name of default value, it can be missed
436
- * if the value is the same as prop.
437
- * @return {string} Code style value.
470
+ * @param nodes Mode(s) to replace current one.
471
+ * @return Current node to methods chain.
438
472
  */
439
- raw(prop: string, defaultType?: string): string
473
+ replaceWith(
474
+ ...nodes: (
475
+ | Node.ChildNode
476
+ | Node.ChildNode[]
477
+ | Node.ChildProps
478
+ | Node.ChildProps[]
479
+ )[]
480
+ ): this
440
481
 
441
482
  /**
442
- * Clear the code style properties for the node and its children.
483
+ * Finds the Root instance of the node’s tree.
443
484
  *
444
485
  * ```js
445
- * node.raws.before //=> ' '
446
- * node.cleanRaws()
447
- * node.raws.before //=> undefined
486
+ * root.nodes[0].nodes[0].root() === root
448
487
  * ```
449
488
  *
450
- * @param keepBetween Keep the `raws.between` symbols.
489
+ * @return Root parent.
451
490
  */
452
- cleanRaws(keepBetween?: boolean): void
491
+ root(): Root
453
492
 
454
493
  /**
455
494
  * Fix circular links on `JSON.stringify()`.
@@ -459,31 +498,39 @@ declare abstract class Node_ {
459
498
  toJSON(): object
460
499
 
461
500
  /**
462
- * Convert string index to line/column.
501
+ * It compiles the node to browser readable cascading style sheets string
502
+ * depending on it's type.
463
503
  *
464
- * @param index The symbol number in the node’s string.
465
- * @return Symbol position in file.
466
- */
467
- positionInside(index: number): Node.Position
468
-
469
- /**
470
- * Get the position for a word or an index inside the node.
504
+ * ```js
505
+ * console.log(new Rule({ selector: 'a' }).toString()) //=> "a {}"
506
+ * ```
471
507
  *
472
- * @param opts Options.
473
- * @return Position.
508
+ * @param stringifier A syntax to use in string generation.
509
+ * @return CSS string of this node.
474
510
  */
475
- positionBy(opts?: Pick<WarningOptions, 'word' | 'index'>): Node.Position
511
+ toString(stringifier?: Stringifier | Syntax): string
476
512
 
477
513
  /**
478
- * Get the range for a word or start and end index inside the node.
479
- * The start index is inclusive; the end index is exclusive.
514
+ * It is a wrapper for {@link Result#warn}, providing convenient
515
+ * way of generating warnings.
480
516
  *
481
- * @param opts Options.
482
- * @return Range.
517
+ * ```js
518
+ * Declaration: {
519
+ * bad: (decl, { result }) => {
520
+ * decl.warn(result, 'Deprecated property: bad')
521
+ * }
522
+ * }
523
+ * ```
524
+ *
525
+ * @param result The `Result` instance that will receive the warning.
526
+ * @param message Description for the warning.
527
+ * @param options Options for the warning.
528
+ *
529
+ * @return `Warning` instance is returned
483
530
  */
484
- rangeBy(opts?: Pick<WarningOptions, 'word' | 'index' | 'endIndex'>): Node.Range
531
+ warn(result: Result, message: string, options?: WarningOptions): Warning
485
532
  }
486
533
 
487
- declare class Node extends Node_ {}
534
+ declare class Node extends Node_ { }
488
535
 
489
536
  export = Node