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:
displayName (ignoreTranspilerName: true)displayName on React.createClasses (ignoreTranspilerName: false)As well as cover these additional use cases:
displayName? (i don't really care about this one, but it seems useful for consistency)@yannickcr @lencioni @EvHaus thoughts?
Voting for option 2!
These aren't exclusive options, they're use cases :-) also there's two lists, which "option 2" do you have in mind?
@ljharb if it can be inferred then I think not explicitly setting a displayName is fine. Anonymous functions or classes though should still be required to have a display name.
export default function() {
return <span>{'foo'}</span>;
}
This should throw an error.
Yes, that's what it's already doing - but in my example, I need "always require an explicit name", because I never want to rely on name inference.
@ljharb yeah you're talking about having three options right? I agree to that.
This is the one that I like that's why I said I like option 2. Now I just realized it could mean the second item in both those lists. Hahaha. ๐ญ
How about "always" | "only-unnamed" | "only-create-class"?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ โ always โ only-unnamed โ only-create-class โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโค
โ function Cat() {} โ fail โ pass โ pass โ
โ class Cat extends Component {} โ fail โ pass โ pass โ
โ export default () => <></> โ fail โ fail โ pass โ
โ exports.Cat = () => <></> โ fail โ fail โ pass โ
โ const Cat = createClass({}) โ fail โ fail โ fail โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโ
@golopot exports.Cat = () => {} doesn't have inference; maybe add const Cat = () => {} which should be fail/fail/pass?