You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# ADR 0000: Choice between "useless" and "unnecessary" in rule naming
2
+
3
+
## Status
4
+
5
+
Accepted
6
+
7
+
## Context
8
+
9
+
When naming rules related to identifying redundant or non-functional code (e.g., in linting or static analysis), the terms "useless" and "unnecessary" both convey a sense of superfluity. However, their nuanced semantic differences could lead to ambiguity if misapplied. For example, a `forwardRef`-wrapped component that is never passed a `ref` is entirely without purpose, but other scenarios might involve optional code that is only redundant in specific contexts. A consistent naming convention is needed to ensure clarity and accuracy in rule documentation and error messaging.
10
+
11
+
## Decision
12
+
13
+
Use "useless" to describe code that has no functional purpose under any circumstances (e.g., a `forwardRef` with no `ref` usage).
14
+
Use "unnecessary" to describe code that is contextually redundant but not strictly non-functional (e.g., an `useEffect` that runs event-specific logic).
15
+
16
+
## Consequences
17
+
18
+
- Improved clarity: Developers can better discern whether code is strictly non-functional ("useless") or situationally redundant ("unnecessary").
19
+
20
+
- Consistency: Rules and error messages will align with precise semantic definitions.
21
+
22
+
- Potential learning curve: Teams may need documentation to understand the distinction initially.
23
+
24
+
## Alternatives Considered
25
+
26
+
1. Using only "unnecessary" for all cases:
27
+
- Rejected because it conflates fundamentally distinct scenarios (strictly non-functional vs. contextually redundant), reducing diagnostic precision.
28
+
29
+
2. Using only "useless" for all cases:
30
+
- Rejected because it could mislabel code that is optional but valid in other contexts, leading to confusion or dismissal of valid feedback.
# ADR 0001: Rename ensure-forward-ref-using-ref to no-useless-forward-ref
2
+
3
+
## Status
4
+
5
+
Accepted
6
+
7
+
## Context
8
+
9
+
The rule `ensure-forward-ref-using-ref` detects React `forwardRef`-wrapped components that never receive a `ref` prop. This matches the "useless" criteria defined in ADR 0000, as such components serve no functional purpose. The current name lacks alignment with our established `no-<category>-<term>` naming convention and semantic categorization.
10
+
11
+
## Decision
12
+
13
+
Rename the rule to **`no-useless-forward-ref`** to:
14
+
15
+
1. Adhere to the `no-<category>-<term>` pattern used in similar rules (e.g., `no-useless-state`).
16
+
2. Reflect the strict "useless" classification per ADR 0000, since unreferenced `forwardRef` components are functionally inert.
17
+
18
+
## Consequences
19
+
20
+
-**Consistency**: Aligns with existing rule taxonomy and terminology.
21
+
-**Clarity**: Clearly signals the rule's focus on non-functional code.
22
+
-**Documentation updates**: Requires migration guides and rule metadata changes.
23
+
24
+
## Alternatives Considered
25
+
26
+
Using `no-unnecessary-forward-ref`:
27
+
28
+
- Rejected because "unnecessary" implies optional redundancy, whereas unreferenced `forwardRef` has zero runtime utility.
29
+
30
+
## Related ADRs
31
+
32
+
-[ADR 0000: Choice between "useless" and "unnecessary" in rule naming](./0000-choice-between-useless-and-unnecessary-in-rule-naming.md)
|[`avoid-shorthand-boolean`](./avoid-shorthand-boolean)| 0️⃣ |`🔍``🔧`| Enforces the use of explicit boolean values for boolean attributes. ||
22
22
|[`avoid-shorthand-fragment`](./avoid-shorthand-fragment)| 0️⃣ |`🔍`| Enforces the use of explicit `<Fragment>` components instead of the shorthand `<>` or `</>` syntax. ||
23
-
|[`ensure-forward-ref-using-ref`](./ensure-forward-ref-using-ref)| 1️⃣ |`🔍`| Requires that components wrapped with `forwardRef` must have a `ref` parameter. ||
23
+
|[`no-useless-forward-ref`](./no-useless-forward-ref)| 1️⃣ |`🔍`| Requires that components wrapped with `forwardRef` must have a `ref` parameter. ||
0 commit comments