Skip to content

refactor: rename 'hooks-extra/no-useless-custom-hooks' to 'hooks-extra/no-unnecessary-use-prefix' #996

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

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.34.2-beta.3
1.35.0-next.0
5 changes: 3 additions & 2 deletions apps/website/content/docs/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ full: true

| Rule | Replaced by | Deprecated in |
| :--------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- | :------------ |
| [`ensure-custom-hooks-using-other-hooks`](/docs/rules/hooks-extra-no-useless-custom-hooks) | [`no-useless-custom-hooks`](/docs/rules/hooks-extra-no-useless-custom-hooks) | 1.13.0 |
| [`ensure-custom-hooks-using-other-hooks`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | [`no-unnecessary-use-prefix`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | 1.13.0 |
| [`ensure-forward-ref-using-ref`](/docs/rules/ensure-forward-ref-using-ref) | [`no-useless-forward-ref`](/docs/rules/no-useless-forward-ref) | 1.33.0 |
| [`ensure-use-callback-has-non-empty-deps`](/docs/rules/hooks-extra-ensure-use-callback-has-non-empty-deps) | [`no-unnecessary-use-callback`](/docs/rules/hooks-extra-no-unnecessary-use-callback) | 1.13.0 |
| [`ensure-use-memo-has-non-empty-deps`](/docs/rules/hooks-extra-ensure-use-memo-has-non-empty-deps) | [`no-unnecessary-use-memo`](/docs/rules/hooks-extra-no-unnecessary-use-memo) | 1.13.0 |
Expand All @@ -17,7 +17,8 @@ full: true
| [`no-children-in-void-dom-elements`](/docs/rules/dom-no-children-in-void-dom-elements) | [`no-void-elements-with-children`](/docs/rules/dom-no-void-elements-with-children) | 1.22.0 |
| [`no-complicated-conditional-rendering`](/docs/rules/no-complicated-conditional-rendering) | [`no-complex-conditional-rendering`](/docs/rules/no-complex-conditional-rendering) | 1.6.0 |
| [`no-nested-components`](/docs/rules/no-nested-components) | [`no-nested-component-definitions`](/docs/rules/no-nested-component-definitions) | 1.34.0 |
| [`no-redundant-custom-hook`](/docs/rules/hooks-extra-no-useless-custom-hooks) | [`no-useless-custom-hooks`](/docs/rules/hooks-extra-no-useless-custom-hooks) | 1.21.0 |
| [`no-redundant-custom-hook`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | [`no-unnecessary-use-prefix`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | 1.21.0 |
| [`no-useless-custom-hooks`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | [`no-unnecessary-use-prefix`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | 1.21.0 |

## Presets

Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/docs/rules/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"hooks-extra-no-direct-set-state-in-use-layout-effect",
"hooks-extra-no-unnecessary-use-callback",
"hooks-extra-no-unnecessary-use-memo",
"hooks-extra-no-useless-custom-hooks",
"hooks-extra-no-unnecessary-use-prefix",
"hooks-extra-prefer-use-state-lazy-initialization",
"---Naming Convention Rules---",
"naming-convention-component-name",
Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/docs/rules/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ full: true
| [`no-direct-set-state-in-use-layout-effect`](./hooks-extra-no-direct-set-state-in-use-layout-effect) | 0️⃣ | `🔍` | Disallow direct calls to the `set` function of `useState` in `useLayoutEffect`. |
| [`no-unnecessary-use-callback`](./hooks-extra-no-unnecessary-use-callback) | 0️⃣ | `🔍` | Disallow unnecessary usage of `useCallback`. |
| [`no-unnecessary-use-memo`](./hooks-extra-no-unnecessary-use-memo) | 0️⃣ | `🔍` | Disallow unnecessary usage of `useMemo`. |
| [`no-useless-custom-hooks`](./hooks-extra-no-useless-custom-hooks) | 1️⃣ | `🔍` | Enforces custom Hooks to use at least one other Hook inside. |
| [`no-unnecessary-use-prefix`](./hooks-extra-no-unnecessary-use-prefix) | 1️⃣ | `🔍` | Enforces custom Hooks to use at least one other Hook inside. |
| [`prefer-use-state-lazy-initialization`](./hooks-extra-prefer-use-state-lazy-initialization) | 1️⃣ | `🔍` | Enforces function calls made inside `useState` to be wrapped in an `initializer function`. |

## Naming Convention Rules
Expand Down
9 changes: 7 additions & 2 deletions apps/website/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,17 @@ const config = {
},
{
source: "/docs/rules/hooks-extra-ensure-custom-hooks-using-other-hooks",
destination: "/docs/rules/hooks-extra-no-useless-custom-hooks",
destination: "/docs/rules/hooks-extra-no-unnecessary-use-prefix",
permanent: true,
},
{
source: "/docs/rules/hooks-extra-no-redundant-custom-hook",
destination: "/docs/rules/hooks-extra-no-useless-custom-hooks",
destination: "/docs/rules/hooks-extra-no-unnecessary-use-prefix",
permanent: true,
},
{
source: "/docs/rules/hooks-extra-no-useless-custom-hooks",
destination: "/docs/rules/hooks-extra-no-unnecessary-use-prefix",
permanent: true,
},
];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/monorepo",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"private": true,
"description": "Monorepo for eslint-plugin-react-[x, dom, web-api, hooks-extra, naming-convention].",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/core",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
"homepage": "https://github.com/Rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-debug",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's ESLint plugin for debugging related rules.",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-dom",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's ESLint plugin for React DOM related rules.",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-hooks-extra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default tseslint.config({
},
rules: {
// Put rules you want to override here
"react-hooks-extra/no-useless-custom-hooks": "warn",
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
},
});
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-hooks-extra",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
"keywords": [
"react",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export const name = "react-hooks-extra/recommended";

export const rules = {
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
"react-hooks-extra/no-useless-custom-hooks": "warn",
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
"react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
} as const satisfies RulePreset;
14 changes: 8 additions & 6 deletions packages/plugins/eslint-plugin-react-hooks-extra/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import noDirectSetStateInUseEffect from "./rules/no-direct-set-state-in-use-effe
import noDirectSetStateInUseLayoutEffect from "./rules/no-direct-set-state-in-use-layout-effect";
import noUnnecessaryUseCallback from "./rules/no-unnecessary-use-callback";
import noUnnecessaryUseMemo from "./rules/no-unnecessary-use-memo";
import noUselessCustomHooks from "./rules/no-useless-custom-hooks";
import noUnnecessaryUsePrefix from "./rules/no-unnecessary-use-prefix";
import preferUseStateLazyInitialization from "./rules/prefer-use-state-lazy-initialization";

export const plugin = {
Expand All @@ -16,17 +16,19 @@ export const plugin = {
"no-direct-set-state-in-use-layout-effect": noDirectSetStateInUseLayoutEffect,
"no-unnecessary-use-callback": noUnnecessaryUseCallback,
"no-unnecessary-use-memo": noUnnecessaryUseMemo,
"no-useless-custom-hooks": noUselessCustomHooks,
"no-unnecessary-use-prefix": noUnnecessaryUsePrefix,
"prefer-use-state-lazy-initialization": preferUseStateLazyInitialization,

// Part: deprecated rules
/** @deprecated Use `no-useless-custom-hooks` instead */
"ensure-custom-hooks-using-other-hooks": noUselessCustomHooks,
/** @deprecated Use `no-unnecessary-use-prefix` instead */
"ensure-custom-hooks-using-other-hooks": noUnnecessaryUsePrefix,
/** @deprecated Use `no-unnecessary-use-callback` instead */
"ensure-use-callback-has-non-empty-deps": noUnnecessaryUseCallback,
/** @deprecated Use `no-unnecessary-use-memo` instead */
"ensure-use-memo-has-non-empty-deps": noUnnecessaryUseMemo,
/** @deprecated Use `no-useless-custom-hooks` instead */
"no-redundant-custom-hook": noUselessCustomHooks,
/** @deprecated Use `no-unnecessary-use-prefix` instead */
"no-redundant-custom-hook": noUnnecessaryUsePrefix,
/** @deprecated Use `no-unnecessary-use-prefix` instead */
"no-useless-custom-hooks": noUnnecessaryUsePrefix,
},
} as const;
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: no-useless-custom-hooks
title: no-unnecessary-use-prefix
---

**Full Name in `eslint-plugin-react-hooks-extra`**

```plain copy
react-hooks-extra/no-useless-custom-hooks
react-hooks-extra/no-unnecessary-use-prefix
```

**Full Name in `@eslint-react/eslint-plugin`**

```plain copy
@eslint-react/hooks-extra/no-useless-custom-hooks
@eslint-react/hooks-extra/no-unnecessary-use-prefix
```

**Features**
Expand All @@ -26,7 +26,7 @@ react-hooks-extra/no-useless-custom-hooks

## What it does

Enforces custom Hooks to use at least one other Hook inside.
Enforces that a function with the `use` prefix should call at least one Hook inside of it.

If your function doesn’t call any Hooks, avoid the `use` prefix. Instead, write it as a regular function without the `use` prefix. For example, `useSorted` below doesn’t call Hooks, so call it `getSorted` instead:

Expand Down Expand Up @@ -120,8 +120,8 @@ function useAuth() {

## Implementation

- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-useless-custom-hooks.ts)
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-useless-custom-hooks.spec.ts)
- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-prefix.ts)
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-prefix.spec.ts)

## Further Reading

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tsx from "dedent";

import { allValid, ruleTester } from "../../../../../test";
import rule, { RULE_NAME } from "./no-useless-custom-hooks";
import rule, { RULE_NAME } from "./no-unnecessary-use-prefix";

ruleTester.run(RULE_NAME, rule, {
invalid: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { CamelCase } from "string-ts";

import { createRule } from "../utils";

export const RULE_NAME = "no-useless-custom-hooks";
export const RULE_NAME = "no-unnecessary-use-prefix";

export const RULE_FEATURES = [
"CHK",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-naming-convention",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's ESLint plugin for naming convention related rules.",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-web-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-web-api",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin-react-x/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-x",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/eslint-plugin",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "More than 80 high-quality linting rules for writing better React code.",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin/src/configs/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const rules = {
"@eslint-react/hooks-extra/no-direct-set-state-in-use-layout-effect": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-callback": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-memo": "warn",
"@eslint-react/hooks-extra/no-useless-custom-hooks": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-prefix": "warn",
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",

"@eslint-react/naming-convention/component-name": "warn",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/eslint-plugin/src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const rules = {
...dom.rules,
...webApi.rules,
"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
"@eslint-react/hooks-extra/no-useless-custom-hooks": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-prefix": "warn",
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
} as const satisfies RulePreset;

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/shared",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's Shared constants and functions.",
"homepage": "https://github.com/Rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/ast/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/ast",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's TSESTree AST utility module.",
"homepage": "https://github.com/Rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/eff/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/eff",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "JavaScript and TypeScript utilities (previously some re-exports of the effect library).",
"homepage": "https://github.com/Rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/jsx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/jsx",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
"homepage": "https://github.com/Rel1cx/eslint-react",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/var/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eslint-react/var",
"version": "1.34.2-beta.3",
"version": "1.35.0-next.0",
"description": "ESLint React's TSESTree AST utility module for static analysis of variables.",
"homepage": "https://github.com/Rel1cx/eslint-react",
"bugs": {
Expand Down
Loading