mui / mui/material-ui

[docs-infra] Prevent to set `undefined` as a default value

Open
#41,139 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

scope: docs-infra type: enhancement
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Why not?

  /**
   * The height of the chart in px. If not defined, it takes the height of the parent element.
   */
  height: PropTypes.number,

It looks funny on the API page:

SCR-20240215-oysy

As far as I know, we only do this if it's null. undefined is the default "prop default value". In https://github.com/mui/material-ui/pull/41114 I try to improve its display.

If this change makes sense, then I think we should throw an error in docs-infra when the default is undefined, saying to remove it as redundant, to prevent future regressions.

Originally posted by @oliviertassinari in https://github.com/mui/mui-x/pull/11996#discussion_r1491248717

Search keywords:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the docs-infra handling for prop default values and compare the API-page example shown in the issue with the intended null behavior. Reproduce the displayed undefined default, then verify that docs-infra rejects redundant undefined defaults while still allowing null; no specific file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.