Releases: Gelio/tslint-react-hooks
Release v2.2.2
Release v2.2.1
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
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
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
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
orReact.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
- 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
The initial implementation of the rule.
The implementation was influenced by eslint-plugin-react-hooks.