npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

find-unused-sass-variables

v6.2.1

Published

A small tool to find unused Sass variables

Readme

find-unused-sass-variables

npm version Build Status

A small tool to find unused Sass variables in a directory.

Install

npm install find-unused-sass-variables --save-dev

CLI

Usage

fusv <folders...> [options]
# or the full alias
find-unused-sass-variables <folders...> [options]

One or more folder paths can be passed at once.

Options

| Flag | Alias | Description | Default | |---|---|---|---| | --ignore <variables> | -i | Comma-separated variable names to skip (e.g. $my-var,$another) | - | | --ignoreFiles <files> | -if | Comma-separated file glob patterns to skip (e.g. **/_variables.scss) | - | | --extension [types...] | -e | File extension(s) to scan. Repeatable or comma-separated. | scss | | --help | | Print help | - |

Examples

# Scan a single folder
fusv src/

# Scan multiple folders
fusv src/ themes/

# Ignore specific variables
fusv src/ --ignore='$my-var,$another-var'

# Ignore files matching a glob
fusv src/ --ignoreFiles='**/_variables.scss'

# Scan .scss and .css files
fusv src/ -e scss -e css

# Combine options
fusv src/ --ignore='$unused' --ignoreFiles='**/vendor/**' -e scss -e sass

Shell quoting On Unix/macOS, quote the value to prevent the shell from expanding $ (e.g. --ignore='$my-var'). On Windows CMD, no quoting is needed (e.g. --ignore=$my-var).

Exit codes

| Code | Meaning | |---|---| | 0 | No unused variables found | | 1 | One or more unused variables found (or an error occurred) |

API

import { find, findAsync } from 'find-unused-sass-variables';

find(dir, options?)

Synchronous. Scans dir and returns the result immediately.

find(dir: string, options?: Options): Result

findAsync(dir, options?)

Asynchronous. Same behaviour as find, but returns a Promise.

findAsync(dir: string, options?: Options): Promise<Result>

Options

| Property | Type | Description | Default | |---|---|---|---| | ignore | string[] | Variable names to skip, e.g. ['$my-var', '$brand-color'] | [] | | ignoreFiles | string[] | File glob patterns to skip, e.g. ['**/_variables.scss'] | [] | | fileExtensions | string[] | Extensions to scan (leading dot optional), e.g. ['scss', 'css'] | ['scss'] |

Return value

Both functions return (or resolve to):

| Property | Type | Description | |---|---|---| | unused | { name: string, file: string, line: number }[] | Variables declared but never referenced | | total | number | Total variables found across all scanned files |

Each entry in unused:

| Field | Type | Description | |---|---|---| | name | string | Variable name, e.g. '$my-color' | | file | string | Path to the file containing the variable | | line | number | Line number of the variable |

Examples

Synchronous

import { find } from 'find-unused-sass-variables';

const result = find('src/');
console.log(result.total);   // total variables found
console.log(result.unused);  // [{ name: '$unused-color', file: 'src/_colors.scss', line: 12 }, ...]

Asynchronous

import { findAsync } from 'find-unused-sass-variables';

const result = await findAsync('src/');
console.log(result.total);
console.log(result.unused);

With options

import { find } from 'find-unused-sass-variables';

const result = find('src/', {
  ignore: ['$my-var', '$brand-color'],
  ignoreFiles: ['**/_variables.scss', '**/vendor/**'],
  fileExtensions: ['scss', 'css']
});

Disable and enable scanning

Wrap any region with fusv-disable / fusv-enable comments to exclude those variables from analysis. Both inline (//) and block (/* */) comment styles are supported.

$used-variable-1: #666;

// fusv-disable
$intentionally-unused: #coffee; // will NOT be reported
// fusv-enable

$used-variable-2: #ace;
/* fusv-disable */
$intentionally-unused: #coffee;
/* fusv-enable */

Notes

  • The tool's logic is pretty "dumb"; if you use the same name for a variable in different files or namespaces, then it won't distinguish between them.
  • The tool only looks for .scss files by default, but you can optionally specify the file extensions.

License

MIT