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 🙏

© 2025 – Pkg Stats / Ryan Hefner

project-structure-lint

v1.0.1

Published

A CLI tool to validate project folder structure and file naming conventions with configurable presets

Downloads

88

Readme

project-structure-lint

A powerful CLI tool to validate project folder structure and file naming conventions with configurable presets. Perfect for maintaining consistency across React, Vue, Angular, and other JavaScript/TypeScript projects.

Features

Component Co-location Validation - Ensures all related files (tests, stories, styles) are in the same folder
File Naming Convention Enforcement - Supports PascalCase, camelCase, kebab-case, snake_case, and UPPER_CASE
Folder Structure Validation - Enforces project directory organization
Configurable Presets - Built-in React preset with easy customization
Detailed Error Reporting - Clear messages with suggestions for fixes
CI/CD Integration - Exit codes for automated workflows

Installation

npm install --save-dev project-structure-lint

Or use globally:

npm install -g project-structure-lint

Quick Start

1. Initialize Configuration

npx validate-structure init

This creates a .validate-structurerc.json file with the React preset.

2. Run Validation

npx validate-structure check

Usage

Commands

check

Validate your project structure:

validate-structure check [options]

Options:
  -c, --config <path>  Path to configuration file
  -r, --root <path>    Root directory to validate (default: current directory)

init

Initialize a configuration file:

validate-structure init [options]

Options:
  -p, --preset <name>  Preset to use (default: react)

presets

List available presets:

validate-structure presets

Configuration

Using Presets

The easiest way to get started is using a preset:

{
  "preset": "react"
}

Custom Configuration

Create a .validate-structurerc.json file:

{
  "preset": "react",
  "rootDir": "src",
  "rules": {
    "componentColocation": {
      "enabled": true,
      "componentDirs": ["components", "pages", "features"],
      "requiredFiles": [
        {
          "pattern": "*.test.{ts,tsx}",
          "required": true,
          "description": "Test file"
        },
        {
          "pattern": "*.stories.{ts,tsx}",
          "required": true,
          "description": "Storybook story"
        }
      ],
      "namingConvention": "PascalCase"
    },
    "fileNaming": {
      "components/**/*.{tsx,jsx}": {
        "convention": "PascalCase",
        "severity": "error"
      },
      "hooks/**/*.{ts,tsx}": {
        "convention": "camelCase",
        "severity": "error"
      },
      "utils/**/*.{ts,js}": {
        "convention": "camelCase",
        "severity": "error"
      }
    },
    "folderStructure": [
      {
        "name": "components",
        "path": "src/components",
        "namingConvention": "PascalCase",
        "allowedExtensions": [".tsx", ".ts", ".css", ".scss"]
      }
    ]
  },
  "ignore": [
    "**/node_modules/**",
    "**/dist/**",
    "**/build/**"
  ],
  "severity": "error"
}

Configuration Options

preset

  • Type: string
  • Available: "react"
  • Use a predefined configuration preset

rootDir

  • Type: string
  • Default: "src"
  • Root directory for validation

rules.componentColocation

Validates that component files are co-located with their tests, stories, etc.

{
  "enabled": true,
  "componentDirs": ["components", "pages"],
  "requiredFiles": [
    {
      "pattern": "*.test.tsx",
      "required": true,
      "description": "Test file"
    }
  ],
  "namingConvention": "PascalCase"
}

rules.fileNaming

Enforces naming conventions for files matching patterns:

{
  "components/**/*.tsx": {
    "convention": "PascalCase",
    "severity": "error"
  }
}

Supported conventions:

  • PascalCase - MyComponent.tsx
  • camelCase - useAuth.ts
  • kebab-case - my-component.tsx
  • snake_case - my_component.tsx
  • UPPER_CASE - API_CONSTANTS.ts

rules.folderStructure

Validates directory structure and contents:

{
  "name": "components",
  "path": "src/components",
  "namingConvention": "PascalCase",
  "allowedExtensions": [".tsx", ".ts", ".css"]
}

ignore

Patterns to ignore (uses glob syntax):

{
  "ignore": [
    "**/node_modules/**",
    "**/dist/**",
    "**/*.test.ts"
  ]
}

severity

Default severity level:

  • "error" - Fails validation
  • "warning" - Shows warning but passes

Examples

React Component Structure

For a component named Button, the tool validates:

components/
└── Button/
    ├── Button.tsx          ✓ Main component
    ├── Button.test.tsx     ✓ Test file
    ├── Button.stories.tsx  ✓ Storybook story
    ├── Button.module.css   ✓ Styles
    └── index.ts            ✓ Re-export

Naming Convention Validation

// ✓ Valid
components/Button/Button.tsx
hooks/useAuth.ts
utils/formatDate.ts

// ✗ Invalid
components/button/button.tsx  // Should be PascalCase
hooks/UseAuth.ts              // Should be camelCase
utils/format_date.ts          // Should be camelCase

CI/CD Integration

Add to your CI pipeline:

# GitHub Actions
- name: Validate Project Structure
  run: npx validate-structure check
// package.json
{
  "scripts": {
    "validate": "validate-structure check",
    "precommit": "validate-structure check"
  }
}

Programmatic Usage

import { ProjectValidator, loadConfig } from 'project-structure-lint';

async function validate() {
  const config = await loadConfig();
  const validator = new ProjectValidator(config, process.cwd());
  const result = await validator.validate();
  
  console.log(`Valid: ${result.valid}`);
  console.log(`Errors: ${result.errors.length}`);
  console.log(`Warnings: ${result.warnings.length}`);
}

Output Example

Project Structure Validation Results
──────────────────────────────────────────────────
Files scanned: 45
Directories scanned: 12

✗ 2 Errors

1. Missing required file: Test file for component
   Directory: components/Button
   Expected: Button.test.tsx
   💡 Create Button.test.tsx in components/Button/

2. File name doesn't follow PascalCase convention
   File: components/myComponent/myComponent.tsx
   Actual: myComponent.tsx
   Expected: MyComponent.tsx
   💡 Rename to MyComponent.tsx

──────────────────────────────────────────────────

✗ Validation failed with 2 errors

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Author

Created with ❤️ for better project organization