Recognize .mts and .cts TypeScript modules - #21
Open
shashwat4543 wants to merge 6 commits into
Open
Conversation
Added agent_prompt.mts to the manifest with expectations and reasoning for TypeScript rules.
Updated changelog to include TypeScript source discovery mapping.
Removed the section about recognizing '.mts' and '.cts' extensions from the GOOD_FIRST_ISSUES document.
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.
What changed
Source discovery now treats
.mtsand.ctsfiles as TypeScript sources, matching Node'smodern ESM/CJS TypeScript module extensions.
LANGUAGES[".mts"]andLANGUAGES[".cts"]nowmap to
"typescript". No rule-level changes were needed:RuleMetadata.languagesgates onthe
typescriptlabel, not the extension, and every TypeScript-aware rule (AG002, AG004,AG006, AG007, AG008) already declares
"typescript".Threat model or motivation
Projects increasingly split TypeScript sources into
.mts(ESM) and.cts(CJS) files,especially for dual-published Node packages. Previously these were silently skipped during
discovery — meaning unsafe patterns (shell execution, unsafe fetch, missing tool validation,
prompt injection, etc.) inside those files produced no findings. This closes that discovery
gap with no change to trust boundaries or rule logic.
Validation
make checkpassesAdded
tests/test_discovery.py(parametrized over.mts/.cts):.mts/.ctsis scanned and detected (AG002)LANGUAGES[".mts"]/LANGUAGES[".cts"]equal"typescript"node_modules/) are still skipped.mts/.ctsfiles still respectmax_file_size_kbAdded
tests/corpus/true_positives/agent_prompt.mts, a labelled corpus case, so coverage ismeasured rather than assumed: an ESM module with
web_contentinterpolated into atemplate-literal prompt, expecting AG004. This is deliberately a different rule than the
existing
.tsfixture (agent_tools.ts, AG002) — the point is to pin that TypeScript-awarerules in general stay wired up for the new extensions, not just the one rule already
covered.
make benchnow shows AG004 at 2 true positives (up from 1) with no new falsepositives.
Updated
CHANGELOG.mdunder[Unreleased]and removed the corresponding entry fromdocs/GOOD_FIRST_ISSUES.mdsince it's now implemented.Related issue
Closes #11