jsx-eslint/eslint-plugin-react

`display-name` `ignoreTranspilerName` is too strict

Open

#1,165 opened on 2017年5月1日

GitHub で見る
 (11 comments) (4 reactions) (3 assignees)JavaScript (8,630 stars) (2,797 forks)batch import
help wantednew rulequestion

説明

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)

コントリビューターガイド