Skip to content

Releases: Gelio/tslint-react-hooks

Release v2.2.2

21 Mar 14:35
Compare
Choose a tag to compare

Changelog

  • Allow TSLint 6.x as a peerDependency

    This rule can not be used with TSLint 6.x.

Release v2.2.1

14 Jul 22:26
Compare
Choose a tag to compare

Changelog

  • Add support for optionally detecting hook calls from sources other than the React namespace
    (e.g. MyHooks.useHook).

    Usage is described in the README.

Release v2.1.0

19 Apr 13:48
Compare
Choose a tag to compare

A minor release. Fixes a bug that caused named function expressions not to be detected properly in some cases.

Changelog

  • Describe a workaround for ambiguous function expressions in the README

  • Detect and allow using hooks inside named function expressions

    const withHoc = <TProps extends object>(Component: ComponentType<TProps>) =>
      function WrappedComponent(props: TProps) {
        // Naming the function expression allows using hooks
        const [state] = useState();
        return <Component {...props} />;
      };

Release v2.0.0

12 Mar 21:02
3cd97c7
Compare
Choose a tag to compare

This release adds support for detecting rule violations whenever hooks are used after a possible early-return.

Changelog

  • Report violations whenever a React hook is used after an early return.

    For example, the following code sample now violates the rule:

    function MyComponent({ counter }) {
      if (counter > 5) {
        return <div>Counter is over 5</div>;
      }
    
      useEffect(() => {
        console.log('Counter is', counter);
      });
    
      return <div>{counter}</div>;
    }

Release v1.1.0

09 Feb 12:09
5c451b8
Compare
Choose a tag to compare

This minor release allows using hooks in function expression passed to React.memo and React.forwardRef.

Changelog

  • Allow using hooks inside React component decorators, such as React.memo or React.forwardRef.

    For example, the following code sample now does not violate the rule:

    const MyComponent = React.memo(props => {
      useEffect(() => {
        console.log('Counter changed');
      }, [props.value]);
    
      return <div>Counter: {props.value}</div>;
    });

Release v1.0.1

03 Feb 15:00
Compare
Choose a tag to compare
  • Add a section about development and testing to README

This release does not modify the source code of the rule. It has been published so that the README on npmjs.com matches the one on GitHub.

Release v1.0

03 Feb 14:51
Compare
Choose a tag to compare

The initial implementation of the rule.

The implementation was influenced by eslint-plugin-react-hooks.