postcss 6.0.22 → 7.0.2

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/CHANGELOG.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 7.0.2
5
+ * Fix warning text (by Rui Pedro M Lima).
6
+
7
+ ## 7.0.1
8
+ * Fix JSDoc (by Steven Lambert).
9
+
10
+ ## 7.0 “President Amy”
11
+ * Remove Node.js 9 and Node.js 4 support.
12
+ * Remove IE and “dead” browsers from Babel.
13
+ * Add CSS position on error happened inside `walk()` (by Nikhil Gaba).
14
+ * Add `LazyResult#finally` (by Igor Kamyshev).
15
+ * Add warning on calling PostCSS without plugins and syntax options.
16
+ * Reduce client-side size.
17
+
18
+ ## 6.0.23
19
+ * Fix parsing nested at-rules without semicolon, params, and spaces.
20
+ * Fix docs (by Kevin Schiffer and Pat Cavit).
21
+
4
22
  ## 6.0.22
5
23
  * Fix `Node#prev` and `Node#next` on missed parent.
6
24
 
package/README-cn.md CHANGED
@@ -14,6 +14,8 @@ PostCSS 是一个允许使用 JS 插件转换样式的工具。
14
14
  PostCSS 在工业界被广泛地应用,其中不乏很多有名的行业领导者,如:维基百科,Twitter,阿里巴巴,
15
15
  JetBrains。PostCSS 的 [Autoprefixer] 插件是最流行的 CSS 处理工具之一。
16
16
 
17
+ PostCSS 接收一个 CSS 文件并提供了一个 API 来分析、修改它的规则(通过把 CSS 规则转换成一个[抽象语法树]的方式)。在这之后,这个 API 便可被许多[插件]利用来做有用的事情,比如寻错或自动添加 CSS vendor 前缀。
18
+
17
19
  **Twitter 账号:** [@postcss](https://twitter.com/postcss)<br>
18
20
  **支持 / 讨论:** [Gitter](https://gitter.im/postcss/postcss)<br>
19
21
 
@@ -21,7 +23,9 @@ JetBrains。PostCSS 的 [Autoprefixer] 插件是最流行的 CSS 处理工具之
21
23
  PostCSS 插件),请联系 [Evil Martians](https://evilmartians.com/?utm_source=postcss)
22
24
  邮箱 <surrender@evilmartians.com>。
23
25
 
26
+ [抽象语法树]: https://zh.wikipedia.org/wiki/%E6%8A%BD%E8%B1%A1%E8%AA%9E%E6%B3%95%E6%A8%B9
24
27
  [Autoprefixer]: https://github.com/postcss/autoprefixer
28
+ [插件]: https://github.com/postcss/postcss/blob/master/README-cn.md#%E6%8F%92%E4%BB%B6
25
29
 
26
30
  <a href="https://evilmartians.com/?utm_source=postcss">
27
31
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
@@ -50,7 +54,6 @@ PostCSS 插件),请联系 [Evil Martians](https://evilmartians.com/?utm_sou
50
54
 
51
55
  * [`autoprefixer`] 添加了 vendor 浏览器前缀,它使用 Can I Use 上面的数据。
52
56
  * [`postcss-preset-env`] 允许你使用未来的 CSS 特性。
53
- * [`postcss-image-set-polyfill`] 为所有浏览器模拟了 [`image-set`] 函数逻辑。
54
57
 
55
58
  ### 更佳的 CSS 可读性
56
59
 
@@ -81,7 +84,6 @@ PostCSS 插件),请联系 [Evil Martians](https://evilmartians.com/?utm_sou
81
84
  * [`lost`] 是一个功能强大的 `calc()` 栅格系统。
82
85
  * [`rtlcss`] 镜像翻转 CSS 样式,适用于 right-to-left 的应用场景。
83
86
 
84
- [`postcss-image-set-polyfill`]: https://github.com/SuperOl3g/postcss-image-set-polyfill
85
87
  [`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg
86
88
  [`postcss-preset-env`]: https://github.com/jonathantneal/postcss-preset-env
87
89
  [`react-css-modules`]: https://github.com/gajus/react-css-modules
@@ -102,7 +104,6 @@ PostCSS 插件),请联系 [Evil Martians](https://evilmartians.com/?utm_sou
102
104
  [`css-modules`]: https://github.com/css-modules/css-modules
103
105
  [`colorguard`]: https://github.com/SlexAxton/css-colorguard
104
106
  [`stylelint`]: https://github.com/stylelint/stylelint
105
- [`image-set`]: https://drafts.csswg.org/css-images-4/#image-set-notation
106
107
  [`stylefmt`]: https://github.com/morishitter/stylefmt
107
108
  [`cssnano`]: http://cssnano.co
108
109
  [`precss`]: https://github.com/jonathantneal/precss
@@ -120,6 +121,7 @@ PostCSS 可以转化样式到任意语法,不仅仅是 CSS。
120
121
  * [`postcss-syntax`] 通过文件扩展名自动切换语法。
121
122
  * [`postcss-html`] 解析类 HTML 文件里`<style>`标签中的样式。
122
123
  * [`postcss-markdown`] 解析 Markdown 文件里代码块中的样式。
124
+ * [`postcss-jsx`] 解析源文件里模板或对象字面量中的CSS。
123
125
  * [`postcss-styled`] 解析源文件里模板字面量中的CSS。
124
126
  * [`postcss-scss`] 允许你使用 SCSS *(但并没有将 SCSS 编译到 CSS)*。
125
127
  * [`postcss-sass`] 允许你使用 Sass *(但并没有将 Sass 编译到 CSS)*。
@@ -134,6 +136,7 @@ PostCSS 可以转化样式到任意语法,不仅仅是 CSS。
134
136
  [`postcss-syntax`]: https://github.com/gucong3000/postcss-syntax
135
137
  [`postcss-html`]: https://github.com/gucong3000/postcss-html
136
138
  [`postcss-markdown`]: https://github.com/gucong3000/postcss-markdown
139
+ [`postcss-jsx`]: https://github.com/gucong3000/postcss-jsx
137
140
  [`postcss-styled`]: https://github.com/gucong3000/postcss-styled
138
141
  [`postcss-scss`]: https://github.com/postcss/postcss-scss
139
142
  [`postcss-sass`]: https://github.com/AleshaOleg/postcss-sass
@@ -169,28 +172,28 @@ PostCSS 可以转化样式到任意语法,不仅仅是 CSS。
169
172
 
170
173
  ```js
171
174
  module.exports = {
172
- module: {
173
- rules: [
174
- {
175
- test: /\.css$/,
176
- exclude: /node_modules/,
177
- use: [
178
- {
179
- loader: 'style-loader',
180
- },
181
- {
182
- loader: 'css-loader',
183
- options: {
184
- importLoaders: 1,
185
- }
186
- },
187
- {
188
- loader: 'postcss-loader'
189
- }
190
- ]
175
+ module: {
176
+ rules: [
177
+ {
178
+ test: /\.css$/,
179
+ exclude: /node_modules/,
180
+ use: [
181
+ {
182
+ loader: 'style-loader',
183
+ },
184
+ {
185
+ loader: 'css-loader',
186
+ options: {
187
+ importLoaders: 1,
191
188
  }
189
+ },
190
+ {
191
+ loader: 'postcss-loader'
192
+ }
192
193
  ]
193
- }
194
+ }
195
+ ]
196
+ }
194
197
  }
195
198
  ```
196
199
 
@@ -198,10 +201,10 @@ module.exports = {
198
201
 
199
202
  ```js
200
203
  module.exports = {
201
- plugins: [
202
- require('precss'),
203
- require('autoprefixer')
204
- ]
204
+ plugins: [
205
+ require('precss'),
206
+ require('autoprefixer')
207
+ ]
205
208
  }
206
209
  ```
207
210
 
@@ -212,16 +215,16 @@ module.exports = {
212
215
  使用 [`gulp-postcss`] 和 [`gulp-sourcemaps`].
213
216
 
214
217
  ```js
215
- gulp.task('css', function () {
216
- var postcss = require('gulp-postcss');
217
- var sourcemaps = require('gulp-sourcemaps');
218
-
219
- return gulp.src('src/**/*.css')
220
- .pipe( sourcemaps.init() )
221
- .pipe( postcss([ require('precss'), require('autoprefixer') ]) )
222
- .pipe( sourcemaps.write('.') )
223
- .pipe( gulp.dest('build/') );
224
- });
218
+ gulp.task('css', () => {
219
+ const postcss = require('gulp-postcss')
220
+ const sourcemaps = require('gulp-sourcemaps')
221
+
222
+ return gulp.src('src/**/*.css')
223
+ .pipe( sourcemaps.init() )
224
+ .pipe( postcss([ require('precss'), require('autoprefixer') ]) )
225
+ .pipe( sourcemaps.write('.') )
226
+ .pipe( gulp.dest('build/') )
227
+ })
225
228
  ```
226
229
 
227
230
  [`gulp-sourcemaps`]: https://github.com/floridoo/gulp-sourcemaps
@@ -246,10 +249,10 @@ postcss --use autoprefixer -c options.json -o main.css css/*.css
246
249
  你可以用 [`postcss-js`] 然后转换样式对象。
247
250
 
248
251
  ```js
249
- var postcss = require('postcss-js');
250
- var prefixer = postcss.sync([ require('autoprefixer') ]);
252
+ var postcss = require('postcss-js')
253
+ var prefixer = postcss.sync([ require('autoprefixer') ])
251
254
 
252
- prefixer({ display: 'flex' }); //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
255
+ prefixer({ display: 'flex' }) //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
253
256
  ```
254
257
 
255
258
  [`postcss-js`]: https://github.com/postcss/postcss-js
@@ -276,19 +279,19 @@ prefixer({ display: 'flex' }); //=> { display: ['-webkit-box', '-webkit-flex', '
276
279
  对于其它的应用环境,你可以使用 JS API:
277
280
 
278
281
  ```js
279
- const fs = require('fs');
280
- const postcss = require('postcss');
281
- const precss = require('precss');
282
- const autoprefixer = require('autoprefixer');
282
+ const autoprefixer = require('autoprefixer')
283
+ const postcss = require('postcss')
284
+ const precss = require('precss')
285
+ const fs = require('fs')
283
286
 
284
287
  fs.readFile('src/app.css', (err, css) => {
285
- postcss([precss, autoprefixer])
286
- .process(css, { from: 'src/app.css', to: 'dest/app.css' })
287
- .then(result => {
288
- fs.writeFile('dest/app.css', result.css);
289
- if ( result.map ) fs.writeFile('dest/app.css.map', result.map);
290
- });
291
- });
288
+ postcss([precss, autoprefixer])
289
+ .process(css, { from: 'src/app.css', to: 'dest/app.css' })
290
+ .then(result => {
291
+ fs.writeFile('dest/app.css', result.css)
292
+ if ( result.map ) fs.writeFile('dest/app.css.map', result.map)
293
+ })
294
+ })
292
295
  ```
293
296
 
294
297
  阅读 [PostCSS API 文档] 获取更多有关 JS API 的信息.
package/README.md CHANGED
@@ -15,6 +15,11 @@ PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba,
15
15
  and JetBrains. The [Autoprefixer] PostCSS plugin is one of the most popular
16
16
  CSS processors.
17
17
 
18
+ PostCSS takes a CSS file and provides an API to analyze and modify its rules
19
+ (by transforming them into an [Abstract Syntax Tree]).
20
+ This API can then be used by [plugins] to do a lot of useful things,
21
+ e.g. to find errors automatically insert vendor prefixes.
22
+
18
23
  **Support / Discussion:** [Gitter](https://gitter.im/postcss/postcss)<br>
19
24
  **Twitter account:** [@postcss](https://twitter.com/postcss)<br>
20
25
  **VK.com page:** [postcss](https://vk.com/postcss)<br>
@@ -24,7 +29,9 @@ For PostCSS commercial support (consulting, improving the front-end culture
24
29
  of your company, PostCSS plugins), contact [Evil Martians](https://evilmartians.com/?utm_source=postcss)
25
30
  at <surrender@evilmartians.com>.
26
31
 
27
- [Autoprefixer]: https://github.com/postcss/autoprefixer
32
+ [Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
33
+ [Autoprefixer]: https://github.com/postcss/autoprefixer
34
+ [plugins]: https://github.com/postcss/postcss#plugins
28
35
 
29
36
  <a href="https://evilmartians.com/?utm_source=postcss">
30
37
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
@@ -60,7 +67,6 @@ If you have any new ideas, [PostCSS plugin development] is really easy.
60
67
 
61
68
  * [`autoprefixer`] adds vendor prefixes, using data from Can I Use.
62
69
  * [`postcss-preset-env`] allows you to use future CSS features today.
63
- * [`postcss-image-set-polyfill`] emulates [`image-set`] function logic for all browsers
64
70
 
65
71
  ### Better CSS Readability
66
72
 
@@ -93,7 +99,6 @@ If you have any new ideas, [PostCSS plugin development] is really easy.
93
99
  * [`lost`] is a feature-rich `calc()` grid system.
94
100
  * [`rtlcss`] mirrors styles for right-to-left locales.
95
101
 
96
- [`postcss-image-set-polyfill`]: https://github.com/SuperOl3g/postcss-image-set-polyfill
97
102
  [PostCSS plugin development]: https://github.com/postcss/postcss/blob/master/docs/writing-a-plugin.md
98
103
  [`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg
99
104
  [`postcss-preset-env`]: https://github.com/jonathantneal/postcss-preset-env
@@ -114,7 +119,6 @@ If you have any new ideas, [PostCSS plugin development] is really easy.
114
119
  [`css-modules`]: https://github.com/css-modules/css-modules
115
120
  [`colorguard`]: https://github.com/SlexAxton/css-colorguard
116
121
  [`stylelint`]: https://github.com/stylelint/stylelint
117
- [`image-set`]: https://drafts.csswg.org/css-images-4/#image-set-notation
118
122
  [`stylefmt`]: https://github.com/morishitter/stylefmt
119
123
  [`cssnano`]: http://cssnano.co
120
124
  [`precss`]: https://github.com/jonathantneal/precss
@@ -133,6 +137,7 @@ you can write a parser and/or stringifier to extend PostCSS.
133
137
  * [`postcss-syntax`] switch syntax automatically by file extensions.
134
138
  * [`postcss-html`] parsing styles in `<style>` tags of HTML-like files.
135
139
  * [`postcss-markdown`] parsing styles in code blocks of Markdown files.
140
+ * [`postcss-jsx`] parsing CSS in template / object literals of source files.
136
141
  * [`postcss-styled`] parsing CSS in template literals of source files.
137
142
  * [`postcss-scss`] allows you to work with SCSS
138
143
  *(but does not compile SCSS to CSS)*.
@@ -152,6 +157,7 @@ you can write a parser and/or stringifier to extend PostCSS.
152
157
  [`postcss-syntax`]: https://github.com/gucong3000/postcss-syntax
153
158
  [`postcss-html`]: https://github.com/gucong3000/postcss-html
154
159
  [`postcss-markdown`]: https://github.com/gucong3000/postcss-markdown
160
+ [`postcss-jsx`]: https://github.com/gucong3000/postcss-jsx
155
161
  [`postcss-styled`]: https://github.com/gucong3000/postcss-styled
156
162
  [`postcss-scss`]: https://github.com/postcss/postcss-scss
157
163
  [`postcss-sass`]: https://github.com/AleshaOleg/postcss-sass
@@ -187,28 +193,28 @@ Use [`postcss-loader`] in `webpack.config.js`:
187
193
 
188
194
  ```js
189
195
  module.exports = {
190
- module: {
191
- rules: [
192
- {
193
- test: /\.css$/,
194
- exclude: /node_modules/,
195
- use: [
196
- {
197
- loader: 'style-loader',
198
- },
199
- {
200
- loader: 'css-loader',
201
- options: {
202
- importLoaders: 1,
203
- }
204
- },
205
- {
206
- loader: 'postcss-loader'
207
- }
208
- ]
196
+ module: {
197
+ rules: [
198
+ {
199
+ test: /\.css$/,
200
+ exclude: /node_modules/,
201
+ use: [
202
+ {
203
+ loader: 'style-loader',
204
+ },
205
+ {
206
+ loader: 'css-loader',
207
+ options: {
208
+ importLoaders: 1,
209
209
  }
210
+ },
211
+ {
212
+ loader: 'postcss-loader'
213
+ }
210
214
  ]
211
- }
215
+ }
216
+ ]
217
+ }
212
218
  }
213
219
  ```
214
220
 
@@ -216,10 +222,10 @@ Then create `postcss.config.js`:
216
222
 
217
223
  ```js
218
224
  module.exports = {
219
- plugins: [
220
- require('precss'),
221
- require('autoprefixer')
222
- ]
225
+ plugins: [
226
+ require('precss'),
227
+ require('autoprefixer')
228
+ ]
223
229
  }
224
230
  ```
225
231
 
@@ -230,16 +236,16 @@ module.exports = {
230
236
  Use [`gulp-postcss`] and [`gulp-sourcemaps`].
231
237
 
232
238
  ```js
233
- gulp.task('css', function () {
234
- var postcss = require('gulp-postcss');
235
- var sourcemaps = require('gulp-sourcemaps');
236
-
237
- return gulp.src('src/**/*.css')
238
- .pipe( sourcemaps.init() )
239
- .pipe( postcss([ require('precss'), require('autoprefixer') ]) )
240
- .pipe( sourcemaps.write('.') )
241
- .pipe( gulp.dest('build/') );
242
- });
239
+ gulp.task('css', () => {
240
+ const postcss = require('gulp-postcss')
241
+ const sourcemaps = require('gulp-sourcemaps')
242
+
243
+ return gulp.src('src/**/*.css')
244
+ .pipe( sourcemaps.init() )
245
+ .pipe( postcss([ require('precss'), require('autoprefixer') ]) )
246
+ .pipe( sourcemaps.write('.') )
247
+ .pipe( gulp.dest('build/') )
248
+ })
243
249
  ```
244
250
 
245
251
  [`gulp-sourcemaps`]: https://github.com/floridoo/gulp-sourcemaps
@@ -266,10 +272,10 @@ To apply PostCSS plugins to React Inline Styles, JSS, Radium
266
272
  and other [CSS-in-JS], you can use [`postcss-js`] and transforms style objects.
267
273
 
268
274
  ```js
269
- var postcss = require('postcss-js');
270
- var prefixer = postcss.sync([ require('autoprefixer') ]);
275
+ var postcss = require('postcss-js')
276
+ var prefixer = postcss.sync([ require('autoprefixer') ])
271
277
 
272
- prefixer({ display: 'flex' }); //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
278
+ prefixer({ display: 'flex' }) //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
273
279
  ```
274
280
 
275
281
  [`postcss-js`]: https://github.com/postcss/postcss-js
@@ -296,19 +302,21 @@ prefixer({ display: 'flex' }); //=> { display: ['-webkit-box', '-webkit-flex', '
296
302
  For other environments, you can use the JS API:
297
303
 
298
304
  ```js
299
- const fs = require('fs');
300
- const postcss = require('postcss');
301
- const precss = require('precss');
302
- const autoprefixer = require('autoprefixer');
305
+ const autoprefixer = require('autoprefixer')
306
+ const postcss = require('postcss')
307
+ const precss = require('precss')
308
+ const fs = require('fs')
303
309
 
304
310
  fs.readFile('src/app.css', (err, css) => {
305
- postcss([precss, autoprefixer])
306
- .process(css, { from: 'src/app.css', to: 'dest/app.css' })
307
- .then(result => {
308
- fs.writeFile('dest/app.css', result.css);
309
- if ( result.map ) fs.writeFile('dest/app.css.map', result.map);
310
- });
311
- });
311
+ postcss([precss, autoprefixer])
312
+ .process(css, { from: 'src/app.css', to: 'dest/app.css' })
313
+ .then(result => {
314
+ fs.writeFile('dest/app.css', result.css, () => true)
315
+ if ( result.map ) {
316
+ fs.writeFile('dest/app.css.map', result.map, () => true)
317
+ }
318
+ })
319
+ })
312
320
  ```
313
321
 
314
322
  Read the [PostCSS API documentation] for more details about the JS API.
@@ -104,7 +104,7 @@ So now lets look more closely on structures that play main role in PostCSS workf
104
104
 
105
105
  Lets look more closely on single token like `word`. As it was said each token represented as a list and follow such pattern.
106
106
 
107
- ```typescript
107
+ ```js
108
108
  const token = [
109
109
  // represents token type
110
110
  'word',
@@ -121,7 +121,7 @@ So now lets look more closely on structures that play main role in PostCSS workf
121
121
 
122
122
  // Next two numbers also optional and represent end position for multichar tokens like this one. Numbers follow same rule as was described above
123
123
  1, 10
124
- ];
124
+ ]
125
125
  ```
126
126
  There are many patterns how tokenization could be done, PostCSS motto is performance and simplicity. Tokenization is complex computing operation and take large amount of syntax analysis time ( ~90% ), that why PostCSS' Tokenizer looks dirty but it was optimized for speed. Any high-level constructs like classes could dramatically slow down tokenizer.
127
127
 
@@ -57,11 +57,11 @@ By wrapping your function in this method,
57
57
  you are hooking into a common plugin API:
58
58
 
59
59
  ```js
60
- module.exports = postcss.plugin('plugin-name', function (opts) {
61
- return function (root, result) {
62
- // Plugin code
63
- };
64
- });
60
+ module.exports = postcss.plugin('plugin-name', opts => {
61
+ return (root, result) => {
62
+ // Plugin code
63
+ }
64
+ })
65
65
  ```
66
66
 
67
67
  ## 2. Processing
@@ -78,19 +78,19 @@ different environments. You should test in (at least) Node.js [active LTS](https
78
78
  For example, use `fs.writeFile` instead of `fs.writeFileSync`:
79
79
 
80
80
  ```js
81
- postcss.plugin('plugin-sprite', function (opts) {
82
- return function (root, result) {
83
-
84
- return new Promise(function (resolve, reject) {
85
- var sprite = makeSprite();
86
- fs.writeFile(opts.file, function (err) {
87
- if ( err ) return reject(err);
88
- resolve();
89
- })
90
- });
91
-
92
- };
93
- });
81
+ postcss.plugin('plugin-sprite', opts => {
82
+ return (root, result) => {
83
+
84
+ return new Promise((resolve, reject) => {
85
+ const sprite = makeSprite()
86
+ fs.writeFile(opts.file, sprite, err => {
87
+ if (err) return reject(err)
88
+ resolve()
89
+ })
90
+ })
91
+
92
+ }
93
+ })
94
94
  ```
95
95
 
96
96
  ### 2.3. Set `node.source` for new nodes
@@ -102,18 +102,18 @@ So if you add new declaration based on some existing declaration, you should
102
102
  clone the existing declaration in order to save that original `source`.
103
103
 
104
104
  ```js
105
- if ( needPrefix(decl.prop) ) {
106
- decl.cloneBefore({ prop: '-webkit-' + decl.prop });
105
+ if (needPrefix(decl.prop)) {
106
+ decl.cloneBefore({ prop: '-webkit-' + decl.prop })
107
107
  }
108
108
  ```
109
109
 
110
110
  You can also set `source` directly, copying from some existing node:
111
111
 
112
112
  ```js
113
- if ( decl.prop === 'animation' ) {
114
- var keyframe = createAnimationByName(decl.value);
115
- keyframes.source = decl.source;
116
- decl.root().append(keyframes);
113
+ if (decl.prop === 'animation') {
114
+ const keyframe = createAnimationByName(decl.value)
115
+ keyframes.source = decl.source
116
+ decl.root().append(keyframes)
117
117
  }
118
118
  ```
119
119
 
@@ -134,8 +134,8 @@ in a mixin plugin) you should use `node.error` to create an error
134
134
  that includes source position:
135
135
 
136
136
  ```js
137
- if ( typeof mixins[name] === 'undefined' ) {
138
- throw decl.error('Unknown mixin ' + name, { plugin: 'postcss-mixins' });
137
+ if (typeof mixins[name] === 'undefined') {
138
+ throw decl.error('Unknown mixin ' + name, { plugin: 'postcss-mixins' })
139
139
  }
140
140
  ```
141
141
 
@@ -145,8 +145,8 @@ Do not print warnings with `console.log` or `console.warn`,
145
145
  because some PostCSS runner may not allow console output.
146
146
 
147
147
  ```js
148
- if ( outdated(decl.prop) ) {
149
- result.warn(decl.prop + ' is outdated', { node: decl });
148
+ if (outdated(decl.prop)) {
149
+ result.warn(decl.prop + ' is outdated', { node: decl })
150
150
  }
151
151
  ```
152
152
 
@@ -23,12 +23,12 @@ it can support plugins which accept a function, such as [`postcss-assets`]:
23
23
 
24
24
  ```js
25
25
  module.exports = [
26
- require('postcss-assets')({
27
- cachebuster: function (file) {
28
- return fs.statSync(file).mtime.getTime().toString(16);
29
- }
30
- })
31
- ];
26
+ require('postcss-assets')({
27
+ cachebuster: function (file) {
28
+ return fs.statSync(file).mtime.getTime().toString(16)
29
+ }
30
+ })
31
+ ]
32
32
  ```
33
33
 
34
34
  [`postcss-assets`]: https://github.com/borodean/postcss-assets
@@ -43,7 +43,7 @@ writing to disk (for example, a gulp transform), you should set both options
43
43
  to point to the same file:
44
44
 
45
45
  ```js
46
- processor.process({ from: file.path, to: file.path });
46
+ processor.process({ from: file.path, to: file.path })
47
47
  ```
48
48
 
49
49
  ### 2.2. Use only the asynchronous API
@@ -53,8 +53,8 @@ The synchronous API is provided only for debugging, is slower,
53
53
  and can’t work with asynchronous plugins.
54
54
 
55
55
  ```js
56
- processor.process(opts).then(function (result) {
57
- // processing is finished
56
+ processor.process(opts).then(result => {
57
+ // processing is finished
58
58
  });
59
59
  ```
60
60
 
@@ -75,13 +75,13 @@ as the runner can be used by developers who are not familiar with JavaScript.
75
75
  Instead, handle such errors gracefully:
76
76
 
77
77
  ```js
78
- processor.process(opts).catch(function (error) {
79
- if ( error.name === 'CssSyntaxError' ) {
80
- process.stderr.write(error.message + error.showSourceCode());
81
- } else {
82
- throw error;
83
- }
84
- });
78
+ processor.process(opts).catch(error => {
79
+ if (error.name === 'CssSyntaxError') {
80
+ process.stderr.write(error.message + error.showSourceCode())
81
+ } else {
82
+ throw error
83
+ }
84
+ })
85
85
  ```
86
86
 
87
87
  ### 3.2. Display `result.warnings()`
@@ -89,9 +89,9 @@ processor.process(opts).catch(function (error) {
89
89
  PostCSS runners must output warnings from `result.warnings()`:
90
90
 
91
91
  ```js
92
- result.warnings().forEach(function (warn) {
93
- process.stderr.write(warn.toString());
94
- });
92
+ result.warnings().forEach(warn => {
93
+ process.stderr.write(warn.toString())
94
+ })
95
95
  ```
96
96
 
97
97
  See also [postcss-log-warnings] and [postcss-messages] plugins.
@@ -106,8 +106,8 @@ PostCSS runners must provide an option to save the source map in a different
106
106
  file:
107
107
 
108
108
  ```js
109
- if ( result.map ) {
110
- fs.writeFile(opts.to + '.map', result.map.toString());
109
+ if (result.map) {
110
+ fs.writeFile(opts.to + '.map', result.map.toString())
111
111
  }
112
112
  ```
113
113
 
@@ -13,17 +13,17 @@ If you don’t want the map inlined, you can set `map.inline: false`.
13
13
 
14
14
  ```js
15
15
  processor
16
- .process(css, {
17
- from: 'app.sass.css',
18
- to: 'app.css',
19
- map: { inline: false },
20
- })
21
- .then(function (result) {
22
- result.map //=> '{ "version":3,
23
- // "file":"app.css",
24
- // "sources":["app.sass"],
25
- // "mappings":"AAAA,KAAI" }'
26
- });
16
+ .process(css, {
17
+ from: 'app.sass.css',
18
+ to: 'app.css',
19
+ map: { inline: false }
20
+ })
21
+ .then(result => {
22
+ result.map //=> '{ "version":3,
23
+ // "file":"app.css",
24
+ // "sources":["app.sass"],
25
+ // "mappings":"AAAA,KAAI" }'
26
+ })
27
27
  ```
28
28
 
29
29
  If PostCSS finds source maps from a previous transformation,