jsx-eslint/eslint-plugin-react

`display-name` `ignoreTranspilerName` is too strict

Open

#1.165 geöffnet am 1. Mai 2017

Auf GitHub ansehen
 (11 Kommentare) (4 Reaktionen) (3 zugewiesene Personen)JavaScript (2.797 Forks)batch import
help wantednew rulequestion

Repository-Metriken

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

Beschreibung

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)

Contributor Guide