jsx-eslint/eslint-plugin-react

`display-name` `ignoreTranspilerName` is too strict

Open

#1,165 建立於 2017年5月1日

在 GitHub 查看
 (11 留言) (4 反應) (3 負責人)JavaScript (2,797 fork)batch import
help wantednew rulequestion

倉庫指標

Star
 (8,630 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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)

貢獻者指南