Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Hooks support and entry point #18

Merged

Conversation

arcticicestudio
Copy link
Contributor

Resolves #17

All React based "Arctic Ice Studio" projects using at least React
version 16.8 (1) that introduced the awesome "Hooks" (2). Since this
comes with an entire new API (3) that follows new design/usage pattern,
the React team created an official "Hooks" ESLint plugin (4) to help to
adhere to the "Rules of Hooks" (5).

Since the `@arcticicestudio/eslint-config` package already includes
support for React and "JSX A11Y", support for "Hooks" have also been
added through a new shareable configuration entry point that

- enables the `react-hooks` plugin.
- configures both currently available rules `react-hooks/rules-of-hooks`
  and `react-hooks/exhaustive-deps` rule to `error` level.

Since "Hooks" make more use of arrow functions the
`react/jsx-no-bind` rule (6) has been adjusted to prevent compatibility
problems by setting the `ignoreDOMComponents` and
`allowArrowFunctions` options to `true`.
Also the `react/display-name` rule has been disabled in order to prevent
problems due to missing "display names" for "functional components" that
make use of "Hooks" instead of being declared as a class component.

The new entry point is available as
`@arcticicestudio/eslint-config/react-hooks` and can be composed with
all other available entry points (7) to inherit their rules.

This feature adds the `eslint-plugin-react-hooks` package as new peer
dependency for `@arcticicestudio/eslint-config`.

References:
  (1) https://reactjs.org/blog/2019/02/06/react-v16.8.0.html
  (2) https://reactjs.org/docs/hooks-intro.html
  (3) https://reactjs.org/docs/hooks-reference.html
  (4) https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
  (5) https://reactjs.org/docs/hooks-rules.html
  (6) https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
  (7) https://github.com/arcticicestudio/styleguide-javascript/blob/develop/packages/%40arcticicestudio/eslint-config/README.md#entry-points

GH-17
@arcticicestudio arcticicestudio merged commit 833cc51 into develop Aug 20, 2019
@arcticicestudio arcticicestudio deleted the feature/gh-17-react-hooks-support-entry-point branch August 20, 2019 08:47
@arcticicestudio arcticicestudio removed their assignment Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React Hooks support and entry point
2 participants