Skip to content

fix(lib): unify tombi-lib and wasm-lib interfaces - #2242

Merged
ya7010 merged 2 commits into
mainfrom
ya7010/unify-lib-interfaces
Sep 29, 2026
Merged

ya7010 merged 2 commits into
mainfrom
ya7010/unify-lib-interfaces

Conversation

@ya7010

@ya7010 ya7010 commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Aligns the public interfaces of the Python/Node.js tombi-lib and @tombi-toml/wasm-lib, which share the rust/tombi-lib core. The sync/async naming (format is sync in Python, a Promise in JS) is left as-is, since each follows its language's convention.

  • Python
    • Position/Range are now importable from tombi_lib. The stub declared them, but __init__.py didn't re-export them, so from tombi_lib import Position failed at runtime.
    • Added ConfigFile/Options TypedDicts in _options.py, re-exported at runtime, and used them for the options argument.
    • Diagnostic.level is now typed as Literal["error", "warning"].
  • JS (Node.js / wasm)
    • Diagnostic.source_file is renamed to sourceFile to follow the JS naming convention. It is still null, not missing, when there is no source file.
  • wasm-lib
    • Added the ConfigFile interface shared with @tombi-toml/lib, and typed Options.config as string | ConfigFile. Config stays as a @deprecated alias.

Breaking change

Diagnostic.source_file becomes sourceFile in @tombi-toml/wasm-lib / tombi-wasm-lib, which shipped source_file in 1.5.8. @tombi-toml/lib is unreleased, so it is unaffected.

Validation

  • pnpm --dir typescript/@tombi-toml/lib build && pnpm --dir typescript/@tombi-toml/lib test (8 pass; regenerated binding.d.ts matches the committed file)
  • pnpm --dir typescript/@tombi-toml/wasm-lib build && pnpm --dir typescript/@tombi-toml/wasm-lib test
  • uv run --frozen --package tombi-lib pytest python/tombi-lib/tests (8 passed)
  • ruff format --check / ruff check --no-fix
  • cargo fmt --all --check, cargo clippy -p tombi-lib-node -p tombi-diagnostic -p tombi-lib -p tombi-lib-python --features tombi-diagnostic/wasm -- -D warnings
  • tsc --strict --noEmit against both packages' .d.ts
  • The Python stub was not checked with pyright/mypy.

🤖 Generated with Claude Code

ya7010 and others added 2 commits September 29, 2026 23:53
- Python: export `Position`/`Range` from `tombi_lib` (they were only
  declared in the stub), add `ConfigFile`/`Options` TypedDicts, and type
  `Diagnostic.level` as `Literal["error", "warning"]`.
- JS (Node.js/wasm): rename `Diagnostic.source_file` to `sourceFile`.
- wasm-lib: add the `ConfigFile` type shared with `@tombi-toml/lib`, and
  keep `Config` as a deprecated alias.

BREAKING CHANGE: `Diagnostic.source_file` is now `sourceFile` in
`@tombi-toml/wasm-lib` / `tombi-wasm-lib`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 14:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

各言語の実装・型定義・実行時テストが整合しており、未解決の問題は確認されませんでした。

Review effort: Balanced
Findings: None

What changed in this PR

Python・Node.js・WASM の公開 API を統一する変更です。

Changes:

  • Python の型・公開エクスポートを整備
  • JS の Diagnostic.sourceFile を camelCase に統一
  • WASM の設定型を Node.js API と整合
File Description
crates/​tombi-diagnostic/​src/​lib.rs WASM 診断を camelCase で直列化
rust/​tombi-lib-node/​src/​lib.rs Node.js の診断フィールド名を更新
rust/​tombi-wasm/​tests/​lib-smoke.mjs WASM の sourceFile を検証
typescript/​@tombi-toml/​lib/​binding.d.ts 生成済み Node.js 型定義を更新
typescript/​@tombi-toml/​lib/​tests/​smoke.test.mjs Node.js の新フィールド名を検証
typescript/​@tombi-toml/​wasm-lib/​types.d.ts 診断・設定型を統一
python/​tombi-lib/​src/​tombi_lib/​_options.py Python の設定用 TypedDict を追加
python/​tombi-lib/​src/​tombi_lib/​__init__.py 新しい公開型を実行時に再エクスポート
python/​tombi-lib/​src/​tombi_lib/​__init__.pyi Python スタブを精密化
python/​tombi-lib/​tests/​tombi_lib/​test_lint.py Position・Range の公開を検証

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ya7010
ya7010 merged commit 126a2a0 into main Sep 29, 2026
34 checks passed
@ya7010
ya7010 deleted the ya7010/unify-lib-interfaces branch September 29, 2026 15:15
ya7010 added a commit that referenced this pull request Sep 29, 2026
* fix(wasm-lib): keep Diagnostic.source_file as a deprecated alias

#2242 renamed `Diagnostic.source_file` to `sourceFile`, but
`@tombi-toml/wasm-lib` / `tombi-wasm-lib` have shipped `source_file`
since #2105. Serialize both keys with the same value and mark
`source_file` as `@deprecated`, like `TombiWasmError` and `Config`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(wasm): split lint out of formatter.rs (#2244)

`formatter.rs` defined both `format` and `lint`. Move `lint` to
`linter.rs`, and the JS <-> `tombi_lib` conversions both use
(`serialize`, `tombi_error`, `deserialize_options`) to `convert.rs`.
No behavior change.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@ya7010 ya7010 changed the title fix(lib)!: unify tombi-lib and wasm-lib interfaces fix(lib): unify tombi-lib and wasm-lib interfaces Sep 29, 2026
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.

2 participants