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

code-comment-check

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-comment-check

> ๐Ÿง  ไธ€ไธช่ฝป้‡ใ€ๅฟซ้€Ÿ็š„ๅ‘ฝไปค่กŒๅทฅๅ…ท๏ผŒ็”จไบŽๅœจๆไบคไปฃ็ ๅ‰ๆฃ€ๆŸฅๅ˜้‡ๅฃฐๆ˜Žๆ˜ฏๅฆ็ผบๅฐ‘ๆณจ้‡Šใ€‚ > ้€š่ฟ‡็ฎ€ๅ•็š„ CLI๏ผŒไธ€้”ฎ็กฎไฟๅ›ข้˜Ÿไปฃ็ ็š„ๅฏ่ฏปๆ€งไธŽไธ€่‡ดๆ€งใ€‚

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
ย 
Created
Source

๐Ÿงฉ code-comment-check

๐Ÿง  A lightweight, fast CLI tool that checks whether your variable declarations are properly commented before committing code. Ensure code readability and consistency across your team with one simple command.

๐Ÿš€ Why use code-comment-check?

Modern projects often enforce strict code style rules โ€” yet comment standards are easy to overlook. code-comment-check solves exactly that problem:

  • โœ… Automatically detects missing comments for each variable declaration
  • โœ… Prevents committing code with missing comments
  • โœ… By default, only checks changed lines in the current commit โ€” fast and efficient
  • โœ… Supports a --strict mode to inspect all declarations in changed files
  • ๐Ÿšซ Ignores test files by default (__tests__, .test.ts, .spec.tsx, etc.)

Use it in your local workflow or CI pipeline to enforce consistent documentation standards across your team.

๐Ÿ“ฆ Installation

# Recommended
pnpm add -D code-comment-check

# Or using npm / yarn
npm install -D code-comment-check
# or
yarn add -D code-comment-check

After installation, the CLI command is automatically registered:

comment-check

โš™๏ธ Usage

pnpm comment-check

Default behavior:

  • Only checks changed lines in the committed files
  • Automatically ignores test files
  • Displays missing comment entries in a formatted table (file, line, declaration)
  • Returns a non-zero exit code if issues are found, blocking the commit

๐Ÿ”น Strict mode

pnpm comment-check --strict

In strict mode, the tool scans all declarations in changed files, making it ideal for code review or CI environments.

๐Ÿช Integrating with Husky (pre-commit hook)

In your .husky/pre-commit file, add the following:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm comment-check

Effect:

  • โœ… If all checks pass โ€” the commit proceeds
  • โŒ If any declaration lacks a comment โ€” a table of missing comments is printed, and the commit is blocked

๐Ÿ’ก Example Output

๐Ÿ” Checking annotation comments...

โš ๏ธ  Missing annotation comments:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ File                       โ”‚ Line โ”‚ Declaration              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ src/utils/math.ts          โ”‚  12  โ”‚ const totalPrice = ...   โ”‚
โ”‚ src/components/Button.tsx  โ”‚  45  โ”‚ let isDisabled = false   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โŒ Please add comments before committing your code.

๐ŸŒŸ Features & Advantages

FeatureDescription
โšก๏ธ High performanceBuilt on the SWC compiler โ€” much faster than Babel
๐Ÿงฉ Zero configurationWorks out of the box, automatically registers the CLI
๐Ÿ’ฌ Clear outputDisplays missing comment details in a table
๐Ÿง  Smart parsingSupports TypeScript / JSX / TSX syntax
๐Ÿชถ LightweightNon-intrusive โ€” analyzes AST without modifying code
๐Ÿ”ง ExtensibleSupports the --strict flag for broader checks

๐Ÿ“˜ Use Cases

  • Enforcing code documentation standards
  • Pre-commit comment validation
  • Automated CI code inspection
  • Integration in internal dev tools or monorepo setups

๐Ÿ“„ License

MIT ยฉ 2025 โ€” maintained by laoer536

Keywords

code-comment-check

FAQs

Package last updated on 03 Nov 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