{"id":14599,"library":"gitlint-parser-node","title":"GitLint Parser for Node.js","description":"Gitlint is a widely used linter for Git commit messages, originally implemented in Python, that enforces conventions such as the Conventional Commits specification, ensuring consistent and readable commit history across projects. The `gitlint-parser-node` package is a JavaScript library designed to parse these commit messages specifically within a Node.js environment, adhering to the core parsing logic and conventions used by gitlint. This enables Node.js applications and tooling to programmatically process, analyze, and extract structured information from git commit messages in a compatible manner, without needing to invoke the Python-based gitlint CLI directly. It supports parsing the various components of a commit message, such as type, scope, subject, body, and footers. The current stable version is 1.1.0. Given its focused utility and version history, it appears to be in a maintenance phase, providing a stable foundation for projects requiring gitlint-compatible commit message parsing in JavaScript.","status":"maintenance","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/evanlucas/gitlint-parser-node","tags":["javascript"],"install":[{"cmd":"npm install gitlint-parser-node","lang":"bash","label":"npm"},{"cmd":"yarn add gitlint-parser-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add gitlint-parser-node","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The `parse` function is the primary named export for parsing commit messages. While CommonJS `require` works, ESM `import` is the recommended modern approach.","wrong":"const parse = require('gitlint-parser-node');","symbol":"parse","correct":"import { parse } from 'gitlint-parser-node';"},{"note":"For CommonJS environments, destructure the `parse` function from the `require` call. Direct default import is not supported as it's a named export.","wrong":"import parse from 'gitlint-parser-node';","symbol":"parse (CommonJS)","correct":"const { parse } = require('gitlint-parser-node');"}],"quickstart":{"code":"import { parse } from 'gitlint-parser-node';\n\nconst commitMessage = `feat(parser): add commit message parsing logic\\n\\nThis commit introduces the initial parsing functionality for git commit messages, adhering to conventional commit guidelines.\\n\\n- Parses type, scope, subject\\n- Extracts body and footers\\n\\nBREAKING CHANGE: The initial API might change in future minor versions.\\nCloses #123, #456`;\n\ntry {\n  const parsedCommit = parse(commitMessage);\n  console.log('Parsed Commit Message:');\n  console.log(`Type: ${parsedCommit.type}`);\n  console.log(`Scope: ${parsedCommit.scope}`);\n  console.log(`Subject: ${parsedCommit.subject}`);\n  console.log(`Header: ${parsedCommit.header}`);\n  console.log(`Body: ${parsedCommit.body}`);\n  console.log('Footers:');\n  parsedCommit.footers.forEach(footer => {\n    console.log(`  ${footer.token}: ${footer.value}`);\n  });\n} catch (error) {\n  console.error('Failed to parse commit message:', error.message);\n}","lang":"javascript","description":"Demonstrates how to import and use the `parse` function to extract structured data from a conventional git commit message."},"warnings":[{"fix":"For ES Modules, use `import { parse } from 'gitlint-parser-node';`. For CommonJS, use `const { parse } = require('gitlint-parser-node');`.","message":"When consuming `gitlint-parser-node` in a Node.js environment, ensure you use the correct import syntax for your module type. While `require()` is common in older CommonJS projects, modern Node.js applications often use ES Modules (`import`). This package primarily offers named exports.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Validate or sanitize input commit messages before passing them to the `parse` function, especially if the messages come from untrusted or external sources. Handle potential parsing errors gracefully with `try...catch` blocks.","message":"As a parsing library, `gitlint-parser-node` expects input formatted according to git commit message conventions. Malformed or unexpectedly structured input may lead to incomplete or incorrect parsing results, or potentially throw errors if the structure deviates too far from expected patterns.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Correct the import statement to use named destructuring: `import { parse } from 'gitlint-parser-node';` for ESM, or `const { parse } = require('gitlint-parser-node');` for CommonJS.","cause":"Attempting to use `parse` as a default import (e.g., `import parse from 'gitlint-parser-node'`) when it is exported as a named export.","error":"TypeError: parse is not a function"},{"fix":"Install the package using npm: `npm install gitlint-parser-node` or `npm install -g gitlint-parser-node` if it's a global utility.","cause":"The package `gitlint-parser-node` has not been installed or is not accessible in the current project's `node_modules`.","error":"Error: Cannot find module 'gitlint-parser-node'"}],"ecosystem":"npm"}