Skip to content

audit-dead-code: detect dead code in JS/TS outside a package.json root #4522

Description

@kyle-sexton

Summary

code-tidying:audit-dead-code 0.23.2 detects dead JS/TS only through knip, and knip runs only
under a package.json root. Standalone scripts get no dead-code check at all. Examples are
.github/scripts/*.mjs, CI helpers, and dotfiles tooling. This is common in org .github, CI, and
config repos.

In melodic-software/.github, a manual whole-word grep found contentsUrl and runLiveCheck in
.github/scripts/pr-section-drift.mjs. Both are exported but used only inside that file. The skill
never saw the file.

Fix

Options, cheapest first. Measure precision on the trap fixtures before choosing a tier.

  1. Grep-lane fallback. Only shell|pwsh files enter the grep lane (scripts/dead-code-scan.sh:225),
    and dc_symbol_defs extracts definitions only for those two
    (scripts/lib/dead-code-shapes.sh:442-469). The repo-wide reference search already covers every
    tracked file (scan:638-640). Route TS/JS files that no package.json root owns to the grep
    lane, and add a definition regex for function, class, const and export declarations.
  2. knip without a manifest. Check whether knip can run over loose files with a generated
    temporary config outside the repo. Not verified.
  3. Exports used only in their own file. Report them at the lowest tier from whichever lane
    covers the file. Whether knip itself flags them by default is not verified.

Verification

  • Done when a fixture with a standalone .mjs that holds one unreferenced function produces a
    candidate for it, and a referenced function does not.
  • Precision is measured on the existing trap-fixture corpus and recorded in the SKILL.md lane table.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageNot yet classified. Floor until a type and one priority tier are set.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions