Registry / testing / gitlint-parser-node

gitlint-parser-node

JSON →
library1.1.0jsnpmunverified

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.

npm install gitlint-parser-node
INSTALL
IMPORT
SIG · GITLINT-PARSER-NOD
G
gitlint-parser-node
testingjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'gitlint-parser-node';
const parse = require('gitlint-parser-node');
The `parse` function is the primary named export for parsing commit messages. While CommonJS `require` works, ESM `import` is the recommended modern approach.
parse (CommonJS)
const { parse } = require('gitlint-parser-node');
import parse from 'gitlint-parser-node';
For CommonJS environments, destructure the `parse` function from the `require` call. Direct default import is not supported as it's a named export.

Demonstrates how to import and use the `parse` function to extract structured data from a conventional git commit message.

import { parse } from 'gitlint-parser-node'; const 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`; try { const parsedCommit = parse(commitMessage); console.log('Parsed Commit Message:'); console.log(`Type: ${parsedCommit.type}`); console.log(`Scope: ${parsedCommit.scope}`); console.log(`Subject: ${parsedCommit.subject}`); console.log(`Header: ${parsedCommit.header}`); console.log(`Body: ${parsedCommit.body}`); console.log('Footers:'); parsedCommit.footers.forEach(footer => { console.log(` ${footer.token}: ${footer.value}`); }); } catch (error) { console.error('Failed to parse commit message:', error.message); }
Debug
Known issues
gotchaWhen 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.
fix
For ES Modules, use `import { parse } from 'gitlint-parser-node';`. For CommonJS, use `const { parse } = require('gitlint-parser-node');`.
affects: >=1.0.0
gotchaAs 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.
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.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: parse is not a function
Attempting to use `parse` as a default import (e.g., `import parse from 'gitlint-parser-node'`) when it is exported as a named export.
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.
Error: Cannot find module 'gitlint-parser-node'
The package `gitlint-parser-node` has not been installed or is not accessible in the current project's `node_modules`.
fix
Install the package using npm: `npm install gitlint-parser-node` or `npm install -g gitlint-parser-node` if it's a global utility.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
gitlint-parser-node — npm install gitlint-parser-node · libregistry