Skip to content

[linter] Add configuration option to specify hooks that return stable values #33382

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

Closed
wants to merge 1 commit into from

Conversation

jbrown215
Copy link
Contributor

@jbrown215 jbrown215 commented May 30, 2025

Summary:
This commit adds a way to configure the exhaustive deps linter to be aware of user-provided
hooks that return stable values. The configuration allows you to specify the hook name
and optionally a list of property names or indexes that are stable. If no properties
are provided then the outer return value is considered to be stable. If properties
are provided then we allow them to be destructured and determined to be stable.

Please let me know if you have any concerns about the configuration structure:

type StableValueHookConfig = Array<{
  name: string,
  propertiesOrIndexes: null | Array<string> | Array<number>
}>;

Stack created with Sapling. Best reviewed with ReviewStack.

@jbrown215 jbrown215 marked this pull request as draft May 30, 2025 15:05
@react-sizebot
Copy link

react-sizebot commented May 30, 2025

Comparing: ee76351...494e470

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 529.84 kB 529.84 kB = 93.52 kB 93.52 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 650.94 kB 650.94 kB = 114.65 kB 114.65 kB
facebook-www/ReactDOM-prod.classic.js = 675.89 kB 675.89 kB = 118.93 kB 118.93 kB
facebook-www/ReactDOM-prod.modern.js = 666.17 kB 666.17 kB = 117.32 kB 117.32 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 494e470

… values

Summary:
This commit adds a way to configure the exhaustive deps linter to be aware of user-provided
hooks that return stable values. The configuration allows you to specify the hook name
and optionally a list of property names or indexes that are stable. If no properties
are provided then the outer return value is considered to be stable. If properties
are provided then we allow them to be destructured and determined to be stable.

Please let me know if you have any concerns about the configuration structure:
```typescript
type StableValueHookConfig = Array<{
  name: string,
  propertiesOrIndexes: null | Array<string> | Array<number>
}>;
```
@jbrown215
Copy link
Contributor Author

Discussed offline. While some people prefer toomit the deps they know are stable, we're going to instead push people to include those deps anyway. It does not change semantics. This lint ru.e opens more points of failure

@jbrown215 jbrown215 closed this Jun 5, 2025
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.

3 participants