In [email protected] (specifically 1bc8cab), react/function-component-definition was configured to allow only function expressions for named components:
|
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md |
|
// TODO: investigate if setting namedComponents to expression vs declaration is problematic |
|
'react/function-component-definition': ['error', { |
|
namedComponents: 'function-expression', |
|
unnamedComponents: 'function-expression', |
|
}], |
This has the effect of disallowing function declarations:
function Foo() {
return <div />
}
While allowing only this style:
const Foo = function () {
return <div />
}
This seems like a configuration mistake, as the React style guide consistently uses function declarations for components (as does the ecosystem as a whole) and specifically points out that "relying on function name inference is discouraged". Let me know if you agree and I'll PR a fix.
In
[email protected](specifically 1bc8cab),react/function-component-definitionwas configured to allow only function expressions for named components:javascript/packages/eslint-config-airbnb/rules/react.js
Lines 526 to 531 in 1bc8cab
This has the effect of disallowing function declarations:
While allowing only this style:
This seems like a configuration mistake, as the React style guide consistently uses function declarations for components (as does the ecosystem as a whole) and specifically points out that "relying on function name inference is discouraged". Let me know if you agree and I'll PR a fix.