postcss 8.2.8 → 8.2.9

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.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
  }
@@ -4,7 +4,7 @@ let { existsSync, readFileSync } = require('fs')
4
4
  let { dirname, join } = require('path')
5
5
  let mozilla = require('source-map')
6
6
 
7
- function fromBase64 (str) {
7
+ function fromBase64(str) {
8
8
  if (Buffer) {
9
9
  return Buffer.from(str, 'base64').toString()
10
10
  } else {
@@ -14,7 +14,7 @@ function fromBase64 (str) {
14
14
  }
15
15
 
16
16
  class PreviousMap {
17
- constructor (css, opts) {
17
+ constructor(css, opts) {
18
18
  if (opts.map === false) return
19
19
  this.loadAnnotation(css)
20
20
  this.inline = this.startWith(this.annotation, 'data:')
@@ -28,32 +28,32 @@ class PreviousMap {
28
28
  if (text) this.text = text
29
29
  }
30
30
 
31
- consumer () {
31
+ consumer() {
32
32
  if (!this.consumerCache) {
33
33
  this.consumerCache = new mozilla.SourceMapConsumer(this.text)
34
34
  }
35
35
  return this.consumerCache
36
36
  }
37
37
 
38
- withContent () {
38
+ withContent() {
39
39
  return !!(
40
40
  this.consumer().sourcesContent &&
41
41
  this.consumer().sourcesContent.length > 0
42
42
  )
43
43
  }
44
44
 
45
- startWith (string, start) {
45
+ startWith(string, start) {
46
46
  if (!string) return false
47
47
  return string.substr(0, start.length) === start
48
48
  }
49
49
 
50
- getAnnotationURL (sourceMapString) {
50
+ getAnnotationURL(sourceMapString) {
51
51
  return sourceMapString
52
52
  .match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//)[1]
53
53
  .trim()
54
54
  }
55
55
 
56
- loadAnnotation (css) {
56
+ loadAnnotation(css) {
57
57
  let annotations = css.match(/\/\*\s*# sourceMappingURL=.*\s*\*\//gm)
58
58
 
59
59
  if (annotations && annotations.length > 0) {
@@ -66,7 +66,7 @@ class PreviousMap {
66
66
  }
67
67
  }
68
68
 
69
- decodeInline (text) {
69
+ decodeInline(text) {
70
70
  let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/
71
71
  let baseUri = /^data:application\/json;base64,/
72
72
  let charsetUri = /^data:application\/json;charset=utf-?8,/
@@ -84,7 +84,7 @@ class PreviousMap {
84
84
  throw new Error('Unsupported source map encoding ' + encoding)
85
85
  }
86
86
 
87
- loadFile (path) {
87
+ loadFile(path) {
88
88
  this.root = dirname(path)
89
89
  if (existsSync(path)) {
90
90
  this.mapFile = path
@@ -92,7 +92,7 @@ class PreviousMap {
92
92
  }
93
93
  }
94
94
 
95
- loadMap (file, prev) {
95
+ loadMap(file, prev) {
96
96
  if (prev === false) return false
97
97
 
98
98
  if (prev) {
@@ -129,7 +129,7 @@ class PreviousMap {
129
129
  }
130
130
  }
131
131
 
132
- isMap (map) {
132
+ isMap(map) {
133
133
  if (typeof map !== 'object') return false
134
134
  return (
135
135
  typeof map.mappings === 'string' ||
@@ -44,7 +44,7 @@ export default class Processor {
44
44
  /**
45
45
  * @param plugins PostCSS plugins
46
46
  */
47
- constructor (plugins?: AcceptedPlugin[])
47
+ constructor(plugins?: AcceptedPlugin[])
48
48
 
49
49
  /**
50
50
  * Adds a plugin to be used as a CSS processor.
@@ -73,7 +73,7 @@ export default class Processor {
73
73
  * @param plugin PostCSS plugin or `Processor` with plugins.
74
74
  * @return {Processes} Current processor to make methods chain.
75
75
  */
76
- use (plugin: AcceptedPlugin): this
76
+ use(plugin: AcceptedPlugin): this
77
77
 
78
78
  /**
79
79
  * Parses source CSS and returns a `LazyResult` Promise proxy.
@@ -94,7 +94,7 @@ export default class Processor {
94
94
  * @param opts Options.
95
95
  * @return Promise proxy.
96
96
  */
97
- process (
97
+ process(
98
98
  css: string | { toString(): string } | Result | LazyResult | Root,
99
99
  options?: ProcessOptions
100
100
  ): LazyResult
package/lib/processor.js CHANGED
@@ -4,17 +4,17 @@ let LazyResult = require('./lazy-result')
4
4
  let Root = require('./root')
5
5
 
6
6
  class Processor {
7
- constructor (plugins = []) {
8
- this.version = '8.2.8'
7
+ constructor(plugins = []) {
8
+ this.version = '8.2.9'
9
9
  this.plugins = this.normalize(plugins)
10
10
  }
11
11
 
12
- use (plugin) {
12
+ use(plugin) {
13
13
  this.plugins = this.plugins.concat(this.normalize([plugin]))
14
14
  return this
15
15
  }
16
16
 
17
- process (css, opts = {}) {
17
+ process(css, opts = {}) {
18
18
  if (
19
19
  this.plugins.length === 0 &&
20
20
  opts.parser === opts.stringifier &&
@@ -33,7 +33,7 @@ class Processor {
33
33
  return new LazyResult(this, css, opts)
34
34
  }
35
35
 
36
- normalize (plugins) {
36
+ normalize(plugins) {
37
37
  let normalized = []
38
38
  for (let i of plugins) {
39
39
  if (i.postcss === true) {
package/lib/result.d.ts CHANGED
@@ -141,7 +141,7 @@ export default class Result {
141
141
  * @param root Root node after all transformations.
142
142
  * @param opts Options from the `Processor#process` or `Root#toResult`.
143
143
  */
144
- constructor (processor: Processor, root: Root, opts: ResultOptions)
144
+ constructor(processor: Processor, root: Root, opts: ResultOptions)
145
145
 
146
146
  /**
147
147
  * An alias for the `Result#css` property.
@@ -151,7 +151,7 @@ export default class Result {
151
151
  * result.css === result.content
152
152
  * ```
153
153
  */
154
- get content (): string
154
+ get content(): string
155
155
 
156
156
  /**
157
157
  * Returns for `Result#css` content.
@@ -162,7 +162,7 @@ export default class Result {
162
162
  *
163
163
  * @return String representing of `Result#root`.
164
164
  */
165
- toString (): string
165
+ toString(): string
166
166
 
167
167
  /**
168
168
  * Creates an instance of `Warning` and adds it to `Result#messages`.
@@ -177,7 +177,7 @@ export default class Result {
177
177
  * @param opts Warning options.
178
178
  * @return Created warning.
179
179
  */
180
- warn (message: string, options?: WarningOptions): Warning
180
+ warn(message: string, options?: WarningOptions): Warning
181
181
 
182
182
  /**
183
183
  * Returns warnings from plugins. Filters `Warning` instances
@@ -191,5 +191,5 @@ export default class Result {
191
191
  *
192
192
  * @return Warnings from plugins.
193
193
  */
194
- warnings (): Warning[]
194
+ warnings(): Warning[]
195
195
  }