Skip to content

refactor(core): reuse formatter file extension - #46080

Merged
kitlangton merged 1 commit into
v2from
formatter-extension
Aug 31, 2026
Merged

kitlangton merged 1 commit into
v2from
formatter-extension

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Each formatting request recalculates the same filename extension for every registered formatter. The extension depends only on the requested path.

What Changes

Compute path.extname(filepath) once before selecting matching formatters. Matching remains case-sensitive and uses the same Node path semantics, registry order, and first-success/fallback behavior.

Scope

The matching expression and focused matching tests only. Command resolution, process execution, timeout policy, and error handling are unchanged.

Verification

cd packages/core
bun run test test/formatter.test.ts
bun typecheck
cd ../..
bunx prettier --check packages/core/src/formatter.ts packages/core/test/formatter.test.ts
git diff --check HEAD^ HEAD

17 tests passed with 24 assertions. New real-harness cases cover matching/nonmatching extensions, case sensitivity, dotfiles, extensionless files, and multi-dot names. Core typechecking, formatting, and whitespace checks passed.

@kitlangton
kitlangton merged commit 327dc80 into v2 Aug 31, 2026
10 checks passed
@kitlangton
kitlangton deleted the formatter-extension branch August 31, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant