File Usages
Find every import, url() and link that points at a file. VS Code's Find All References works for symbols, not for files, so you cannot ask who uses an image, a stylesheet or a module before you rename or delete it. File Usages answers that, locally and read-only.
What It Does
- Right-click a file in the Explorer, or a tab title, and choose File Usages: Find References to This File. The palette command does the same for the active file, including images and other non-text tabs.
- Results appear in the File Usages view in the Explorer, grouped by the file that refers to the target. Each result reads
line: preview with the reference highlighted. Click it to open the file with the reference selected.
- Understands the usual ways one file points at another:
- JavaScript and TypeScript:
import ... from, export ... from, side-effect import "x", require(), require.context(), dynamic import(), new URL("...", import.meta.url) and test mocks such as jest.mock() and vi.mock(). In .jsx and .tsx also <img src="https://github.com/toolsmith-labs/support/raw/HEAD/..."> and src={"..."}.
- CSS, SCSS, Sass and LESS:
@import (including lists such as @import "a", "b" and options such as (reference)), @use, @forward and url(...).
- HTML, Vue, Svelte and Astro:
src, href, poster, data-src, xlink:href, every srcset candidate and url() inside style="...", with double, single or no quotes, plus the <script> and <style> blocks.
- Markdown: links (targets may hold balanced parentheses, as in
[a](https://github.com/toolsmith-labs/support/blob/HEAD/foo(1).md)), images (also an image inside a link, as in badges), reference definitions, autolinks such as <./notes.md> and inline HTML such as <img src="https://github.com/toolsmith-labs/support/raw/HEAD/...">.
- Astro: the
--- frontmatter is read as JavaScript. MDX: import and export blocks are read as JavaScript.
- Resolves paths the way each language does. A path is relative to the referencing file,
/x.png is also tried in the workspace root and in the public and static folders next to the file or above it, and ?query, #hash and %20 are handled.
- JS imports and
require may leave out the extension (.ts, .tsx, .d.ts, .js, .jsx, .mjs, .cjs, .json, .vue, .svelte, .css, .scss, .sass, .less), may name a folder (index.*) and may write .js for a .ts or .d.ts file.
- Sass and LESS imports may leave out the style extension, use partials (
_name.scss) and name a folder (index or _index).
- Paths in JSON files may leave out
.json or name a folder that holds package.json or index.json, so "extends": "./tsconfig.base" finds tsconfig.base.json.
- Everything else (
new URL, url(), src, Markdown links, YAML) must name the file, so [docs](https://github.com/toolsmith-labs/support/blob/HEAD/api) does not match api.ts.
- Matching ignores case on Windows and macOS.
- Never changes anything. It does not rename, move, delete or edit files.
Features (Free vs Pro)
| Feature |
Free |
Pro |
| Find references to one file from JS/TS, CSS/SCSS/LESS, HTML/Vue/Svelte and Markdown |
Included |
Included |
| Relative paths, implicit extensions, index files, query and hash handling |
Included |
Included |
Results view with highlighted line: preview and click to open |
Included |
Included |
tsconfig.json and jsconfig.json paths and baseUrl (comments allowed, extends followed up to 5 levels inside the workspace) |
Not applied |
Included |
fileUsages.aliases for Vite and webpack style aliases |
Not applied |
Included |
| References from relative-path-looking strings in JSON and YAML files |
Not applied |
Included |
| Folder impact scan: every reference from outside a folder into it |
Upgrade prompt |
Included |
| Orphan finder: files in a folder that nothing references |
Upgrade prompt |
Included |
| Export results to Markdown or CSV in an untitled document |
Upgrade prompt |
Included |
Commands
fileUsages.findReferences (File Usages: Find References to This File): Explorer, tab title and palette.
fileUsages.scanFolderImpact (File Usages: Folder Impact Scan (Pro)): Right-click a folder, or pick one from the palette. Lists references from files outside the folder to anything inside it, which is what a move or delete would break.
fileUsages.findOrphans (File Usages: Find Orphan Files in Folder (Pro)): Lists files under a folder with no static reference from anywhere in the workspace. Nothing is deleted.
fileUsages.exportReport (File Usages: Export Results (Pro)): Opens the current results as Markdown or CSV in an untitled document. CSV cells that start with =, +, -, @, a tab or a carriage return get a leading ' so spreadsheets do not run them. A scan note, such as files that were unread, goes on a leading # comment line, not in a data row.
file-usages.enterLicense (File Usages: Enter License Key): Activates a Pro license key in VS Code SecretStorage.
Settings
fileUsages.maxFiles (number, default 20000): Most source files read in one search. Only files that can contain references count (code, styles, markup, Markdown and, with Pro, JSON and YAML), not images or other assets. A search stops there and says so. The orphan finder refuses to run past it, because a partial scan cannot prove a file is unreferenced.
fileUsages.maxFileSizeKB (number, default 1024): Source files larger than this are skipped without being read.
fileUsages.aliases (object, default {}, Pro): Aliases such as { "@/*": "src/*", "~assets": "src/assets" }. Targets are relative to the workspace folder.
file-usages.apiBaseUrl (string, default ""): Override the licensing API base URL (must use https://, machine-scoped).
file-usages.webBaseUrl (string, default ""): Override the web storefront base URL (must use https://, machine-scoped).
Invalid values for the two caps (not a finite number, below 1) fall back to the defaults, and very large values are clamped. In untrusted workspaces the workspace-level values of the caps are ignored.
What Is Scanned
- Files come from the workspace folder that contains the file you picked. In a multi-root workspace each folder is searched on its own.
- Excluded: your
files.exclude and search.exclude entries, and always node_modules, .git, dist, build, out and coverage.
- Every file in the folder is listed, so any file can be a target. Only files with a supported extension are read: JS/TS (
.js .jsx .mjs .cjs .ts .tsx .mts .cts), styles (.css .scss .sass .less), markup (.html .htm .xhtml .svg .vue .svelte .astro), Markdown (.md .markdown .mdx) and, with Pro, .json .jsonc .yaml .yml.
- Binary files and files over
fileUsages.maxFileSizeKB are not read. The view and every export say how many files were unread, so results are never presented as complete when they are not.
- Markdown and YAML lines longer than 10,000 characters are ignored, and the view and every export say how many ("N long lines skipped").
- Unsaved edits in open editors are used instead of the version on disk.
- To stay quick, a file is parsed only if its text contains the target's name without extension (or a known alias for it). Index files are parsed everywhere, because folder imports reach them without naming them.
- Comments are skipped, and regular expression literals are recognised so that a slash inside one is not taken for a comment.
- The search is cancellable from its progress notification.
Known Limits
- Only static references are found. Paths built at run time (
import(`./locales/${lang}.json`)), glob imports and framework conventions such as file-based routes are not.
- The orphan finder is a hint, not a verdict. Entry points, config files, dynamically loaded modules and files used from outside the workspace show up as orphans. A group of files that only reference each other is not reported.
- A bare name such as
lodash in a JS import is a package and is skipped unless an alias or tsconfig mapping claims it. In HTML, CSS, Markdown and JSON a bare path such as assets/logo.png is read as relative to the file.
- References inside Markdown code spans and fences, and in strings that look like code, can be reported.
- Fenced code in Markdown and MDX is not excluded, so an
import line inside a fence can be reported.
- An attribute value that spans several lines (other than
srcset and style) is not read.
Privacy and Data Handling
| Data |
Where |
Retention |
| Your files and results |
Read and shown locally. Nothing is stored or sent |
Not applicable |
| License key, product ID, machine ID hash |
Sent to the licensing API (file-usages.apiBaseUrl) only when you activate or refresh a Pro license |
Active license lifetime |
| Telemetry |
None. File Usages sends no usage data and has no telemetry setting |
Not applicable |
Offline Behaviour
Searching, the view, folder impact, orphans and export all work with no network. The only network use is the licensing API, and only when you activate or refresh a Pro license. Paid licenses are verified offline using the bundled Ed25519 public key with a 14-day grace period.
Pricing
File Usages is free to use. Pro adds alias and tsconfig resolution, JSON and YAML references, folder impact, the orphan finder and export.
- Pro: $4/month or $36/year
- All Access (every Toolsmith Labs extension): $12/month or $99/year
View plans and buy. After purchase, sign in to your account to copy your license key, then run File Usages: Enter License Key.
Support
Report issues or request help at github.com/toolsmith-labs/support. For billing or license questions, email jashambaliya05@gmail.com.
| |