Skip to content

[No QA] Fix ESLint seatbelt failure in createDocsRoutes.ts (unsafe type assertions) - #95782

Closed
MelvinBot wants to merge 1 commit into
mainfrom
claude-fixDocsRoutesUnsafeTypeAssertions
Closed

[No QA] Fix ESLint seatbelt failure in createDocsRoutes.ts (unsafe type assertions)#95782
MelvinBot wants to merge 1 commit into
mainfrom
claude-fixDocsRoutesUnsafeTypeAssertions

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The lint / ESLint check job started failing on main after PR #95101, which added new @typescript-eslint/no-unsafe-type-assertion violations to .github/scripts/createDocsRoutes.ts. The file's eslint-seatbelt baseline allowed only 3 such assertions, but the new getOrderFromArticleFrontMatter / getSectionMeta helpers pushed it to 6, breaking the build.

This removes the 5 unsafe as assertions on the yaml.load(...) results (which return unknown) and replaces them with:

  • A small isRecord() type guard that narrows an unknown value to Record<string, unknown>.
  • typeof checks when reading order/title, so the returned values are correctly typed without asserting.

This is behavior-preserving and actually slightly safer: the old code blind-cast frontmatterObject.order to number | undefined and meta.title to string | undefined even if the parsed YAML held a different type; the new code validates the runtime type before using it. Only the original as DocsRoutes assertion remains (grandfathered), so the seatbelt baseline for this file is tightened from 3 to 1 in config/eslint/eslint.seatbelt.tsv.

Fixed Issues

$ #95779
PROPOSAL: #95779 (comment)

Tests

// TODO: The human co-author must fill out the tests they ran before marking this PR as "ready for review".

This is a CI/build-script change with no runtime (app) impact. It can be validated with:

  1. Run npm run lint (or ./scripts/lint.sh .github/scripts/createDocsRoutes.ts) and verify it passes with 0 errors.
  2. Run npm run createDocsRoutes and verify docs/_data/routes.yml is generated identically to before (article order and section titles unchanged).
  • Verify that no errors appear in the JS console

Offline tests

N/A — build/CI-only change.

QA Steps

// TODO: The issue title includes "[No QA]" — this change only affects a repo build script (.github/scripts/createDocsRoutes.ts) and the lint baseline, not the app.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.

Screenshots/Videos

N/A — no UI changes.

Co-authored-by: Stephanie Elliott <stephanieelliott@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 I analyzed the checks. No code fix is needed — the check this PR exists to fix is already green, and the only failing check is the human-only PR Author Checklist.

Failing check: PR Author Checklist / checklist — this fails because the checklist boxes in the PR body aren't ticked ("You completed 1 out of 38 checklist items"). That's an author task; MelvinBot can't (and shouldn't) tick these on a human's behalf. stephanieelliott, please complete the checklist to clear it.

Everything relevant passes:

  • lint / ESLint check ✅ — this is the failure the PR was opened to fix (the no-unsafe-type-assertion seatbelt for .github/scripts/createDocsRoutes.ts), and it's now green.
  • typecheck ✅, perf-tests ✅, Oxfmt, React Compiler, spellcheck, knip, verify, dryRun — all ✅.
Why no other failure is expected

The Jest test suite was still running when I finished, but it can't be affected by this change: the diff only touches .github/scripts/createDocsRoutes.ts (a build-time docs-generation script) and config/eslint/eslint.seatbelt.tsv. createDocsRoutes is not imported anywhere under src/ or tests/, so it isn't exercised by the unit tests or the app runtime. Any failure there would be pre-existing/flaky and unrelated to this PR — re-run it if it flakes.

Bottom line: tick the PR Author Checklist boxes to clear the only failing check; there's nothing for me to push.

@stephanieelliott
stephanieelliott marked this pull request as ready for review July 10, 2026 07:02
@melvin-bot
melvin-bot Bot requested review from Eskalifer1 and removed request for a team July 10, 2026 07:02
@melvin-bot

melvin-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

@Eskalifer1 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Re-checked — nothing has changed since my earlier analysis, and there's still no code fix for me to push.

  • Only failing check: PR Author Checklist / checklist — a human-only task. stephanieelliott, tick the checklist boxes in the PR body to clear it (currently 1/38 completed).
  • lint / ESLint check (the failure this PR fixes) ✅, plus typecheck, perf-tests, and all other completed checks ✅.
  • test (job 8) (Jest) is still running — it's just slow, not hung (~18 min in). It can't be affected by this change: the diff only touches the build-time script .github/scripts/createDocsRoutes.ts and config/eslint/eslint.seatbelt.tsv, neither of which is imported by the unit tests. If it flakes/fails, re-run it — it's unrelated to this PR.

@Eskalifer1

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@Eskalifer1

Copy link
Copy Markdown
Contributor

@codex review

@Eskalifer1

Copy link
Copy Markdown
Contributor

@MelvinBot we have branch conflict with main, let's fix that

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I can't resolve the conflict here because I can only make code changes (including merging main and pushing) when directed by the PR author, an assignee, or an existing co-author. This PR is authored by MelvinBot and assigned to stephanieelliott (also the only co-author), and Eskalifer1 isn't one of those.

To have me do it, an assignee or co-author (e.g. stephanieelliott) should reply tagging me. Otherwise, the conflict can be resolved directly with:

gh pr checkout 95782
git merge main
# resolve conflicts, then:
git add -A && git commit && git push

The conflict is almost certainly in config/eslint/eslint.seatbelt.tsv (this PR tightens the createDocsRoutes.ts baseline from 3 to 1), since that file changes frequently on main.

@Eskalifer1

Copy link
Copy Markdown
Contributor

@MelvinBot merge main and resolve conflicts

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f9e46f183d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Still can't do this, Eskalifer1 — nothing has changed since my last reply. I can only merge main and push to this branch when the request comes from the PR author, an assignee, or an existing co-author. This PR is authored by MelvinBot and assigned to stephanieelliott (also the only co-author), and you're not one of those.

Two ways forward:

  • stephanieelliott replies here tagging me to run the merge, or adds you as a PR assignee — then retry your request.
  • Or resolve it directly:
    gh pr checkout 95782
    git merge main
    # resolve conflicts, then:
    git add -A && git commit && git push

The conflict is most likely in config/eslint/eslint.seatbelt.tsv (this PR tightens the createDocsRoutes.ts baseline from 3 to 1), which changes frequently on main.

@Eskalifer1

Copy link
Copy Markdown
Contributor

@MelvinBot I am assigned to this issue as C+, you can check it

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I checked, and I don't see Eskalifer1 listed as an assignee on either the PR or the linked issue #95779:

I can only make code changes (including merging main to resolve the conflict) when directed by the PR author, a PR assignee, or an existing co-author. If you should be assigned as C+, an assignee (e.g. stephanieelliott) can add you to the PR assignees and then you can retry the request — or an existing assignee/co-author can tag me directly.

Alternatively, the conflict can be resolved manually:

gh pr checkout 95782
git merge main
# resolve conflicts (most likely in config/eslint/eslint.seatbelt.tsv), then:
git add -A && git commit && git push

@stephanieelliott

Copy link
Copy Markdown
Contributor

Oop this isn't needed anymore! We ended up reverting the offending PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants