feat: export script names and analyzer constants - #14
Merged
Conversation
Callers writing rules against dominantScript or expectedScripts had no way to know the actual values — they had to hardcode strings and hope. Export what the analysis already knows: SCRIPT_NAMES (every value a finding can report), SUPPORTED_SCRIPTS, PSEUDO_SCRIPTS, FORMAT_CHAR_SCRIPTS, LEGITIMATE_SCRIPT_COMBINATIONS, ZALGO_MARK_RUN and primaryScript(). Script-typed fields move from string to the ScriptName union, so a typo like expectedScripts: ['Cyrilic'] fails to compile instead of silently matching nothing. Runtime behavior is unchanged. Each constant is tested against the behavior it describes, so a constant cannot drift from the analyzer without a red test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Callers writing rules against
dominantScriptorexpectedScriptshad no way to discover the actual values — they had to hardcode strings and hope. This exports what the analysis already knows.New exports
SCRIPT_NAMESdominantScriptandwords[].scriptsSUPPORTED_SCRIPTSPSEUDO_SCRIPTSCommon,Inherited,Unknown— never appear in a findingFORMAT_CHAR_SCRIPTSinvisible/zalgoLEGITIMATE_SCRIPT_COMBINATIONSmixed_scriptZALGO_MARK_RUNzalgofiresprimaryScript(char)ScriptName,PseudoScriptType narrowing
AnalysisResult.dominantScript,WordFinding.scriptsandAnalyzeOptions.expectedScriptsmove fromstringtoScriptName. Runtime behavior is unchanged, but TS callers passing a plainstring[]toexpectedScriptsnow needScriptName[]— which is the point:expectedScripts: ['Cyrilic']no longer compiles silently matching nothing.Testing
test/exports.test.tsties each constant back to the behavior it claims to describe —ZALGO_MARK_RUNis asserted as the depth at which the signal flips,FORMAT_CHAR_SCRIPTSagainst a Persian ZWNJ passing and a Latin one failing — so a constant cannot drift from the analyzer without a red test. The README example runs intest/readme.test.tsper repo convention.275 tests pass; typecheck, lint and build clean. Changeset included (minor).
🤖 Generated with Claude Code