Skip to content

Commit

Permalink
Demonstrate state as optional in controller guidelines (#4910)
Browse files Browse the repository at this point in the history
## Explanation

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

In various examples in the controller guidelines, the `state` controller
option was not optional, even though there is a guideline that says it
should be. This commit updates the documentation so that it shown as
optional.

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

I discovered that the examples were incorrect when reviewing [this
PR](MetaMask/metamask-extension#28113 (comment)).

## Changelog

<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.

(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)

Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).

If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.

Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->

N/A

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
  • Loading branch information
mcmire authored Nov 30, 2024
1 parent a71a8a8 commit f11ea90
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/writing-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FooController extends BaseController</* ... */> {
state = {},
}: {
messenger: FooControllerMessenger;
state: Partial<FooControllerState>;
state?: Partial<FooControllerState>;
}) {
super({
// ...
Expand Down Expand Up @@ -87,7 +87,7 @@ class FooController extends BaseController</* ... */> {
state = {},
}: {
messenger: FooControllerMessenger;
state: Partial<FooControllerState>;
state?: Partial<FooControllerState>;
}) {
super({
name,
Expand Down Expand Up @@ -158,7 +158,7 @@ class FooController extends BaseController</* ... */> {
state = {},
}: {
messenger: FooControllerMessenger;
state: Partial<FooControllerState>;
state?: Partial<FooControllerState>;
},
isEnabled: boolean,
) {
Expand All @@ -177,7 +177,7 @@ class FooController extends BaseController</* ... */> {
isEnabled,
}: {
messenger: FooControllerMessenger;
state: Partial<FooControllerState>;
state?: Partial<FooControllerState>;
isEnabled: boolean;
}) {
// ...
Expand Down

0 comments on commit f11ea90

Please sign in to comment.