Skip to content

Commit c867a27

Browse files
authored
Merge pull request #98062 from Expensify/marcaaron-remove-claudeisms
Remove AI-generated jargon from comments [No QA]
2 parents 2a780e5 + 9564b62 commit c867a27

32 files changed

Lines changed: 153 additions & 96 deletions

File tree

.claude/skills/coding-standards/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Coding standards for the Expensify App. Each standard is a standalone file in `r
5555
- [CONSISTENCY-14](rules/consistency-14-new-file-header.md) — Non-trivial new files start with a header description
5656
- [CONSISTENCY-15](rules/consistency-15-comment-why.md) — Comments explain why the code exists, not what it does
5757
- [CONSISTENCY-16](rules/consistency-16-plain-comment-style.md) — Write comments as plain, natural sentences
58+
- [CONSISTENCY-17](rules/consistency-17-no-ai-jargon.md) — No AI-generated jargon in code or comments
5859

5960
### Clean React Patterns
6061
- [CLEAN-REACT-PATTERNS-0](rules/clean-react-0-compiler.md) — React Compiler compliance
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
ruleId: CONSISTENCY-17
3+
title: No AI-generated jargon in code or comments
4+
---
5+
6+
## [CONSISTENCY-17] No AI-generated jargon in code or comments
7+
8+
### Reasoning
9+
10+
Certain phrases appear constantly in AI-generated code but rarely in code written by engineers. They make the codebase sound like it was written by a chatbot and should be replaced with plain, direct language.
11+
12+
### Banned phrases
13+
14+
| Phrase | Plain substitute |
15+
|--------|-----------------|
16+
| sentinel | placeholder, marker, guard entry |
17+
| fan out | send, make, dispatch, distribute |
18+
| carve out | set aside, exclude, separate |
19+
| defense in depth | extra guard, additional check |
20+
| belt and suspenders / belt-and-suspenders | extra safety check, redundant guard |
21+
| fresh evidence | new data, updated result |
22+
23+
### Incorrect
24+
25+
```ts
26+
// Fan out the request to every matching snapshot.
27+
function getSentinelValue() { ... }
28+
const fanOutRequests = () => { ... }
29+
30+
// Defense in depth: reject the value if it arrived stale.
31+
// Belt-and-suspenders check before writing.
32+
// Uses a sentinel to signal end-of-stream.
33+
```
34+
35+
### Correct
36+
37+
```ts
38+
// Send the request to every matching snapshot.
39+
function getPlaceholderValue() { ... }
40+
const sendDuplicateRequests = () => { ... }
41+
42+
// Additional guard: reject the value if it arrived stale.
43+
// Extra safety check before writing.
44+
// Uses a placeholder to signal end-of-stream.
45+
```
46+
47+
---
48+
49+
### Review Metadata
50+
51+
Flag when any added or modified code — including comments, function names, variable names, type names, or string literals — contains one of the banned phrases above.
52+
53+
**DO NOT flag if:**
54+
55+
- The phrase appears inside a quoted external API name, a third-party library identifier, or a value the codebase does not control (e.g. a server response field name)
56+
- The phrase is in a test description string that is directly testing behavior described by an external spec or API that uses the term

src/components/ConnectToHRFlow/index.ios.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function ConnectToHRFlow({setupLink, onDone}: ConnectToHRFlowProps) {
4040
hasOpened.current = true;
4141

4242
getShortLivedAuthTokenURL(setupLink)
43-
// CONST.DEEPLINK_BASE_URL is used as a sentinel so ASWebAuthenticationSession
43+
// CONST.DEEPLINK_BASE_URL is used as the redirect URL so ASWebAuthenticationSession
4444
// auto-dismisses when the flow redirects back to the app via deep link.
4545
.then((url) => {
4646
if (isDismissed.current) {

src/components/Modal/useSyncModalWithHistory/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ type UseSyncModalWithHistoryParams = {
2626
};
2727

2828
/**
29-
* Web: represents a `shouldHandleNavigationBack` modal's back-guard as a uniquely-tagged sentinel in the
29+
* Web: represents a `shouldHandleNavigationBack` modal's back-guard as a uniquely-tagged history entry in the
3030
* root navigator's `state.history` (dispatched via `TOGGLE_MODAL_WITH_HISTORY`). React Navigation's
3131
* `useLinking` mirrors the history length delta into the browser, so opening the modal pushes a browser
32-
* entry and browser Back removes it. The router consumes the sentinel on forward navigation
32+
* entry and browser Back removes it. The router consumes the guard entry on forward navigation
3333
* (history length unchanged → `replaceState`) so no orphaned entry is left behind.
3434
*
3535
* The per-instance tag lets nested modals add/remove their own guard independently (LIFO).
3636
*/
3737
export default function useSyncModalWithHistory({isVisible, shouldHandleNavigationBack, onClose, onOpen}: UseSyncModalWithHistoryParams) {
3838
const modalId = useId();
39-
const sentinel = `${CONST.NAVIGATION.CUSTOM_HISTORY_ENTRY_MODAL}:${modalId}`;
39+
const guardEntry = `${CONST.NAVIGATION.CUSTOM_HISTORY_ENTRY_MODAL}:${modalId}`;
4040

4141
const guardStateRef = useRef<ModalGuardState>(MODAL_GUARD_STATE.CLOSED);
4242

@@ -50,7 +50,7 @@ export default function useSyncModalWithHistory({isVisible, shouldHandleNavigati
5050

5151
const snapshotKey = useSyncExternalStore(
5252
subscribeToRootNavigation,
53-
() => getModalGuardSnapshotKey(sentinel),
53+
() => getModalGuardSnapshotKey(guardEntry),
5454
() => EMPTY_MODAL_GUARD_SNAPSHOT_KEY,
5555
);
5656
// We can't use usePrevious here because we need to imperatively reset this ref mid-effect
@@ -89,7 +89,7 @@ export default function useSyncModalWithHistory({isVisible, shouldHandleNavigati
8989
}
9090
guardStateRef.current = MODAL_GUARD_STATE.CLOSING_BY_DISPATCH;
9191
// Defer (microtask via isNavigationReady) so any forward navigation fired from the same close
92-
// handler is dispatched first; the router then consumes our sentinel during that push and this
92+
// handler is dispatched first; the router then consumes our guard entry during that push and this
9393
// toggle(false) becomes a no-op, avoiding an extra browser back().
9494
Navigation.isNavigationReady().then(() => {
9595
navigationRef.dispatch({
@@ -99,7 +99,7 @@ export default function useSyncModalWithHistory({isVisible, shouldHandleNavigati
9999
});
100100
}, [isVisible, shouldHandleNavigationBack, modalId]);
101101

102-
// Browser Back/Forward changes the guard sentinel in root history react via snapshot transitions.
102+
// Browser Back/Forward changes the guard entry in root history, so we react via snapshot transitions.
103103
useEffect(() => {
104104
if (!shouldHandleNavigationBack) {
105105
prevSnapshotKeyRef.current = snapshotKey;

src/components/Modal/useSyncModalWithHistory/modalGuardSnapshot.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const EMPTY_MODAL_GUARD_SNAPSHOT: ModalGuardSnapshot = {
1313

1414
const EMPTY_MODAL_GUARD_SNAPSHOT_KEY = 'false:0';
1515

16-
function getModalGuardSnapshot(sentinel: string): ModalGuardSnapshot {
16+
function getModalGuardSnapshot(guardEntry: string): ModalGuardSnapshot {
1717
if (!navigationRef.isReady()) {
1818
return EMPTY_MODAL_GUARD_SNAPSHOT;
1919
}
2020

2121
const state = navigationRef.getRootState();
2222
return {
23-
guardPresent: !!state?.history?.includes(sentinel),
23+
guardPresent: !!state?.history?.includes(guardEntry),
2424
routesLength: state?.routes?.length ?? 0,
2525
};
2626
}
@@ -29,8 +29,8 @@ function serializeModalGuardSnapshot(snapshot: ModalGuardSnapshot): string {
2929
return `${snapshot.guardPresent}:${snapshot.routesLength}`;
3030
}
3131

32-
function getModalGuardSnapshotKey(sentinel: string): string {
33-
return serializeModalGuardSnapshot(getModalGuardSnapshot(sentinel));
32+
function getModalGuardSnapshotKey(guardEntry: string): string {
33+
return serializeModalGuardSnapshot(getModalGuardSnapshot(guardEntry));
3434
}
3535

3636
function parseModalGuardSnapshotKey(snapshotKey: string): ModalGuardSnapshot {

src/components/Modal/useSyncModalWithHistory/modalGuardState.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ const MODAL_GUARD_EFFECT = {
1717
} as const;
1818

1919
/**
20-
* Lifecycle of one modal's browser-history back-guard sentinel. A single state replaces the previous
20+
* Lifecycle of one modal's browser-history back-guard entry. A single state replaces the previous
2121
* pair of correlated booleans (`hasGuard` / `isClosingByDispatch`) so the invalid "registered AND
2222
* closing" combination cannot be expressed.
2323
*
24-
* - `CLOSED`: no sentinel registered.
25-
* - `OPEN`: sentinel registered; browser Back removes it.
26-
* - `CLOSING_BY_DISPATCH`: we initiated the close and removed our own sentinel, so the resulting
24+
* - `CLOSED`: no guard registered.
25+
* - `OPEN`: guard registered; browser Back removes it.
26+
* - `CLOSING_BY_DISPATCH`: we initiated the close and removed our own guard entry, so the resulting
2727
* `GUARD_REMOVED` must be swallowed rather than treated as a browser Back.
2828
*/
2929
type ModalGuardState = (typeof MODAL_GUARD_STATE)[keyof typeof MODAL_GUARD_STATE];
3030

3131
type ModalGuardEvent =
3232
| {
33-
/** Our sentinel left root history (browser Back, our own close, or forward-nav consume). */
33+
/** Our guard entry left root history (browser Back, our own close, or forward-nav consume). */
3434
type: typeof MODAL_GUARD_EVENT_TYPE.GUARD_REMOVED;
3535

3636
/** Whether a route was pushed alongside the removal (forward navigation consumed the guard). */
3737
routesGrew: boolean;
3838
}
3939
| {
40-
/** Our sentinel re-entered root history (browser Forward restored the saved nav state). */
40+
/** Our guard entry re-entered root history (browser Forward restored the saved nav state). */
4141
type: typeof MODAL_GUARD_EVENT_TYPE.GUARD_APPEARED;
4242
};
4343

@@ -50,12 +50,12 @@ type ModalGuardTransition = {
5050
/**
5151
* Pure transition for a modal's back-guard in response to root-history changes. The write path sets
5252
* `OPEN` / `CLOSING_BY_DISPATCH` directly; this reducer owns the ambiguous external events where one
53-
* observable change (the sentinel disappearing) has several possible causes.
53+
* observable change (the guard entry disappearing) has several possible causes.
5454
*/
5555
function reduceModalGuardState(state: ModalGuardState, event: ModalGuardEvent, isVisible: boolean): ModalGuardTransition {
5656
switch (event.type) {
5757
case MODAL_GUARD_EVENT_TYPE.GUARD_REMOVED:
58-
// Our own close dispatch removed the sentinel — settle without firing onClose.
58+
// Our own close dispatch removed the guard entry, so settle without firing onClose.
5959
if (state === MODAL_GUARD_STATE.CLOSING_BY_DISPATCH) {
6060
return {state: MODAL_GUARD_STATE.CLOSED};
6161
}

src/components/MoneyRequestConfirmationList/hooks/useConfirmationValidation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function useConfirmationValidation({
239239

240240
const isCategoryBeingCreated = policyCategories?.[iouCategory]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
241241

242-
// The 'Uncategorized'/'none' sentinel means no category, so treat it as missing (not out of policy) here, mirroring
242+
// The 'Uncategorized'/'none' placeholder means no category, so treat it as missing (not out of policy) here, mirroring
243243
// isCategoryMissing/ViolationsUtils. Otherwise it wrongly blocks confirmation when the policy lacks that literal category.
244244
if (iouCategory && !isCategoryMissing(iouCategory) && policyCategories && !policyCategories[iouCategory]?.enabled && !isCategoryBeingCreated) {
245245
return {errorKey: 'violations.categoryOutOfPolicy'};

src/components/Popover/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function Popover(props: PopoverProps) {
6767
// changes, without intercepting that navigation.
6868
//
6969
// We subscribe to React Navigation state events rather than raw `popstate` so that
70-
// `navigationRef.getCurrentRoute()` is already fresh when the callback fires. Sentinel-only
70+
// `navigationRef.getCurrentRoute()` is already fresh when the callback fires. History changes from guard entries only
7171
// history changes (e.g. a nested YearPickerModal opening/closing) do NOT change the focused
7272
// route key, so the calendar popover stays open. A real navigation away changes the key and
7373
// closes the popover.

src/components/Search/SearchRouter/SearchRouterContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ function SearchRouterContextProvider({children}: ChildrenProps) {
5656
const searchRouterDisplayedRef = useRef(false);
5757

5858
// Registers a browser-history entry when the SearchRouter is open, so browser Back closes it
59-
// and browser Forward (after Back) reopens it. Uses the same sentinel mechanism as other modals
60-
// rather than direct window.history calls, avoiding misalignment with other sentinel-tracked overlays.
59+
// and browser Forward (after Back) reopens it. Uses the same back-guard mechanism as other modals
60+
// rather than direct window.history calls, avoiding misalignment with other guard-tracked overlays.
6161
useSyncModalWithHistory({
6262
isVisible: isSearchRouterDisplayed,
6363
shouldHandleNavigationBack: true,

src/libs/Navigation/AppNavigator/createRootStackNavigator/GetStateForActionHandlers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,11 @@ function handleToggleModalWithHistoryAction(state: StackNavigationState<ParamLis
627627
return state;
628628
}
629629

630-
// Each modal instance owns a uniquely-tagged sentinel so nested modals can be added/removed
631-
// independently (LIFO), unlike the singleton side-panel sentinel.
630+
// Each modal instance owns a uniquely-tagged history entry so nested modals can be added/removed
631+
// independently (LIFO), unlike the singleton side-panel entry.
632632
const entry = `${CONST.NAVIGATION.CUSTOM_HISTORY_ENTRY_MODAL}:${action.payload.modalId}`;
633633

634-
// On open, append this modal's back-guard sentinel. useLinking sees history grow by one and
634+
// On open, append this modal's back-guard entry. useLinking sees history grow by one and
635635
// pushes a browser history entry, so browser Back closes the modal.
636636
// Skip if already present (e.g. browser Forward restored the saved nav state before our dispatch ran).
637637
if (action.payload.isVisible) {
@@ -641,8 +641,8 @@ function handleToggleModalWithHistoryAction(state: StackNavigationState<ParamLis
641641
return {...state, history: [...state.history, entry]};
642642
}
643643

644-
// On close, remove only this modal's own sentinel (the last matching one). Filtering by exact
645-
// tag keeps sibling/nested modal sentinels intact.
644+
// On close, remove only this modal's own entry (the last matching one). Filtering by exact
645+
// tag keeps sibling/nested modal entries intact.
646646
const indexToRemove = state.history.lastIndexOf(entry);
647647
if (indexToRemove === -1) {
648648
return state;

0 commit comments

Comments
 (0)