-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Closed
Description
In [email protected] (specifically 1bc8cab), react/function-component-definition was configured to allow only function expressions for named components:
javascript/packages/eslint-config-airbnb/rules/react.js
Lines 526 to 531 in 1bc8cab
| // 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.
slifty, targumon, luanbernardes, oottinger, j-m and 31 more
Metadata
Metadata
Assignees
Labels
No labels