New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-folder-generator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-folder-generator

A CLI tool to generate React component folders with TypeScript/JavaScript and CSS/SCSS files with modular or scoped styling options

latest
Source
npmnpm
Version
2.2.0
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

🚀 Component Generator CLI

A powerful Node.js CLI tool to scaffold React components with flexible architecture options.

✨ Features

  • ⚙️ Supports JavaScript (.jsx) and TypeScript (.tsx)
  • 🎨 Multiple styling options: CSS, SCSS, CSS Modules, SCSS Modules
  • 🛡 Scoped styling capability
  • 📁 Configurable folder structure
  • ✅ Input validation and overwrite protection

📋 Prerequisites

🖥 System Requirements

  • Node.js ≥16.0.0
  • npm ≥7.0.0 or yarn

📦 Project Dependencies

FeatureRequired Packages
TypeScripttypescript, @types/react
SCSSsass
CSS ModulesBuild tool configuration

🛠 Installation

npm install -g react-folder-generator
# or for project-specific
npm install react-folder-generator --save-dev

🗂 Folder Structure Conventions

📌 Naming Patterns

Kebab-case (Recommended)

src/components/my-component/
├── index.tsx
├── index.module.scss

PascalCase

src/components/MyComponent/
├── MyComponent.tsx
├── MyComponent.module.scss

Flat Structure

src/components/
├── MyComponent.tsx
├── MyComponent.module.scss

🎯 Scoped vs Non-Scoped Styles

TypeFile PatternUsage Scenario
ScopedComponentName.extComponent-specific
Non-Scopedindex.extShared/global styles

🔍 What is Scoped Styling?

Scoped styling creates component-specific style files following naming patterns like:

📄 File Naming

  • Component: Button.tsx
  • Style: Button.module.scss (when using --scoped-style)

🎯 Benefits

  • Prevents style leakage
  • Explicit component-style association
  • Better large-scale project organization

💡 Example

// Button.tsx
import styles from './Button.module.scss';

const Button = () => (
  <button className={styles.root}>
    Click me
  </button>
);
// Button.module.scss
.root {
  padding: 1rem 2rem;
  background: blue;

  &:hover {
    background: darkblue;
  }
}

💡 Usage Options

🔧 Basic Command

react-folder-generator ComponentName [options]

🧾 Option Matrix

OptionFile PatternRequires
--ts.tsxTypeScript
--scss.scsssass
--module-scss.module.scssCSS Modules config
--scoped-styleComponent-named-

🏗 Example Outputs

✅ Standard Component

react-folder-generator sidebar --scss
components/
  sidebar/
    ├── index.jsx
    └── index.scss

✅ Scoped TypeScript Module

react-folder-generator AuthForm --ts --module-scss --scoped-style
components/
  auth-form/
    ├── AuthForm.tsx
    ├── AuthForm.module.scss
    └── index.ts

⚙️ Build System Config

📦 Webpack CSS Modules Setup

{
  test: /\.module\.scss$/,
  use: [
    'style-loader',
    {
      loader: 'css-loader',
      options: {
        modules: {
          localIdentName: '[name]__[local]--[hash:base64:5]'
        }
      }
    },
    'sass-loader'
  ]
}

❓ FAQ

🟡 When should I use scoped styles?

Recommended for:

  • Large codebases
  • Component libraries
  • Teams with multiple developers

🟡 What's the difference between index.scss and Component.module.scss?

  • index.scss: Global/shared styles
  • Component.module.scss: Locally scoped styles for a component

👨‍💻 Author

Afriduzzaman
Senior Frontend Engineer
GitHub @Thetourist2051 | Email thetourist2051@gmail.com

📜 License

MIT © 2025 Afriduzzaman

This README follows technical writing best practices for clarity, visual hierarchy, and developer usability.

npm version

Keywords

react

FAQs

Package last updated on 12 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts