postcss 8.2.8 → 8.2.12

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
@@ -175,7 +175,7 @@ export default abstract class Node {
175
175
  /**
176
176
  * @param defaults Value for node properties.
177
177
  */
178
- constructor (defaults?: object)
178
+ constructor(defaults?: object)
179
179
 
180
180
  /**
181
181
  * Returns a `CssSyntaxError` instance containing the original position
@@ -204,7 +204,7 @@ export default abstract class Node {
204
204
  *
205
205
  * @return Error object to throw it.
206
206
  */
207
- error (message: string, options?: NodeErrorOptions): CssSyntaxError
207
+ error(message: string, options?: NodeErrorOptions): CssSyntaxError
208
208
 
209
209
  /**
210
210
  * This method is provided as a convenience wrapper for `Result#warn`.
@@ -223,7 +223,7 @@ export default abstract class Node {
223
223
  *
224
224
  * @return Created warning object.
225
225
  */
226
- warn (result: Result, text: string, opts?: WarningOptions): void
226
+ warn(result: Result, text: string, opts?: WarningOptions): void
227
227
 
228
228
  /**
229
229
  * Removes the node from its parent and cleans the parent properties
@@ -237,7 +237,7 @@ export default abstract class Node {
237
237
  *
238
238
  * @return Node to make calls chain.
239
239
  */
240
- remove (): this
240
+ remove(): this
241
241
 
242
242
  /**
243
243
  * Returns a CSS string representing the node.
@@ -249,7 +249,7 @@ export default abstract class Node {
249
249
  * @param stringifier A syntax to use in string generation.
250
250
  * @return CSS string of this node.
251
251
  */
252
- toString (stringifier?: Stringifier | Syntax): string
252
+ toString(stringifier?: Stringifier | Syntax): string
253
253
 
254
254
  /**
255
255
  * Returns an exact clone of the node.
@@ -267,7 +267,7 @@ export default abstract class Node {
267
267
  * @param overrides New properties to override in the clone.
268
268
  * @return Clone of the node.
269
269
  */
270
- clone (overrides?: object): this
270
+ clone(overrides?: object): this
271
271
 
272
272
  /**
273
273
  * Shortcut to clone the node and insert the resulting cloned node
@@ -281,7 +281,7 @@ export default abstract class Node {
281
281
  *
282
282
  * @return New node
283
283
  */
284
- cloneBefore (overrides?: object): this
284
+ cloneBefore(overrides?: object): this
285
285
 
286
286
  /**
287
287
  * Shortcut to clone the node and insert the resulting cloned node
@@ -290,7 +290,7 @@ export default abstract class Node {
290
290
  * @param overrides New properties to override in the clone.
291
291
  * @return New node.
292
292
  */
293
- cloneAfter (overrides?: object): this
293
+ cloneAfter(overrides?: object): this
294
294
 
295
295
  /**
296
296
  * Inserts node(s) before the current node and removes the current node.
@@ -306,7 +306,7 @@ export default abstract class Node {
306
306
  * @param nodes Mode(s) to replace current one.
307
307
  * @return Current node to methods chain.
308
308
  */
309
- replaceWith (
309
+ replaceWith(
310
310
  ...nodes: (ChildNode | ChildProps | ChildNode[] | ChildProps[])[]
311
311
  ): this
312
312
 
@@ -325,7 +325,7 @@ export default abstract class Node {
325
325
  *
326
326
  * @return Next node.
327
327
  */
328
- next (): ChildNode | undefined
328
+ next(): ChildNode | undefined
329
329
 
330
330
  /**
331
331
  * Returns the previous child of the node’s parent.
@@ -340,7 +340,7 @@ export default abstract class Node {
340
340
  *
341
341
  * @return Previous node.
342
342
  */
343
- prev (): ChildNode | undefined
343
+ prev(): ChildNode | undefined
344
344
 
345
345
  /**
346
346
  * Insert new node before current node to current node’s parent.
@@ -354,7 +354,7 @@ export default abstract class Node {
354
354
  * @param newNode New node.
355
355
  * @return This node for methods chain.
356
356
  */
357
- before (newNode: Node | ChildProps | string | Node[]): this
357
+ before(newNode: Node | ChildProps | string | Node[]): this
358
358
 
359
359
  /**
360
360
  * Insert new node after current node to current node’s parent.
@@ -368,7 +368,7 @@ export default abstract class Node {
368
368
  * @param newNode New node.
369
369
  * @return This node for methods chain.
370
370
  */
371
- after (newNode: Node | ChildProps | string | Node[]): this
371
+ after(newNode: Node | ChildProps | string | Node[]): this
372
372
 
373
373
  /**
374
374
  * Finds the Root instance of the node’s tree.
@@ -379,7 +379,7 @@ export default abstract class Node {
379
379
  *
380
380
  * @return Root parent.
381
381
  */
382
- root (): Root
382
+ root(): Root
383
383
 
384
384
  /**
385
385
  * Returns a `Node#raws` value. If the node is missing
@@ -399,7 +399,7 @@ export default abstract class Node {
399
399
  * if the value is the same as prop.
400
400
  * @return {string} Code style value.
401
401
  */
402
- raw (prop: string, defaultType?: string): string
402
+ raw(prop: string, defaultType?: string): string
403
403
 
404
404
  /**
405
405
  * Clear the code style properties for the node and its children.
@@ -412,14 +412,14 @@ export default abstract class Node {
412
412
  *
413
413
  * @param keepBetween Keep the `raws.between` symbols.
414
414
  */
415
- cleanRaws (keepBetween?: boolean): void
415
+ cleanRaws(keepBetween?: boolean): void
416
416
 
417
417
  /**
418
418
  * Fix circular links on `JSON.stringify()`.
419
419
  *
420
420
  * @return Cleaned object.
421
421
  */
422
- toJSON (): object
422
+ toJSON(): object
423
423
 
424
424
  /**
425
425
  * Convert string index to line/column.
@@ -427,5 +427,5 @@ export default abstract class Node {
427
427
  * @param index The symbol number in the node’s string.
428
428
  * @return Symbol position in file.
429
429
  */
430
- positionInside (index: number): Position
430
+ positionInside(index: number): Position
431
431
  }
package/lib/node.js CHANGED
@@ -5,7 +5,7 @@ let Stringifier = require('./stringifier')
5
5
  let { isClean } = require('./symbols')
6
6
  let stringify = require('./stringify')
7
7
 
8
- function cloneNode (obj, parent) {
8
+ function cloneNode(obj, parent) {
9
9
  let cloned = new obj.constructor()
10
10
 
11
11
  for (let i in obj) {
@@ -33,7 +33,7 @@ function cloneNode (obj, parent) {
33
33
  }
34
34
 
35
35
  class Node {
36
- constructor (defaults = {}) {
36
+ constructor(defaults = {}) {
37
37
  this.raws = {}
38
38
  this[isClean] = false
39
39
 
@@ -53,7 +53,7 @@ class Node {
53
53
  }
54
54
  }
55
55
 
56
- error (message, opts = {}) {
56
+ error(message, opts = {}) {
57
57
  if (this.source) {
58
58
  let pos = this.positionBy(opts)
59
59
  return this.source.input.error(message, pos.line, pos.column, opts)
@@ -61,13 +61,13 @@ class Node {
61
61
  return new CssSyntaxError(message)
62
62
  }
63
63
 
64
- warn (result, text, opts) {
64
+ warn(result, text, opts) {
65
65
  let data = { node: this }
66
66
  for (let i in opts) data[i] = opts[i]
67
67
  return result.warn(text, data)
68
68
  }
69
69
 
70
- remove () {
70
+ remove() {
71
71
  if (this.parent) {
72
72
  this.parent.removeChild(this)
73
73
  }
@@ -75,7 +75,7 @@ class Node {
75
75
  return this
76
76
  }
77
77
 
78
- toString (stringifier = stringify) {
78
+ toString(stringifier = stringify) {
79
79
  if (stringifier.stringify) stringifier = stringifier.stringify
80
80
  let result = ''
81
81
  stringifier(this, i => {
@@ -84,7 +84,7 @@ class Node {
84
84
  return result
85
85
  }
86
86
 
87
- clone (overrides = {}) {
87
+ clone(overrides = {}) {
88
88
  let cloned = cloneNode(this)
89
89
  for (let name in overrides) {
90
90
  cloned[name] = overrides[name]
@@ -92,19 +92,19 @@ class Node {
92
92
  return cloned
93
93
  }
94
94
 
95
- cloneBefore (overrides = {}) {
95
+ cloneBefore(overrides = {}) {
96
96
  let cloned = this.clone(overrides)
97
97
  this.parent.insertBefore(this, cloned)
98
98
  return cloned
99
99
  }
100
100
 
101
- cloneAfter (overrides = {}) {
101
+ cloneAfter(overrides = {}) {
102
102
  let cloned = this.clone(overrides)
103
103
  this.parent.insertAfter(this, cloned)
104
104
  return cloned
105
105
  }
106
106
 
107
- replaceWith (...nodes) {
107
+ replaceWith(...nodes) {
108
108
  if (this.parent) {
109
109
  let bookmark = this
110
110
  let foundSelf = false
@@ -127,46 +127,46 @@ class Node {
127
127
  return this
128
128
  }
129
129
 
130
- next () {
130
+ next() {
131
131
  if (!this.parent) return undefined
132
132
  let index = this.parent.index(this)
133
133
  return this.parent.nodes[index + 1]
134
134
  }
135
135
 
136
- prev () {
136
+ prev() {
137
137
  if (!this.parent) return undefined
138
138
  let index = this.parent.index(this)
139
139
  return this.parent.nodes[index - 1]
140
140
  }
141
141
 
142
- before (add) {
142
+ before(add) {
143
143
  this.parent.insertBefore(this, add)
144
144
  return this
145
145
  }
146
146
 
147
- after (add) {
147
+ after(add) {
148
148
  this.parent.insertAfter(this, add)
149
149
  return this
150
150
  }
151
151
 
152
- root () {
152
+ root() {
153
153
  let result = this
154
154
  while (result.parent) result = result.parent
155
155
  return result
156
156
  }
157
157
 
158
- raw (prop, defaultType) {
158
+ raw(prop, defaultType) {
159
159
  let str = new Stringifier()
160
160
  return str.raw(this, prop, defaultType)
161
161
  }
162
162
 
163
- cleanRaws (keepBetween) {
163
+ cleanRaws(keepBetween) {
164
164
  delete this.raws.before
165
165
  delete this.raws.after
166
166
  if (!keepBetween) delete this.raws.between
167
167
  }
168
168
 
169
- toJSON (_, inputs) {
169
+ toJSON(_, inputs) {
170
170
  let fixed = {}
171
171
  let emitInputs = inputs == null
172
172
  inputs = inputs || new Map()
@@ -214,7 +214,7 @@ class Node {
214
214
  return fixed
215
215
  }
216
216
 
217
- positionInside (index) {
217
+ positionInside(index) {
218
218
  let string = this.toString()
219
219
  let column = this.source.start.column
220
220
  let line = this.source.start.line
@@ -231,7 +231,7 @@ class Node {
231
231
  return { line, column }
232
232
  }
233
233
 
234
- positionBy (opts) {
234
+ positionBy(opts) {
235
235
  let pos = this.source.start
236
236
  if (opts.index) {
237
237
  pos = this.positionInside(opts.index)
@@ -242,9 +242,9 @@ class Node {
242
242
  return pos
243
243
  }
244
244
 
245
- getProxyProcessor () {
245
+ getProxyProcessor() {
246
246
  return {
247
- set (node, prop, value) {
247
+ set(node, prop, value) {
248
248
  if (node[prop] === value) return true
249
249
  node[prop] = value
250
250
  if (
@@ -260,7 +260,7 @@ class Node {
260
260
  return true
261
261
  },
262
262
 
263
- get (node, prop) {
263
+ get(node, prop) {
264
264
  if (prop === 'proxyOf') {
265
265
  return node
266
266
  } else if (prop === 'root') {
@@ -272,14 +272,14 @@ class Node {
272
272
  }
273
273
  }
274
274
 
275
- toProxy () {
275
+ toProxy() {
276
276
  if (!this.proxyCache) {
277
277
  this.proxyCache = new Proxy(this, this.getProxyProcessor())
278
278
  }
279
279
  return this.proxyCache
280
280
  }
281
281
 
282
- addToError (error) {
282
+ addToError(error) {
283
283
  error.postcssNode = this
284
284
  if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
285
285
  let s = this.source
@@ -291,7 +291,7 @@ class Node {
291
291
  return error
292
292
  }
293
293
 
294
- markDirty () {
294
+ markDirty() {
295
295
  if (this[isClean]) {
296
296
  this[isClean] = false
297
297
  let next = this
@@ -301,7 +301,7 @@ class Node {
301
301
  }
302
302
  }
303
303
 
304
- get proxyOf () {
304
+ get proxyOf() {
305
305
  return this
306
306
  }
307
307
  }
package/lib/parse.js CHANGED
@@ -4,7 +4,7 @@ let Container = require('./container')
4
4
  let Parser = require('./parser')
5
5
  let Input = require('./input')
6
6
 
7
- function parse (css, opts) {
7
+ function parse(css, opts) {
8
8
  let input = new Input(css, opts)
9
9
  let parser = new Parser(input)
10
10
  try {
package/lib/parser.js CHANGED
@@ -8,7 +8,7 @@ let Root = require('./root')
8
8
  let Rule = require('./rule')
9
9
 
10
10
  class Parser {
11
- constructor (input) {
11
+ constructor(input) {
12
12
  this.input = input
13
13
 
14
14
  this.root = new Root()
@@ -21,11 +21,11 @@ class Parser {
21
21
  this.root.source = { input, start: { offset: 0, line: 1, column: 1 } }
22
22
  }
23
23
 
24
- createTokenizer () {
24
+ createTokenizer() {
25
25
  this.tokenizer = tokenizer(this.input)
26
26
  }
27
27
 
28
- parse () {
28
+ parse() {
29
29
  let token
30
30
  while (!this.tokenizer.endOfFile()) {
31
31
  token = this.tokenizer.nextToken()
@@ -63,7 +63,7 @@ class Parser {
63
63
  this.endFile()
64
64
  }
65
65
 
66
- comment (token) {
66
+ comment(token) {
67
67
  let node = new Comment()
68
68
  this.init(node, token[2])
69
69
  node.source.end = this.getPosition(token[3] || token[2])
@@ -81,7 +81,7 @@ class Parser {
81
81
  }
82
82
  }
83
83
 
84
- emptyRule (token) {
84
+ emptyRule(token) {
85
85
  let node = new Rule()
86
86
  this.init(node, token[2])
87
87
  node.selector = ''
@@ -89,7 +89,7 @@ class Parser {
89
89
  this.current = node
90
90
  }
91
91
 
92
- other (start) {
92
+ other(start) {
93
93
  let end = false
94
94
  let type = null
95
95
  let colon = false
@@ -150,7 +150,7 @@ class Parser {
150
150
  }
151
151
  }
152
152
 
153
- rule (tokens) {
153
+ rule(tokens) {
154
154
  tokens.pop()
155
155
 
156
156
  let node = new Rule()
@@ -161,7 +161,7 @@ class Parser {
161
161
  this.current = node
162
162
  }
163
163
 
164
- decl (tokens, customProperty) {
164
+ decl(tokens, customProperty) {
165
165
  let node = new Declaration()
166
166
  this.init(node, tokens[0][2])
167
167
 
@@ -254,7 +254,7 @@ class Parser {
254
254
  }
255
255
  }
256
256
 
257
- atrule (token) {
257
+ atrule(token) {
258
258
  let node = new AtRule()
259
259
  node.name = token[1].slice(1)
260
260
  if (node.name === '') {
@@ -337,7 +337,7 @@ class Parser {
337
337
  }
338
338
  }
339
339
 
340
- end (token) {
340
+ end(token) {
341
341
  if (this.current.nodes && this.current.nodes.length) {
342
342
  this.current.raws.semicolon = this.semicolon
343
343
  }
@@ -354,7 +354,7 @@ class Parser {
354
354
  }
355
355
  }
356
356
 
357
- endFile () {
357
+ endFile() {
358
358
  if (this.current.parent) this.unclosedBlock()
359
359
  if (this.current.nodes && this.current.nodes.length) {
360
360
  this.current.raws.semicolon = this.semicolon
@@ -362,7 +362,7 @@ class Parser {
362
362
  this.current.raws.after = (this.current.raws.after || '') + this.spaces
363
363
  }
364
364
 
365
- freeSemicolon (token) {
365
+ freeSemicolon(token) {
366
366
  this.spaces += token[1]
367
367
  if (this.current.nodes) {
368
368
  let prev = this.current.nodes[this.current.nodes.length - 1]
@@ -375,7 +375,7 @@ class Parser {
375
375
 
376
376
  // Helpers
377
377
 
378
- getPosition (offset) {
378
+ getPosition(offset) {
379
379
  let pos = this.input.fromOffset(offset)
380
380
  return {
381
381
  offset,
@@ -384,7 +384,7 @@ class Parser {
384
384
  }
385
385
  }
386
386
 
387
- init (node, offset) {
387
+ init(node, offset) {
388
388
  this.current.push(node)
389
389
  node.source = {
390
390
  start: this.getPosition(offset),
@@ -395,7 +395,7 @@ class Parser {
395
395
  if (node.type !== 'comment') this.semicolon = false
396
396
  }
397
397
 
398
- raw (node, prop, tokens) {
398
+ raw(node, prop, tokens) {
399
399
  let token, type
400
400
  let length = tokens.length
401
401
  let value = ''
@@ -438,7 +438,7 @@ class Parser {
438
438
  node[prop] = value
439
439
  }
440
440
 
441
- spacesAndCommentsFromEnd (tokens) {
441
+ spacesAndCommentsFromEnd(tokens) {
442
442
  let lastTokenType
443
443
  let spaces = ''
444
444
  while (tokens.length) {
@@ -449,7 +449,7 @@ class Parser {
449
449
  return spaces
450
450
  }
451
451
 
452
- spacesAndCommentsFromStart (tokens) {
452
+ spacesAndCommentsFromStart(tokens) {
453
453
  let next
454
454
  let spaces = ''
455
455
  while (tokens.length) {
@@ -460,7 +460,7 @@ class Parser {
460
460
  return spaces
461
461
  }
462
462
 
463
- spacesFromEnd (tokens) {
463
+ spacesFromEnd(tokens) {
464
464
  let lastTokenType
465
465
  let spaces = ''
466
466
  while (tokens.length) {
@@ -471,7 +471,7 @@ class Parser {
471
471
  return spaces
472
472
  }
473
473
 
474
- stringFrom (tokens, from) {
474
+ stringFrom(tokens, from) {
475
475
  let result = ''
476
476
  for (let i = from; i < tokens.length; i++) {
477
477
  result += tokens[i][1]
@@ -480,7 +480,7 @@ class Parser {
480
480
  return result
481
481
  }
482
482
 
483
- colon (tokens) {
483
+ colon(tokens) {
484
484
  let brackets = 0
485
485
  let token, type, prev
486
486
  for (let [i, element] of tokens.entries()) {
@@ -510,36 +510,36 @@ class Parser {
510
510
 
511
511
  // Errors
512
512
 
513
- unclosedBracket (bracket) {
513
+ unclosedBracket(bracket) {
514
514
  throw this.input.error('Unclosed bracket', bracket[2])
515
515
  }
516
516
 
517
- unknownWord (tokens) {
517
+ unknownWord(tokens) {
518
518
  throw this.input.error('Unknown word', tokens[0][2])
519
519
  }
520
520
 
521
- unexpectedClose (token) {
521
+ unexpectedClose(token) {
522
522
  throw this.input.error('Unexpected }', token[2])
523
523
  }
524
524
 
525
- unclosedBlock () {
525
+ unclosedBlock() {
526
526
  let pos = this.current.source.start
527
527
  throw this.input.error('Unclosed block', pos.line, pos.column)
528
528
  }
529
529
 
530
- doubleColon (token) {
530
+ doubleColon(token) {
531
531
  throw this.input.error('Double colon', token[2])
532
532
  }
533
533
 
534
- unnamedAtrule (node, token) {
534
+ unnamedAtrule(node, token) {
535
535
  throw this.input.error('At-rule without name', token[2])
536
536
  }
537
537
 
538
- precheckMissedSemicolon (/* tokens */) {
538
+ precheckMissedSemicolon(/* tokens */) {
539
539
  // Hook for Safe Parser
540
540
  }
541
541
 
542
- checkMissedSemicolon (tokens) {
542
+ checkMissedSemicolon(tokens) {
543
543
  let colon = this.colon(tokens)
544
544
  if (colon === false) return
545
545
 
package/lib/postcss.d.ts CHANGED
@@ -4,6 +4,7 @@ import Node, {
4
4
  Position,
5
5
  Source,
6
6
  ChildNode,
7
+ NodeErrorOptions,
7
8
  NodeProps,
8
9
  ChildProps,
9
10
  AnyNode
@@ -30,6 +31,7 @@ export {
30
31
  ChildNode,
31
32
  AnyNode,
32
33
  Message,
34
+ NodeErrorOptions,
33
35
  NodeProps,
34
36
  DeclarationProps,
35
37
  ContainerProps,
package/lib/postcss.js CHANGED
@@ -18,14 +18,14 @@ let Rule = require('./rule')
18
18
  let Root = require('./root')
19
19
  let Node = require('./node')
20
20
 
21
- function postcss (...plugins) {
21
+ function postcss(...plugins) {
22
22
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
23
23
  plugins = plugins[0]
24
24
  }
25
25
  return new Processor(plugins)
26
26
  }
27
27
 
28
- postcss.plugin = function plugin (name, initializer) {
28
+ postcss.plugin = function plugin(name, initializer) {
29
29
  if (console && console.warn) {
30
30
  console.warn(
31
31
  name +
@@ -41,7 +41,7 @@ postcss.plugin = function plugin (name, initializer) {
41
41
  )
42
42
  }
43
43
  }
44
- function creator (...args) {
44
+ function creator(...args) {
45
45
  let transformer = initializer(...args)
46
46
  transformer.postcssPlugin = name
47
47
  transformer.postcssVersion = new Processor().version
@@ -50,7 +50,7 @@ postcss.plugin = function plugin (name, initializer) {
50
50
 
51
51
  let cache
52
52
  Object.defineProperty(creator, 'postcss', {
53
- get () {
53
+ get() {
54
54
  if (!cache) cache = creator()
55
55
  return cache
56
56
  }
@@ -50,7 +50,7 @@ export default class PreviousMap {
50
50
  * @param css Input CSS source.
51
51
  * @param opts Process options.
52
52
  */
53
- constructor (css: string, opts?: ProcessOptions)
53
+ constructor(css: string, opts?: ProcessOptions)
54
54
 
55
55
  /**
56
56
  * Create a instance of `SourceMapGenerator` class
@@ -61,12 +61,12 @@ export default class PreviousMap {
61
61
  *
62
62
  * @return Object with source map information.
63
63
  */
64
- consumer (): SourceMapConsumer
64
+ consumer(): SourceMapConsumer
65
65
 
66
66
  /**
67
67
  * Does source map contains `sourcesContent` with input source text.
68
68
  *
69
69
  * @return Is `sourcesContent` present.
70
70
  */
71
- withContent (): boolean
71
+ withContent(): boolean
72
72
  }