jsx-eslint/eslint-plugin-react

`display-name` `ignoreTranspilerName` is too strict

Open

#1165 aperta il 1 mag 2017

Vedi su GitHub
 (11 commenti) (4 reazioni) (3 assegnatari)JavaScript (2797 fork)batch import
help wantednew rulequestion

Metriche repository

Star
 (8630 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

The purpose of ignoreTranspilerName is to ignore inferred names:

const SFC = () => <div />; // inferred name
const Foo = class extends React.Component {} // inferred name

It should not, however, ignore explicit names:

function SFC() { return <div />; } // explicit name
class Foo extends React.Component {} // explicit name

I think that the ignoreTranspilerName option should be deprecated, and replaced with new options that cover the current use cases:

  1. always require an explicit displayName (ignoreTranspilerName: true)
  2. only require an explicit displayName on React.createClasses (ignoreTranspilerName: false)

As well as cover these additional use cases:

  1. always require an explicit name - ie, an explicit displayName or a named function or named `class
  2. always require a name - either explicit, or ES6-inferred
  3. Never allow an explicit displayName? (i don't really care about this one, but it seems useful for consistency)

Guida contributor