Skip to content
Fallow home
All docs pages

Docs home

How fallow reads Vue, Svelte, Astro, MDX, HTML and CSS files

Which file types fallow analyzes besides JavaScript and TypeScript, what it reads from each type, and what it reports.

Your project has an HTML page, a Vue component or a stylesheet next to its TypeScript, and you want to know what fallow reports for these files. At the end of this guide, you can predict the findings for each file type, and you can correct a result that surprises you.

The question matters, because a tool that reads only .ts files sees no use of a file that only a stylesheet or a template uses. Fallow picks the parser for a file from its extension, with no plugin and no config. So a file that only an HTML page, a Vue template or a stylesheet uses is not unused.

Before you start

  • Read Entry points and reachability: a file is used when an entry point reaches it.
  • Install the dependencies. The plugins that make files such as index.html entry points turn on from package.json.

Steps

1. Find the row of your file type

File typeExtensionsWhat fallow readsWhat fallow reports
JavaScript and TypeScript.js .jsx .mjs .cjs .ts .tsx .mts .ctsImports, exports, require(), dynamic imports, and JSDoc import() typesEach dead code issue type
Vue.vueEach <script> block, and the names that the <template> usesUnused files and unused exports
Svelte.svelteEach <script> block, and the names that the markup usesUnused files. No unused exports.
Astro.astroThe frontmatter, and the client scripts in the bodyUnused files and unused exports
MDX.mdxThe import and export lines, and the names that the content usesUnused files and unused exports
HTML.html<script src>, <link rel="stylesheet"> and <link rel="modulepreload">Unused files
CSS, Sass, Less.css .scss .sass .less@import, @use, @forward, Tailwind directivesUnused files. In a CSS module, unused classes.
GraphQL.graphql .gqlRelative #import linesUnused files
Glimmer.gjs .gtsThe script, and the names that each <template> usesUnused files and unused exports

Fallow does not analyze other files, for example .json and .md files. It never reports them as unused. An import of a .json file resolves like any other import.

2. Run fallow and read the findings

The table is easier to trust when you see it on real files. This example adds a Vite and Vue front end to the demo project: vite and vue in package.json, a dev script that runs vite, an index.html, and these files under src/web/:

index.html                          loads /src/web/main.ts and /src/web/styles/global.css
src/web/main.ts                     imports OrderCard.vue and graphql/orders.graphql
src/web/components/OrderCard.vue    uses formatDate and styles.root in its template
src/web/dates.ts                    exports formatDate and formatTime
src/web/styles/card.module.css      defines .root and .shadow
src/web/graphql/orders.graphql      #import "./order-fields"
src/web/graphql/order-fields.graphql
src/web/graphql/old-orders.graphql
src/web/OldBanner.svelte
npx fallow dead-code --unused-files --unused-exports
  4 entry points detected (2 package.json, 2 plugin)

── Unused Code ─────────────────────────────────────

● Unused files (3)
  src/utils/legacy-currency.ts
  src/web/OldBanner.svelte
  src/web/graphql/old-orders.graphql
  Files not reachable from any entry point
  https://fallow.tools/docs/explanations/dead-code/#unused-files
  To suppress: // fallow-ignore-file unused-file

● Unused exports (5)
  src/lib/format.ts
    :3 formatPercent
  src/lib/index.ts
    :1 formatPercent (re-export)
  src/services/orders.ts
    :18 cancelOrder
  src/web/dates.ts
    :3 formatTime
  src/web/styles/card.module.css
    :3 shadow
  Exported symbols with no known consumers
  https://fallow.tools/docs/explanations/dead-code/#unused-exports
  To auto-fix: fallow fix --dry-run
  To suppress: // fallow-ignore-next-line unused-export

✗ 3 files · 5 exports (0.04s)

The findings in src/utils/, src/lib/ and src/services/ are the findings of the demo. The new findings come from the front end. Read them together with the files that are not in the list:

  • global.css is used, because index.html loads it. The Vite plugin makes index.html an entry point, so the entry point count goes from 3 to 4.
  • formatDate is used, because the template of OrderCard.vue calls it. The script block alone does not use it.
  • .shadow is an unused export of the CSS module. Fallow treats each class of a .module.css file as an export.
  • order-fields.graphql is used through #import "./order-fields". Fallow tries .graphql and .gql for a path without an extension.
  • OldBanner.svelte and old-orders.graphql are unused files, because no file loads them.

3. Read the notes for your file type

The run above shows the common case of each file type. Each type also has rules that decide the edge cases, for example a Svelte prop or a path that starts with /.

Vue and Svelte

Fallow parses <script> and <script setup>, also with lang="ts". In the template, it counts component tags, directives and expressions as uses of the imported names. A name that only the template uses is therefore used, and that is why formatDate in the run above is not in the list.

A Svelte component declares its props as exports. Fallow cannot tell a prop from a helper export, so it does not report unused exports of a .svelte file. Put helpers in a .ts file, where fallow checks them.

Astro

Fallow parses the frontmatter between the two --- lines as TypeScript. It also follows <script src> and the imports of inline <script> blocks, because Astro bundles them into the page. Health scores the functions of inline scripts.

HTML

An HTML file is reachable only when an entry point or a plugin names it. The Vite and Parcel plugins make index.html an entry point. Fallow resolves a path that starts with / against the directory of the HTML file, then the nearest package directory, then the project root, then public/. In the demo, index.html is in the project root, so /src/web/main.ts resolves at the first step.

fallow health also reports the complexity of Angular templates: external .html templates and inline template strings.

Fallow reads the same tags in an html`...` tagged template in JavaScript and TypeScript, for example in a Hono layout. In JSX, <script src> is a string, so fallow does not follow it.

CSS

Fallow reads the import rules and treats a CSS module class as an export. A class inside :global(...) is not an export, because the CSS module does not rename it. An @apply or @tailwind directive counts as a use of tailwindcss. A Tailwind @plugin directive counts as a use of its package or file. Styling covers the analysis of the classes themselves.

MDX and Markdown

Fallow adds the import and export lines of an .mdx file to the module graph. It does not read .md files, so it does not see the <script setup> of a VitePress page. A module that only a .md page imports is reported as unused. Add it to entry.

JSDoc in JavaScript

In a JavaScript file, fallow reads the import() types of /** */ comments, for example @param {import('./types').Config} cfg. The type then counts as used. Fallow ignores /* */ comments.

React Native

The suffixes .ios, .android, .native and .web have a meaning only when the react-native or expo plugin is active:

Import in the codeWith the pluginWithout the plugin
./ButtonEach file of the set is reachable: Button.tsx, Button.ios.tsx, Button.android.tsx, Button.native.tsx and Button.web.tsx.Only Button.tsx is reachable. The platform files are unused files. Without Button.tsx, the import is an unresolved import.
./Button.iosOnly Button.ios.tsx is reachable.Only Button.ios.tsx is reachable.

The expo-router plugin does not turn on platform files. An Expo Router app gets them through its react-native dependency.

Check the result

Run npx fallow dead-code again after each change. A file that an HTML page, a template or a stylesheet uses is not in the list of unused files. To see which file keeps it in use, trace it:

npx fallow dead-code --trace-file src/web/styles/global.css
  REACHABLE src/web/styles/global.css

  Imported by (1):
    -> index.html

If it fails

When a result still surprises you, the cause is usually a file that no entry point names, or a use that fallow cannot read:

ProblemCauseFix
A file that an HTML page loads is unused.No entry point or plugin names the HTML file.Add the HTML file to entry.
An import that a template uses is unused.The template uses the name in a way that fallow does not read, for example a computed component name.Trace the export, and suppress it when the use is real.
An unused helper in a .svelte file is not reported.Fallow does not check the exports of Svelte files.Move the helper to a .ts file.