feat(spec): port isValidCnpj to the bridge - #581
hyanmandian wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Tree-shaking report✅ No bundle size impact. All 155 exports are the same size as on the base branch (full import 648.9 KB, gzip 166.2 KB). All exports (155)
How this is measuredEvery export is imported alone into an esbuild consumer bundle (minified, tree-shaken) built from the head and from the base of this pull request; the sizes are the resulting bundles, gzip is their gzipped size. 🔴 marks a regression: a pre-existing export that grew more than 20% and more than 256 B, or the bundle importing every pre-existing export growing more than 5%. 🟡 is growth under the threshold, 🟢 a decrease, ⚪ no change, 🆕 an export that does not exist on the base (never a regression), 🗑️ an export that was removed. An intentional increase is accepted with the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude/single-impl-multi-lang-fftjdk #581 +/- ##
======================================================================
Coverage 100.00% 100.00%
======================================================================
Files 183 183
Lines 2069 2069
Branches 612 612
======================================================================
Hits 2069 2069
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The first utility through the compiler, and the one that exercises the parts a validator
needs: two compiled regular expressions, a check digit pass over both CNPJ versions, and the
`typeof` guard that makes a number invalid in JavaScript.
The CNPJ rules that `formatCnpj` will also need — the two shapes a CNPJ can be written in,
the weight vectors, the check digits — go under `source/_internals/`, written once. The
compiler inlines them into this utility and prunes the rest, so the emitted module carries
what it uses and nothing else.
The corpus is every string literal in the package's own CNPJ test files, plus generated
CNPJs, masked variants, one-digit mutations and the numbers a JavaScript caller can pass
where a string is declared, under all three option sets. The generator is seeded, so the
table is the same on every run.
typescript 1725/1725 python 1725/1725 ruby 1725/1725
go 1707/1707 rust 1707/1707 java 1707/1707
csharp 1707/1707 cabi 1707/1707
The eighteen the compiled targets do not run are the numeric inputs: they declare the
parameter as a string, so `isValidCnpj(12345678000195)` is a question that cannot be asked
there. The row records that rather than dropping it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UX1gTGeMTyoXQyr1qUoQKd
403fb0d to
4de5b16
Compare
72a3a71 to
f701ac0
Compare
|
The red Everything on GitHub Actions is green or still running, and this PR touches nothing under Generated by Claude Code |
|
Closing this one: the stack is being collapsed into #580 at the author's request. Nothing is lost — this PR's commit ( Generated by Claude Code |
What does this PR do?
Stacked on #580 (the compiler). Review that one first; this PR's diff is only what
isValidCnpjadds.The first utility through the bridge, and the one that exercises what a validator needs: two compiled regular expressions, a check digit pass over both CNPJ versions, and the
typeofguard that makes a number invalid in JavaScript.The diff, in full
source/is-valid-cnpj.tssource/_internals/cnpj.tsformatCnpjwill also need, written onceconformance/cases/is-valid-cnpj.tsconformance/cases/_cnpj-corpus.tsformatCnpjNo driver, no emitter change, no compiler change. That is the point: the table's columns come from the compiled signature, the expectation comes from calling the shipped package, and the replay program for each of the eight targets is generated.
Sharing without coupling
The check digit rules go under
source/_internals/. The compiler inlines them into whichever utility imports them and prunes whatever that utility cannot reach, so the emitted module carries what it uses and nothing else — no cross-module import in any of the seven targets, and nothing for a bundler to have to see through.Parity
The corpus is every string literal in the package's own CNPJ test files, plus 120 generated CNPJs, masked variants, one-digit mutations, and the numbers a JavaScript caller can pass where a string is declared — under all three option sets.
Math.randomis seeded while it is built, so the table is identical on every run.bash spec/bridge/conformance/run-all.sh:The eighteen are the numeric inputs. Go, Rust, Java and C# declare the parameter as a string, so
isValidCnpj(12345678000195)is a question that cannot be asked there; the row records which targets can be handed it rather than dropping the case.bash spec/bridge/conformance/verify-typescript.sh— the generated TypeScript dropped intosrc/, running the package's own suite unmodified:Checklist
npm test) — not applicable: no change tosrc/. The generated output is checked against the package's existing suite byverify-typescript.sh, and against a recording of the shipped package byrun-all.sh.npm run checkpasses locally (format, lint, types).npm run build:llmsif I toucheddocs/utilities.md— not applicable,docs/untouched.🤖 Generated with Claude Code
https://claude.ai/code/session_01UX1gTGeMTyoXQyr1qUoQKd
Generated by Claude Code