Skip to content
Source
Sign inSign up
TanStack/showcase
A read-only demo of every feature
Every page of this repository is open, and nothing can change. Take a guided tour of what TanStack Source does.

feat: formatList numbers the tasks with { numbered: true } #14

OpenAlemTuzlakwants to merge 1 commit intomain fromfeat/numbered-listopened

Intent

1 transcript

Why

Issue #13 asks for numbered tasks in formatList. People paste the list into chats and want to be able to say "task 2". Today every line starts with a - bullet, so tasks carry no speakable numbers. The default output had to stay exactly as it was, because people already use the bullets.

What was asked

The person asked the agent: "Issue #13 asks for numbered tasks in formatList. People paste the list into chats and want to say 'task 2'. Add an option for it, but keep the default output exactly as it is, because people use the bullets today. Add tests, run the checks, then push a branch and open the pull request that closes #13."

Decisions

  • Options object instead of a bare boolean. formatList(list, options: FormatOptions = {}) with numbered?: boolean. A bare true argument was rejected: "An options object keeps the call readable ({ numbered: true }, not a bare true), and later options can join it without a breaking change."
  • Numbers come from list position, not task ids. Numbering by task id was rejected because "ids can have gaps after removeTask, and a reader expects 1, 2, 3." The marker is therefore `${index + 1}.` and the numbers "follow the order of the list".
  • Tests written first. The numbered-list test was added before the implementation and was watched failing (expected '- [ ] Ship it…' to be '1. [ ] Ship it…') to confirm it failed for the right reason — the option not existing yet.
  • FormatOptions is exported. It is re-exported from src/index.ts so callers can type their options.
  • README documents the option. The API table row became formatList(list, options?) with a note that { numbered: true } numbers the tasks.

Architecture

The change sits in one function: formatList in src/format.ts maps each task to a line whose marker is ${index + 1}. when { numbered: true } is passed and - otherwise, keeps the [x]/[ ] checkbox and title unchanged, joins the lines with \n, and takes an empty default options so existing calls are untouched; FormatOptions is re-exported from src/index.ts and documented in the README.

Review notes

  • Default output unchanged: the existing test still expects formatList(list) to be - [x] Ship it\n- [ ] Docs, and the suite passed 9/9 after the change; verify the no-options path is byte-identical to before.
  • Numbering is positional: the numbers renumber whenever the list changes — after removeTask leaves gaps in ids, the lines still read 1, 2, 3. A "task 2" said in a chat refers to the current position, not a stable id; check this is the intended behavior.
  • Falsy handling untested: numbered is read as a truthy flag, so {} and { numbered: false } produce bullets; there is no explicit test for those inputs, only for the default call without a second argument.
  • Empty list: formatList([], { numbered: true }) returns '' — covered by a test.
  • Only pnpm test and pnpm typecheck were run. The input contains only the author transcript and no reviewer feedback, so nothing has been second-read yet.

Open questions

None.

AlemTuzlakcommented

formatList gets an option to number the tasks. With { numbered: true } each line starts with 1., 2., 3. in place of -, so people can say "task 2" when they paste a list into a chat. The default output does not change.

Closes #13

Before and after

formatList(list) writes a bullet for each task

formatList(list, { numbered: true }) writes 1, 2 and 3 in front of the tasks

Demo

What changed

  • src/format.ts: formatList(list, options?) takes FormatOptions. numbered writes <n>. in place of the bullet. The numbers follow the order of the list.
  • src/index.ts: exports the FormatOptions type.
  • test/tasks.test.ts: two tests, for a numbered list and for an empty list.
  • README.md: the API table shows the option.

How to test

pnpm test
pnpm typecheck

Or install the package preview of this pull request from the Package previews card, and call formatList(list, { numbered: true }).

    1. AlemTuzlak linked this to fix #13

    2. tanstack-sourceBotcommented

      Nice and tidy: this closes #13 exactly as asked, keeps the default output the same, and comes with tests and README docs. 👍

      TanStack Source bot, value agent

    3. tanstack-source published a comment(spam 3%, injection 9%)

    4. tanstack-sourceBotcommented

      Verdict: fixes ✅

      I reproduced issue #13 on both commits with a vitest repro (.factory-repro/repro.test.ts) built from the issue text:

      • Base 2025880 — failed: formatList(list, { numbered: true }) returned - [ ] Ship it\n- [x] Docs\n- [ ] Tests — bullets, with the option ignored.
      • Head bfa31eb — passed: the output is 1. [ ] Ship it\n2. [x] Docs\n3. [ ] Tests, and the default bullet output is unchanged.

      The full test suite (11 tests) and pnpm typecheck also pass on the head, so the PR closes #13 as asked.

      TanStack Source bot, fixes-issue agent

    5. tanstack-source published a comment(spam 1%, injection 24%)

    6. tanstack-sourceBotcommented

      Ready to merge: every factory step passed on bfa31eb.

      • spam: not-spam
      • assign: no-match
      • audit: clean
      • impact: recorded
      • value: useful
      • classify: recorded
      • fixes-issue: fixes
      • review: no-findings

      TanStack Source bot

Sign in to join this conversation.