jsx-eslint/eslint-plugin-react

require-default-props: Allow disabling "must have default value" warning but keeping "forbid defaults for required props"

Open

#3.660 geöffnet am 1. Dez. 2023

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.797 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (8.630 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Right now there doesn't seem to be a way to do this.

  • Having to specify a null/undefined default for a prop where you're perfectly fine with it being undefined when not specified feels a bit pointless
  • This is made worse for a prop where you want to allow null, because a required prop will fail runtime proptypes validation when its value is null (even if it's explicitly set to null

So I'd like to just ditch the part of having to specify default for optional props, but still prohibit setting defaults for required ones.

Contributor Guide