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

test-filestructure-linter-cli

v1.0.3

Published

CLI tool for test filetructure linting

Readme

Test Filestructure Linter CLI

A command-line interface for analyzing and fixing test file structure in .NET solutions.

Installation

npm i test-filestructure-linter-cli

Usage

test-filestructure-linter -s <src-root> -t <test-root> [options]

Options

Required:
  -s, --src-root <path>           Source files root directory
  -t, --test-root <path>          Test files root directory

Validation:
  -n, --name                      Enable filename validation
  -d, --dir                       Enable directory structure validation
  -m, --missing                   Enable validation of missing test files

Fix modes:
  -a, --all                       Fix all directory structure issues
  -f, --fix <path>               Fix a specific test file
  -i, --interactive              Interactive mode - select files to fix

Filtering:
  --ignore-directories <list>     Comma-separated list of directories to ignore
  --ignore-files <list>           Comma-separated list of files to ignore

Output:
  -o, --output [path]            Output JSON report to file
                                 If path is omitted, defaults to:
                                 test-filestructure-linter-results/result-<datetime>.json

Other options:
  -e, --ext <ext>                File extension to analyze (default: ".cs")
  --test-suffix <suffix>          Test file suffix (default: "Tests")
  --test-project-suffix <suffix>  Test project suffix (default: ".Tests")
  -h, --help                     Display help
  -V, --version                  Display version

Examples

# Basic analysis (no validations enabled)
test-filestructure-linter -s ./src -t ./tests

# Enable specific validations
test-filestructure-linter -s ./src -t ./tests -d
test-filestructure-linter -s ./src -t ./tests -n
test-filestructure-linter -s ./src -t ./tests -m

# Enable all validations
test-filestructure-linter -s ./src -t ./tests -d -n -m

# Fix all directory structure issues
test-filestructure-linter -s ./src -t ./tests -d -a

# Fix specific file
test-filestructure-linter -s ./src -t ./tests -d -f ./tests/Wrong/Path/MyTests.cs

# Interactive mode
test-filestructure-linter -s ./src -t ./tests -d -i

# Custom file extension and suffixes
test-filestructure-linter -s ./src -t ./tests -e .vb --test-suffix Spec --test-project-suffix .Specs

# Ignore specific directories and files
test-filestructure-linter -s ./src -t ./tests -d --ignore-directories bin,obj,IntegrationTests --ignore-files AssemblyInfo.cs,Startup.cs

# Using relative or absolute paths
test-filestructure-linter -s ../../MyProject/src -t ../../MyProject/tests
test-filestructure-linter -s C:/Projects/MyApp/src -t C:/Projects/MyApp/tests

# Output JSON report to default location
test-filestructure-linter -s ./src -t ./tests -d -o

# Output JSON report to custom location
test-filestructure-linter -s ./src -t ./tests -d -o ./reports/my-report.json

Validation Types

File Name Validation

When enabled with -n or --name, checks if:

  • Test files end with the configured suffix (default: "Tests.cs")
  • File names match their contained test class names

Directory Structure Validation

When enabled with -d or --dir, verifies that:

  • Test files are in directories matching their source file structure
  • Example: If source is at src/Project/Feature/Class.cs, test should be at tests/Project.Tests/Feature/ClassTests.cs

Missing Test Validation

When enabled with -m or --missing, checks for:

  • Source files that don't have corresponding test files

Fix Modes

Fix All

-a, --all
  • Automatically moves all test files to their correct locations
  • Creates necessary directories if they don't exist

Fix Specific File

-f, --fix <path>
  • Moves a single test file to its correct location
  • Validates if the file can be fixed before attempting
  • Reports error if fix is not possible

Interactive Mode

-i, --interactive
  • Displays a list of fixable files with:
    • 📄 Source file paths
    • 🧪 Current test file paths
    • ✨ Expected test file paths
  • Allows selecting multiple files using checkboxes
  • Shows fix operation results

JSON Output Report

The tool can generate a detailed JSON report of the analysis results using the -o or --output option.

Usage

# Generate report with default path
test-filestructure-linter -s ./src -t ./tests -d -o

# Generate report with custom path
test-filestructure-linter -s ./src -t ./tests -d -o ./my-reports/analysis.json

Default Output Path

When -o is used without specifying a path, the report is saved to:

test-filestructure-linter-results/result-<datetime>.json

The <datetime> format is: YYYYMMDD-HHMMSS (e.g., 20231107-143025)

Report Format

The JSON report contains:

  • Summary statistics (total files analyzed, files with errors, etc.)
  • Detailed error information for each test file
  • Expected vs. actual file paths
  • Severity levels for each issue

Filtering Options

Ignore Directories

--ignore-directories <directories>
  • Comma-separated list of directory names to exclude from analysis
  • Directories at any level with these names will be skipped
  • Useful for excluding build outputs, integration test projects, etc.
  • Example: --ignore-directories bin,obj,IntegrationTests

Ignore Files

--ignore-files <files>
  • Comma-separated list of file names to exclude from analysis
  • Files with these names will be skipped regardless of location
  • Useful for excluding generated files, specific test cases, etc.
  • Example: --ignore-files AssemblyInfo.cs,GlobalSetup.cs

Notes

  • Source and test root paths are required
  • All validations are opt-in and must be explicitly enabled
  • Fix operations require directory structure validation to be enabled
  • The tool will create necessary directories when fixing file locations
  • Works with both relative and absolute paths
  • Supports Windows and Unix-style paths