Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(styleguide): add section on chaining #6885

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions contributor_docs/documentation_style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Our community is large and diverse. Many people learn to code using p5.js, and a
- [Arrays](#arrays)
- [Functions](#functions)
- [Arrow Functions](#arrow-functions)
- [Chaining](#chaining)
- [Classes](#classes)
- [Assets](#assets)

Expand Down Expand Up @@ -1041,6 +1042,30 @@ function processImage(img) {
// Good.
[1, 2, 3].map((number) => number * number);
```
**[⬆ back to top](#table-of-contents)**

## Chaining

* Use individual function calls instead of function chaining.

> Why? To accommodate users who may not be familiar with the concept of function chaining.

```javascript
// Bad.
fill(0)
.strokeWeight(6)
.textSize(20);

// Bad.
fill(0).strokeWeight(6).textSize(20);

// Good.
fill(0);
strokeWeight(6);
textSize(20);
```

**[⬆ back to top](#table-of-contents)**

## Classes

Expand Down
Loading