1.0.0 • Published 5 months ago

@softfix/code-standards v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

@softfix/code-standards

šŸš€ Enforce Consistent Code Standards Across Projects

This package ensures consistent naming conventions for files, functions, variables, and interfaces in React, Next.js, Node.js, and TypeScript projects.


šŸ“¦ Installation

npm install --save-dev @softfix/code-standards

šŸš€ Usage

Run Pre-commit Checks Manually

npx softfix-precommit

This command performs the following checks:

  • File Names: Must be lowercase and kebab-case (e.g., my-component.tsx).
  • Functions: Must use camelCase (e.g., fetchData).
  • Variables: Must use camelCase or UPPER_CASE.
  • Interfaces: Must use PascalCase and start with I (e.g., IUserProfile).

āœ… If any rule is violated, the pre-commit will fail and show the list of issues.


🧩 Examples

āœ… File Names

  • Correct: user-profile.ts, order-list.component.tsx
  • Incorrect: UserProfile.ts, order_list.tsx

āœ… Function Names

// āœ… Correct
function getUserDetails() {}

// 🚫 Incorrect
function GetUserDetails() {}
function get_user_details() {}

āœ… Variable Names

// āœ… Correct
const userName = 'John';
const API_KEY = '12345';

// 🚫 Incorrect
const UserName = 'John';
const apiKey = '12345';

āœ… Interface Names

// āœ… Correct
interface IUser {
  id: number;
  name: string;
}

// 🚫 Incorrect
interface user {
  id: number;
  name: string;
}
interface UserInterface {} // Should start with 'I'

šŸ› ļø Why Use This Package?

āœ… Automates code standard checks for faster development workflows āœ… Reduces code review time and improves code quality āœ… Seamlessly enforces company-wide coding standards āœ… Keeps naming conventions consistent across all projects āœ… Easily integrates with existing development pipelines and tools āœ… Prevents common naming mistakes before code is committed āœ… Saves time by catching issues early in the development cycle āœ… Enhances team collaboration through standardized code practices āœ… Provides clear, actionable feedback for quick fixes āœ… Supports scalable codebases by maintaining clean and organized code āœ… Works out of the box with minimal configuration āœ… Increases project maintainability and reduces technical debt


šŸ’» Keep your codebase clean, consistent, and error-free with @softfix/code-standards!

1.0.0

5 months ago