jsx-eslint/eslint-plugin-react

react/boolean-prop-naming interface does not work

Open

#3.285 aberto em 9 de mai. de 2022

Ver no GitHub
 (14 comments) (21 reactions) (0 assignees)JavaScript (2.797 forks)batch import
enhancementhelp wantedtypescript

Métricas do repositório

Stars
 (8.630 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

The react/boolean-prop-naming rule does not work when using an interface with TypeScript but it works with a type

This shows an error like it should:

type Props = {
  done: boolean; // Shows error
}

This doesn't show an error like it should:

interface Props {
  done: boolean; // No error
}

My usage of the rule:

"react/boolean-prop-naming": [
      "error",
      {
        "rule": "^(is|has)[A-Z]([A-Za-z0-9]?)+",
        "message": "It is better if your prop ({{ propName }}) starts with `is` or `has`"
      }
    ],

Versions:

  • eslint - 8.15.0
  • eslint-plugin-react 7.29.4

Guia do colaborador