Skip to content

feat(prettier-plugin-toml): load tombi through tombit - #535

Merged
JounQin merged 10 commits into
masterfrom
feat/tombit-0.1.1
Oct 19, 2026
Merged

JounQin merged 10 commits into
masterfrom
feat/tombit-0.1.1

Conversation

@JounQin

@JounQin JounQin commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

What

Replaces @tombi-toml/lib + smol-toml with tombit ^0.1.3:

  • configuration discovery and merging stay in Rust — tombit finds .tombi.toml, tombi.toml, .config/tombi.toml, [tool.tombi] in pyproject.toml, then the user/system configs;
  • the plugin drops discover.ts (218 lines) and the smol-toml dependency;
  • tombit's format/lint are async, so formatting no longer blocks the event loop;
  • formatting a string without a filepath now falls back to a synthetic name for discovery instead of failing to convert undefined into a Rust string.

Precedence

The rules are resolved in ascending priority: the discovered configuration's base rules, then Prettier's core options (printWidth, tabWidth, useTabs, singleQuote, bracketSpacing) and explicitly set plugin options (passed as overrideConfig), then the discovered configuration's per-file [[overrides]], which Tombi applies last.

The plugin's own options no longer declare defaults, so "not set" is observable: an unset plugin option follows the discovered configuration (or Tombi's default). Prettier's core options are always resolved, so they cannot be distinguished from their defaults and stay authoritative. toml-version follows the discovered configuration unless the tomlVersion option is set, because it decides how the source is parsed.

This is a behavior change from 4.0.0, where a discovered tombi.toml could override Prettier's defaults.

To keep the tombi CLI / VS Code extension in sync, set line-width in tombi.toml to the same value as printWidth; with no configuration at all, Prettier defaults to 80 while tombi has no line width limit.

Diagnostics

tombit exposes range/sourceFile on diagnostics again, so syntax errors keep rendering their Prettier code frame.

Review status

  • [email protected] fixes the [[overrides]] abort (serialize the resolved config with the linked toml_edit) and applies a matching override's format/lint rules over the base rules (tombi-toml/tombi#2330).
  • This PR depends on ^0.1.3 and adds a plugin-level [[overrides]] regression test (packages/toml/test/overrides.spec.ts, six-space indentation).
  • codecov/project reports about −2.4%: deleting a 97%-covered file lowers the project percentage while the remaining files' coverage and codecov/patch are unchanged. No repo-wide Codecov config is added without the owner's decision.
  • The changeset stays minor (the owner chose to avoid another major); the precedence change is documented above.

Verification

  • yarn vitest run packages/toml — 20/20, toml/src 100% coverage
  • yarn lint:tsc, yarn eslint packages/toml — clean
  • fixture1.toml (80-column wrapping) and invalid.toml (code frame) snapshots unchanged
  • .changeset/tombit.md — minor

Replace `@tombi-toml/lib` and `smol-toml` with `tombit`: configuration
discovery and merging stay in Rust, explicit Prettier options are passed as
`overrideConfig`, and the plugin drops its JavaScript discovery/caching layer.

Prettier's resolved options (including its defaults) are authoritative for the
rules the plugin exposes; `tombi.toml` still supplies the remaining rules and
its `[[overrides]]` are applied by Tombi last. Diagnostics carry a range again,
so syntax errors keep their code frame.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 05:43
@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d413da0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
prettier-plugin-toml Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3310dbaa-2a70-4958-b465-af790e98e3cb
📥 Commits

Reviewing files that changed from the base of the PR and between 0f7b945 and e679712.

📒 Files selected for processing: 3
  • packages/toml/README.md
  • packages/toml/test/fixtures.spec.ts
  • packages/toml/test/index.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The TOML plugin now uses tombit for formatting and configuration discovery. It maps resolved Prettier options to Tombi rules, removes plugin-defined option defaults, and updates its configuration documentation and tests.

Changes: TOML configuration handoff

Layer / File(s) Summary
Build configuration from Prettier options
packages/toml/src/config.ts, packages/toml/src/options.ts, packages/toml/README.md, packages/toml/test/config.spec.ts, packages/toml/test/options.spec.ts
getTombiConfig maps resolved Prettier options to Tombi rules and adds toml-version only when set. Plugin option definitions no longer specify defaults. Tests cover the mappings and option behavior.
Delegate discovery and formatting to tombit
packages/toml/src/index.ts, packages/toml/src/discover.ts, packages/toml/package.json, packages/toml/README.md, packages/toml/test/*, .changeset/tombit.md
The formatter passes a filepath or stdin.toml and overrideConfig to tombit. The plugin removes its local discovery and merge code and updates its dependency and documentation. Tests cover filepath-free formatting and parser behavior; the former discovery tests are removed.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Prettier
  participant TOMLPlugin
  participant tombit
  Prettier->>TOMLPlugin: Pass document and resolved options
  TOMLPlugin->>tombit: Pass filepath and overrideConfig
  tombit-->>TOMLPlugin: Return formatting result and diagnostics
Loading

Suggested reviewers: i1stg

Merge Risk: ⚪ Minimal · up to e6797

The changes add filepath-free TOML formatting and document configuration precedence. No actionable failure is established in the supplied evidence, so no merge-blocking issue is identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 7 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: loading Tombi through tombit in the Prettier TOML plugin.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 7 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codesandbox-ci

codesandbox-ci Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@codacy-production

codacy-production Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics -2 complexity · 0 duplication

Metric Results
Complexity -2
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · -0.78% coverage variation

Metric Results
Coverage variation ✅ -0.78% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (1dda891) 342 318 92.98%
Head commit (e679712) 218 (-124) 201 (-117) 92.20% (-0.78%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#535) 8 8 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploying prettier with  Cloudflare Pages  Cloudflare Pages

Latest commit: d413da0
Status: ✅  Deploy successful!
Preview URL: https://20a8312d.prettier-ans.pages.dev
Branch Preview URL: https://feat-tombit-0-1-1.prettier-ans.pages.dev

View logs

@socket-security

socket-security Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​tombit@​0.1.36810010091100

View full report

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
packages/autocorrect/lib/index.js 24.26 KB (0%)
packages/pkg/lib/index.js 2.09 KB (0%)
packages/sh/lib/index.js 3.96 KB (0%)
packages/sql/lib/index.js 2.25 KB (0%)

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.70%. Comparing base (1dda891) to head (d413da0).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #535      +/-   ##
==========================================
- Coverage   92.25%   89.70%   -2.55%     
==========================================
  Files          12       11       -1     
  Lines         413      272     -141     
  Branches      108       77      -31     
==========================================
- Hits          381      244     -137     
+ Misses         31       27       -4     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/toml/src/config.ts Resolved
Comment thread packages/toml/src/index.ts Resolved
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

📊 Package size report   -0.3%↓

File Before After
.changeset/tombit.md — 1.2 kB
packages/toml/package.json 1.1 kB -3.18%↓1.1 kB
packages/toml/README.md 7.8 kB 13%↑8.8 kB
packages/toml/src/config.ts 7.2 kB -57%↓3.1 kB
packages/toml/src/discover.ts 6.2 kB —
packages/toml/src/index.ts 2.7 kB -6.08%↓2.6 kB
packages/toml/src/options.ts 5.3 kB -3.62%↓5.1 kB
packages/toml/test/config.spec.ts 3.3 kB -14.7%↓2.8 kB
packages/toml/test/discover-global.spec.ts 2.5 kB —
packages/toml/test/discover.spec.ts 4.9 kB —
packages/toml/test/fixtures.spec.ts 857 B 45%↑1.2 kB
packages/toml/test/index.spec.ts — 1.6 kB
packages/toml/test/options.spec.ts 1.3 kB 26%↑1.6 kB
packages/toml/test/overrides.spec.ts — 1.2 kB
Total (Includes all files) 4.2 MB -0.3%↓4.2 MB
Tarball size 1.5 MB -0.17%↓1.5 MB
Unchanged files
File Size
.changeset/config.json 313 B
.changeset/README.md 510 B
.codesandbox/ci.json 38 B
.editorconfig 161 B
.gitattributes 152 B
.github/workflows/autofix.yml 963 B
.github/workflows/ci.yml 1.8 kB
.github/workflows/pkg-pr-new.yml 726 B
.github/workflows/pkg-size.yml 609 B
.github/workflows/release.yml 1.3 kB
.github/workflows/size-limit.yml 856 B
.nano-staged.js 48 B
.nvmrc 6 B
.postcssrc.cjs 51 B
.prettierignore 23 B
.prettierrc 24 B
.remarkrc 159 B
.renovaterc 49 B
.simple-git-hooks.js 49 B
.size-limit.json 293 B
.yarn/plugins/plugin-prepare-lifecycle.cjs 202 B
.yarn/releases/yarn-4.18.1.cjs 3.8 MB
.yarnrc.yml 479 B
assets/pkg.svg 15.1 kB
assets/sh.png 14.4 kB
CHANGELOG.md 393 B
docs/App.tsx 1.2 kB
docs/global.css 321 B
docs/index.tsx 211 B
eslint.config.js 632 B
index.html 414 B
LICENSE 1.1 kB
package.json 3.6 kB
packages/autocorrect/CHANGELOG.md 2.2 kB
packages/autocorrect/index.d.cts 63 B
packages/autocorrect/LICENSE 1.1 kB
packages/autocorrect/package.json 1.1 kB
packages/autocorrect/README.md 4.0 kB
packages/autocorrect/src/index.ts 1.4 kB
packages/autocorrect/src/types.ts 78 B
packages/autocorrect/test/__snapshots__/fixtures.spec.ts.snap 4.7 kB
packages/autocorrect/test/fixtures.spec.ts 1.0 kB
packages/autocorrect/test/fixtures/test.css 189 B
packages/autocorrect/test/fixtures/test.go 470 B
packages/autocorrect/test/fixtures/test.html 1.1 kB
packages/autocorrect/test/fixtures/test.md 1.1 kB
packages/autocorrect/test/fixtures/test.py 368 B
packages/autocorrect/test/fixtures/test.rb 234 B
packages/autocorrect/test/fixtures/test0.js 453 B
packages/autocorrect/tsconfig.json 154 B
packages/pkg/CHANGELOG.md 14.3 kB
packages/pkg/index.d.cts 47 B
packages/pkg/LICENSE 16.7 kB
packages/pkg/package.json 1.0 kB
packages/pkg/README.md 7.2 kB
packages/pkg/src/index.ts 2.9 kB
packages/pkg/src/rules/files.ts 1.6 kB
packages/pkg/src/rules/object.ts 1.0 kB
packages/pkg/src/rules/sort.ts 5.4 kB
packages/pkg/src/types.ts 1.1 kB
packages/pkg/src/utils.ts 2.6 kB
packages/pkg/test/__snapshots__/engines.spec.ts.snap 158 B
packages/pkg/test/__snapshots__/files.spec.ts.snap 173 B
packages/pkg/test/__snapshots__/ignore-sort.spec.ts.snap 1.1 kB
packages/pkg/test/__snapshots__/sort-order-preset.spec.ts.snap 7.6 kB
packages/pkg/test/__snapshots__/sort-order.spec.ts.snap 996 B
packages/pkg/test/__snapshots__/test.spec.ts.snap 2.1 kB
packages/pkg/test/engines.spec.ts 417 B
packages/pkg/test/files.spec.ts 409 B
packages/pkg/test/fixtures/fixture1.json 1.0 kB
packages/pkg/test/fixtures/fixture2.json 895 B
packages/pkg/test/fixtures/fixture3.json 430 B
packages/pkg/test/ignore-sort.spec.ts 414 B
packages/pkg/test/sort-order-preset.spec.ts 708 B
packages/pkg/test/sort-order.spec.ts 442 B
packages/pkg/test/test.spec.ts 2.3 kB
packages/pkg/test/utils.spec.ts 3.4 kB
packages/pkg/tsconfig.json 154 B
packages/sh/CHANGELOG.md 17.0 kB
packages/sh/index.d.cts 45 B
packages/sh/LICENSE 1.1 kB
packages/sh/package.json 1.4 kB
packages/sh/README.md 10.5 kB
packages/sh/src/index.ts 14.1 kB
packages/sh/test/__snapshots__/fixtures.spec.ts.snap 29.4 kB
packages/sh/test/__snapshots__/shellscript.spec.ts.snap 394 B
packages/sh/test/error.spec.ts 484 B
packages/sh/test/fixtures.spec.ts 1.5 kB
packages/sh/test/fixtures/.dockerignore 108 B
packages/sh/test/fixtures/.env.development 29 B
packages/sh/test/fixtures/.husky/precommit 17 B
packages/sh/test/fixtures/.nvmrc 6 B
packages/sh/test/fixtures/.properties 177 B
packages/sh/test/fixtures/133.sh 5.2 kB
packages/sh/test/fixtures/162.sh 15.7 kB
packages/sh/test/fixtures/182.sh 1.9 kB
packages/sh/test/fixtures/191.sh 1.7 kB
packages/sh/test/fixtures/278.Dockerfile 32 B
packages/sh/test/fixtures/292.Dockerfile 95 B
packages/sh/test/fixtures/376.Dockerfile 217 B
packages/sh/test/fixtures/384.Dockerfile 51 B
packages/sh/test/fixtures/398.Dockerfile 64 B
packages/sh/test/fixtures/441.Dockerfile 219 B
packages/sh/test/fixtures/445.Dockerfile 198 B
packages/sh/test/fixtures/445.sh 105 B
packages/sh/test/fixtures/Dockerfile 394 B
packages/sh/test/fixtures/hosts 406 B
packages/sh/test/fixtures/jvm.options 162 B
packages/sh/test/fixtures/no-ext 38 B
packages/sh/test/fixtures/shell.sh 368 B
packages/sh/test/loc-functions.spec.ts 950 B
packages/sh/test/options.spec.ts 645 B
packages/sh/test/parser.spec.ts 2.1 kB
packages/sh/test/zsh.spec.ts 1.3 kB
packages/sh/tsconfig.json 154 B
packages/sql/CHANGELOG.md 12.2 kB
packages/sql/index.d.cts 47 B
packages/sql/LICENSE 1.1 kB
packages/sql/package.json 1.3 kB
packages/sql/README.md 7.0 kB
packages/sql/src/index.ts 13.1 kB
packages/sql/test/__snapshots__/fixtures-eol.spec.ts.snap 886 B
packages/sql/test/__snapshots__/fixtures.spec.ts.snap 43.0 kB
packages/sql/test/__snapshots__/sql.spec.ts.snap 374 B
packages/sql/test/fixtures-eol.spec.ts 1.4 kB
packages/sql/test/fixtures-eol/556.sql 73 B
packages/sql/test/fixtures-eol/557.sql 69 B
packages/sql/test/fixtures-eol/558.sql 69 B
packages/sql/test/fixtures-eol/559.sql 73 B
packages/sql/test/fixtures.spec.ts 1.9 kB
packages/sql/test/fixtures/144.sql 68 B
packages/sql/test/fixtures/233.sql 68 B
packages/sql/test/fixtures/277.sql 88 B
packages/sql/test/fixtures/279.sql 106 B
packages/sql/test/fixtures/291.sql 1.2 kB
packages/sql/test/fixtures/334.sql 15 B
packages/sql/test/fixtures/405.sql 160 B
packages/sql/test/fixtures/495.sql 310 B
packages/sql/test/fixtures/basic.sql 120 B
packages/sql/test/sql.spec.ts 660 B
packages/sql/tsconfig.json 154 B
packages/toml/CHANGELOG.md 5.9 kB
packages/toml/index.d.cts 49 B
packages/toml/LICENSE 1.1 kB
packages/toml/src/types.ts 2.4 kB
packages/toml/test/__snapshots__/fixtures.spec.ts.snap 842 B
packages/toml/test/fixtures/comments.toml 87 B
packages/toml/test/fixtures/fixture1.toml 162 B
packages/toml/test/fixtures/invalid.toml 16 B
packages/toml/test/fixtures/pyproject.toml 106 B
packages/toml/tsconfig.json 154 B
public/android-chrome-192x192.png 3.5 kB
public/android-chrome-512x512.png 12.6 kB
public/apple-touch-icon.png 3.5 kB
public/favicon-16x16.png 309 B
public/favicon-32x32.png 547 B
public/favicon.ico 15.4 kB
public/site.webmanifest 288 B
README.md 6.8 kB
scripts/format.ts 593 B
scripts/languages.ts 3.3 kB
test/global.d.ts 103 B
test/tsconfig.json 223 B
tsconfig.base.json 153 B
tsconfig.json 275 B
vite.config.ts 544 B
vitest.config.ts 541 B

🤖 This report was automatically generated by pkg-size-action

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

prettier-plugin-autocorrect

npm i https://pkg.pr.new/prettier-plugin-autocorrect@535

prettier-plugin-pkg

npm i https://pkg.pr.new/prettier-plugin-pkg@535

prettier-plugin-sh

npm i https://pkg.pr.new/prettier-plugin-sh@535

prettier-plugin-sql

npm i https://pkg.pr.new/prettier-plugin-sql@535

prettier-plugin-toml

npm i https://pkg.pr.new/prettier-plugin-toml@535

commit: d413da0

@gitar-bot gitar-bot Bot added the gitar-approved Added by Gitar label Oct 19, 2026

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

Restore 100% coverage after dropping the JavaScript discovery layer: cover
`useTabs`, explicit `stringQuoteStyle`/`inlineTableBraceSpaceWidth`, an unset
`printWidth`, the missing-diagnostic guard and `locStart`/`locEnd`.
`tomlVersion` defaulted to `v1.0.0`, so the plugin always sent `toml-version`
through `overrideConfig`; a project's `toml-version = "v1.1.0"` was then parsed
as v1.0.0. Drop the option default and only emit the key when it is set.

Refresh the docs/comments that still described the explicit-only precedence and
drop the unused "explicitly configured" tuple flag.
Prettier can format a string without a filepath; fall back to a synthetic name
so tombi can still discover a configuration instead of failing to convert
`undefined` into a Rust string. Also simplify the core-rule mapping.
With no defaults, an unset plugin option is `undefined` and is not sent, so the
discovered `tombi.toml` (or Tombi's own default) supplies it; explicitly set
options still override. Prettier's core options keep their resolved values.

The outputs without a config are unchanged (Tombi's defaults match the removed
ones); added a test that the option definitions declare no defaults.
Comment thread packages/toml/src/index.ts Outdated
async function format(code: string, options: PrettierOptions) {
const { formatted, diagnostics } = await formatToml(code, options.filepath, {
// Prettier may omit the filepath; a synthetic name still allows discovery.
const filepath = options.filepath || 'stdin.toml'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just be inlined.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined in 33e2f02: the filepath fallback is now an argument of the formatToml call.

Comment thread packages/toml/src/config.ts Resolved
Inline the filepath fallback and the four resolve helpers into `getCoreRules`
as suggested in review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 11
packages/toml/src/config.ts: 2

35-37: LGTM!


15-22: 🎯 Functional Correctness

[email protected] derives an unset key-quote-style from the effective string-quote-style. When the override changes string-quote-style, the key quote style follows the override. No change is required.

packages/toml/README.md: 1

53-93: LGTM!

packages/toml/src/options.ts: 1

15-16: LGTM!

packages/toml/test/config.spec.ts: 1

24-101: LGTM!

packages/toml/test/options.spec.ts: 1

53-59: LGTM!

packages/toml/package.json: 1

44-44: LGTM!

packages/toml/src/index.ts: 1

42-48: LGTM!

packages/toml/test/fixtures.spec.ts: 1

10-14: LGTM!

packages/toml/test/index.spec.ts: 1

1-36: LGTM!

.changeset/tombit.md: 1

19-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Fix the line wrap in the changeset text.

Line 19 is longer than the surrounding wrapped lines. It joins two sentences on one line. This does not change the rendered output. Rewrap it for consistency.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c61ec8ec-80b3-497b-b088-94369715631a
📥 Commits

Reviewing files that changed from the base of the PR and between 1dda891 and 0f7b945.

⛔ Files ignored due to path filters: 1
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing: 13
  • .changeset/tombit.md
  • packages/toml/README.md
  • packages/toml/package.json
  • packages/toml/src/config.ts
  • packages/toml/src/discover.ts
  • packages/toml/src/index.ts
  • packages/toml/src/options.ts
  • packages/toml/test/config.spec.ts
  • packages/toml/test/discover-global.spec.ts
  • packages/toml/test/discover.spec.ts
  • packages/toml/test/fixtures.spec.ts
  • packages/toml/test/index.spec.ts
  • packages/toml/test/options.spec.ts
💤 Files with no reviewable changes: 3
  • packages/toml/test/discover.spec.ts
  • packages/toml/test/discover-global.spec.ts
  • packages/toml/src/discover.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@i1stG i1stG left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The direction is good: dropping smol-toml and the 218-line JS discovery layer in favour of serde_tombi is a real simplification, and async format is a nice improvement. Tests, tsc and eslint are green.

Requesting changes for one blocking regression, plus a CI failure and some docs/semver issues.

🚨 Blocker: a discovered tombi.toml with [[overrides]] aborts the process

[email protected] panics natively and aborts:

thread '<unnamed>' panicked at tombi/rust/serde_tombi/src/ser.rs:155:17:
internal error: entered unreachable code: Document must be valid TOML.
thread caused non-unwinding panic. aborting.

With tombi.toml:

[format.rules]
indent-table-key-value-pairs = true
indent-width = 4

[[overrides]]
files.include = ["**/*.toml"]

[overrides.format.rules]
indent-width = 6

and:

import { format } from 'prettier'
import plugin from 'prettier-plugin-toml'

await format('[t]\nkey = 1\n', {
  filepath: '<dir>/a.toml',
  parser: 'toml',
  plugins: [plugin],
})

Narrowed on tombit directly (Node 24.22.0, darwin/arm64):

call result
config: false ok
explicit config: { content, path } with [[overrides]] ok
discovery with [[overrides]] (no overrideConfig) abort
overrideConfig.overrides / explicit config + any overrideConfig abort

4.0.0 (master) formats the same config fine (@tombi-toml/[email protected] + the previous JS merge), so this is a regression from this switch.

I filed the upstream repro at unrs/tombit#5. Please:

  • add an [[overrides]] regression test here, and
  • don't merge until tombit is fixed (the ^0.1.1 range will pick up a 0.1.x patch).

CI

codecov/project fails: 92.25% → 89.70% (−2.55%).

Docs / semver

  • The README precedence list says "each step overriding the previous one" but reads as discovered rules > Prettier options; the actual order is discovered base < overrideConfig < per-file [[overrides]]. Reorder it or say "highest priority first".
  • The changeset is minor, but this changes output for existing users (Prettier's defaults now beat a discovered tombi.toml — e.g. line-width = 120 stops applying unless printWidth matches). That looks major.

Nits

  • index.spec.ts mocks tombit but never asserts the call args; worth locking in the 'stdin.toml' fallback and overrideConfig.
  • fixtures.spec.ts's no-filepath test depends on cwd not containing a tombi.toml.
  • printWidth: Infinity omits line-width, so a discovered line-width applies despite "core options always win".

… review nits

Reorder the precedence list in ascending priority, assert the synthetic
filepath and the override config in the unit test, and run the no-filepath
fixture test from a temporary cwd.
@JounQin

JounQin commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review.

  • The [[overrides]] abort is fixed in fix: serialize the resolved config with toml_edit unrs/tombit#6: the resolved config is now serialized with toml instead of serde_tombi's writer, which produced invalid TOML for nested tables inside [[overrides]]. Regression tests for discovery with [[overrides]] (sync and async) are in and pass.
  • I'll bump this PR to tombit@^0.1.2 and add the plugin-level [[overrides]] regression test once 0.1.2 is published, and hold the merge until then.
  • The precedence list is now ordered by ascending priority (discovered base < overrideConfig < per-file [[overrides]]), and the test nits (stdin.toml fallback/overrideConfig assertion, temporary cwd) are addressed.

@gitar-bot

gitar-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 closed / 2 findings

🟡 Medium risk · Delegating TOML config resolution to tombit and changing option precedence could alter formatting or parsing unexpectedly for existing projects.

Replaces @tombi-toml/lib and smol-toml with tombit for config discovery and async formatting, dropping discover.ts. Resolved the toml-version default overriding tombi.toml and the stale docs describing explicit-only option merging. No issues found.

✅ 2 closed
✅ Bug: Prettier's tomlVersion default now overrides tombi.toml's toml-version

📄 packages/toml/src/config.ts:111-116 📄 packages/toml/src/index.ts:41-44
tomlVersion has a Prettier default of 'v1.0.0' (options.ts), so options.tomlVersion is always set. getTombiConfig then always sends toml-version through overrideConfig. A project whose tombi.toml / [tool.tombi] sets toml-version = "v1.1.0" will now have v1.1-only syntax (for example newlines in inline tables) parsed as v1.0.0. That fails with a syntax error, where before it formatted fine. Format rules only change the output's style, but this setting decides whether the file parses at all, and neither the changeset nor the README precedence section (which only talks about rules) mentions it. Either leave toml-version out of the override unless the user set it explicitly (for example, drop the option's default and only emit the key when it is set), or call out this parse-level break in the changeset and README.

✅ Quality: Docs/comments still say only explicit Prettier options are merged

📄 packages/toml/src/index.ts:30-34 📄 .changeset/tombit.md:9-10 📄 packages/toml/src/config.ts:53-67
The JSDoc on format in index.ts ("the Prettier options that were explicitly configured are merged on top") and the changeset ("Explicit Prettier options are passed as overrideConfig") describe the old explicit-only behavior. In fact getTombiConfig now sends every resolved option, Prettier defaults included. The third tuple element in getCoreCandidates (the "explicitly configured" flag) is also never read anymore. That leftover makes the code look like explicitness still matters. Update both texts to say all resolved options are authoritative, and simplify getCoreCandidates to [rule, value] pairs.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

tombit 0.1.3 applies a matching `[[overrides]]`'s format/lint rules over the
base rules. Bump the dependency, add a plugin-level regression test, and note
the requirement in the changeset.
@JounQin

JounQin commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

[email protected] is released. This PR now depends on ^0.1.3, includes a plugin-level [[overrides]] regression test, and the [[overrides]] abort from the review is fixed. Ready for re-review.

@codacy-production

codacy-production Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 2 complexity · 0 duplication

Metric Results
Complexity 2
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · -0.78% coverage variation

Metric Results
Coverage variation ✅ -0.78% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (1dda891) 342 318 92.98%
Head commit (d413da0) 218 (-124) 201 (-117) 92.20% (-0.78%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#535) 8 8 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sonarqubecloud

Copy link
Copy Markdown

@i1stG i1stG left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review

The blocker is fixed and the review nits are addressed.

  • [email protected] now applies the discovered [[overrides]]: verified end-to-end (base indent-width = 4, override 6 for both *.toml and **/*.toml → "[t]\n key = 1\n"), with no abort (async and sync).
  • npx vitest run packages/toml → 20/20, including the new overrides.spec.ts; build:ts, lint:tsc and eslint clean, CI matrix green.
  • README precedence list now reads correctly (base → overrideConfig → per-file [[overrides]]).
  • Nits covered: the no-filepath test chdirs to a temp dir, and index.spec.ts asserts the synthetic stdin.toml + overrideConfig.
  • The precedence behavior change and the minor changeset decision are now explicitly documented in the PR body — owner's call, fine.

Non-blocking: codecov/project is still red (92.25% → 89.70%, from deleting the well-covered discovery layer); it isn't a required check, so not blocking.

LGTM.

@JounQin
JounQin merged commit 4ad8ffe into master Oct 19, 2026
42 of 44 checks passed
@JounQin
JounQin deleted the feat/tombit-0.1.1 branch October 19, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gitar-approved Added by Gitar

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants