# eslint-plugin-no-unnecessary-hook-definition

> [![eslint-plugin-no-unnecessary-hook-definition — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/eslint-plugin-no-unnecessary-hook-definition/main/eslint-plugin-no-unnecessary-hook-definition-Hero.png)](https://formi

Latest version **0.1.1** (published 2023-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-no-unnecessary-hook-definition
pnpm add eslint-plugin-no-unnecessary-hook-definition
yarn add eslint-plugin-no-unnecessary-hook-definition
bun add eslint-plugin-no-unnecessary-hook-definition
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-06-01 |
| First published | 2022-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (Unknown) |
| GitHub stars | 3 |
| Author | Formidable |
| Maintainers | scottianstewart, keithluchtel, ceceppa, robwalkerco, gksander, sarahformidable, scott-rippey, yankovalera, michaelmerrill, sarmeyer, mariano-formidable, carlospaelinck, ryan.roemer, formidable-owner, eastridge, exogen, jmcbee1, formidablelabs, carbonrobot, masiddee |
| Keywords | eslint, react, hooks, lint |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-no-unnecessary-hook-definition
- Repository: https://github.com/FormidableLabs/eslint-plugin-no-unnecessary-hook-definition
- Issues: https://github.com/FormidableLabs/eslint-plugin-no-unnecessary-hook-definition/issues
- npm.io page: https://npm.io/package/eslint-plugin-no-unnecessary-hook-definition

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2023-06-01
- 0.1.0 — 2022-10-25
- 0.0.4 — 2022-10-25
- 0.0.3 — 2022-10-25
- 0.0.2 — 2022-10-24
- 0.0.1 — 2022-10-24

## README

[![eslint-plugin-no-unnecessary-hook-definition — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/eslint-plugin-no-unnecessary-hook-definition/main/eslint-plugin-no-unnecessary-hook-definition-Hero.png)](https://formidable.com/open-source/)

`eslint-plugin-no-unnecessary-hook-definition`

This library contains a simple ESLint plugin with a single rule to disallow defining React "hooks" that perhaps shouldn't be considered "hooks". This library enforces the following rule:

> A function should only be considered a React "hook" (e.g., its name starts with `use`) if it calls another hook.

This rule ensures your codebase is not littered with "fake hooks" like the following:

```js
// ❌ This will get flagged
const useFirstName = (person) => {
  return person.firstName;
};
```

since this function, as an example, has no reliance on React or its hook ecosystem and is probably best declared as a plain 'ol function like `getFirstName`.

## Setup & Usage

Start by installing the plugin:

```sh
npm install -D eslint-plugin-no-unnecessary-hook-definition

# Or...

yarn add -D eslint-plugin-no-unnecessary-hook-definition
```

Then add the plugin to your `.eslintrc` configuration file in both the `plugins` and `rules` fields:

```json
{
  "plugins": ["no-unnecessary-hook-definition", "..."],
  "rules": {
    "no-unnecessary-hook-definition/rule": 2
  }
}
```

That's it! Happy coding!

---
_Source: https://npm.io/package/eslint-plugin-no-unnecessary-hook-definition · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
