Skip to content

Commit

Permalink
Update rules.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 committed May 7, 2020
1 parent 0376cf9 commit 5152a63
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/developer-guide/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ You should make use of the:

#### PostCSS API

Use the [PostCSS API](https://api.postcss.org/) to navigate and analyze the CSS syntax tree. We recommend using the `walk` iterators (e.g. `walkDecls`), rather than using `forEach` to loop through the nodes. Use `node.raws` instead of `node.raw()` when accessing raw strings from the [PostCSS AST](https://astexplorer.net/#/gist/ef718daf3e03f1d200b03dc5a550ec60/c8cbe9c6809a85894cebf3fb66de46215c377f1a).
Use the [PostCSS API](https://api.postcss.org/) to navigate and analyze the CSS syntax tree. We recommend using the `walk` iterators (e.g. `walkDecls`), rather than using `forEach` to loop through the nodes. If `forEach` is a better fit, you should explicitly check the `type` property of the `node` before attempting to access other properties. For example:

```js
const hasProperty = nodes.find(
({type, prop}) => type === "decl" && prop === propertyName
);
```

Use `node.raws` instead of `node.raw()` when accessing raw strings from the [PostCSS AST](https://astexplorer.net/#/gist/ef718daf3e03f1d200b03dc5a550ec60/c8cbe9c6809a85894cebf3fb66de46215c377f1a).

#### Construct-specific parsers

Expand Down

0 comments on commit 5152a63

Please sign in to comment.