commitlint-config 3.0.0
Install from the command line:
Learn more about npm packages
$ npm install @LottieFiles/commitlint-config@3.0.0
Install via package.json:
"@LottieFiles/commitlint-config": "3.0.0"
About this version
Shared commitlint configuration with Linear integration and enhanced conventional commits support.
This package provides a comprehensive commitlint configuration that enforces commit message standards with enhanced features including Linear issue validation, automatic scope detection from pnpm workspaces, and interactive commit prompts.
- Linear Integration: Validates issue states and references through Linear API
- Smart Issue References: Supports Linear's magic keywords for automatic issue linking
- Extended Commit Types: Comprehensive set of commit types beyond conventional commits
- Interactive Prompts: Rich guided commit message creation
- Multiple Scopes: Support for comma-separated scopes
- Workspace Integration: Automatic scope detection from pnpm workspaces
- Strict Validation: Comprehensive rules for consistent formatting
See GUIDE.md documentation for details and examples on writing great commit messages with this config.
- Installation
- Quick Start
- Configuration
- Linear Integration
- Commit Types
- Scopes
- Development
- Troubleshooting
- API Reference
- Node.js ≥ 20.0.0
- pnpm package manager
- Git repository
# Install the configuration package
pnpm add -D @lottiefiles/commitlint-config
# Install commitlint CLI (if not already installed)
pnpm add -D @commitlint/cli
Create commitlint.config.mjs
in your project root:
import { createConfig } from '@lottiefiles/commitlint-config';
export default createConfig({
// Required: Linear team/project prefixes
issuePrefixes: ['WEB', 'CRE'],
// Optional: Enable Linear validation (defaults to 'auto')
linearEnabled: true,
// Optional: Allowed Linear issue states (defaults to ['started'])
linearIssueStates: ['started', 'completed'],
});
# Install husky
pnpm add -D husky
# Initialize husky
pnpm exec husky install
# Add commit-msg hook
pnpm exec husky add .husky/commit-msg 'pnpm commitlint --edit $1'
Add to your package.json
:
{
"lint-staged": {
"*": "pnpm commitlint --edit"
}
}
Once configured, commitlint will automatically validate your commit messages:
# Valid commit
git commit -m "feat(auth): add OAuth2 authentication"
# Invalid commit (will be rejected)
git commit -m "Add new feature" # Missing type format
# Set your Linear API key
export LINEAR_API_KEY="lin_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Commit with Linear issue reference
git commit -m "feat(auth): implement SSO login
Add single sign-on authentication with SAML support.
Includes proper error handling and user feedback.
Closes WEB-123"
For guided commit creation, use with commitizen:
# Install commitizen globally
npm install -g commitizen
# Use interactive prompts
git cz
import { createConfig } from '@lottiefiles/commitlint-config';
export default createConfig();
import { createConfig } from '@lottiefiles/commitlint-config';
export default createConfig({
// Linear team prefixes (required for Linear integration)
issuePrefixes: ['WEB', 'CRE', 'DEVOP'],
// Linear API configuration
linearEnabled: true, // or 'auto' or false
linearApiKey: process.env.LINEAR_API_KEY,
linearIssueStates: ['started', 'completed'],
// Custom scopes (overrides pnpm workspace detection)
scopes: ['api', 'web', 'mobile', 'docs'],
});
-
Get Linear API Key:
- Go to Linear Settings → API
- Create a new API key
- Set as environment variable:
LINEAR_API_KEY=lin_api_xxx...
-
Configure Issue Prefixes:
export default createConfig({ issuePrefixes: ['WEB', 'CRE'], // Your Linear team keys });
The configuration validates:
- Issue exists in Linear
- Issue is in allowed states (default:
['started']
) - Reference uses valid action keywords
Linear magic keywords for automatic issue linking:
Action | Description |
---|---|
closes , close , closed , closing
|
Marks issue as completed |
fixes , fix , fixed , fixing
|
Marks issue as completed |
resolves , resolve , resolved , resolving
|
Marks issue as completed |
completes , complete , completed , completing
|
Marks issue as completed |
refs , ref , references
|
Links without state change |
part of , related to , contributes to
|
Links without state change |
toward , towards
|
Links without state change |
git commit -m "feat(auth): implement OAuth2 login
Add OAuth2 authentication with Google and GitHub providers.
Includes token refresh and proper error handling.
Closes WEB-123
Refs WEB-124"
Type | Description | Use Case |
---|---|---|
feat |
New features | Adding new functionality |
fix |
Bug fixes | Fixing existing issues |
docs |
Documentation | README, API docs, comments |
style |
Code style | Formatting, whitespace, semicolons |
refactor |
Code refactoring | Restructuring without functional changes |
perf |
Performance | Performance improvements |
test |
Testing | Adding or modifying tests |
build |
Build system | Webpack, npm scripts, dependencies |
ci |
CI/CD | GitHub Actions, deployment scripts |
ops |
Operations | Infrastructure, monitoring, deployment |
chore |
Maintenance | Routine tasks, dependency updates |
revert |
Reverts | Reverting previous commits |
release |
Releases | Version bumps, changelogs |
merge |
Merges | Merge conflict resolutions |
wip |
Work in progress | Incomplete features (use sparingly) |
By default, scopes are automatically detected from your pnpm-workspace.yaml
:
packages:
- 'packages/auth'
- 'packages/api'
- 'packages/web'
Valid scopes: auth
, api
, web
Override automatic detection:
export default createConfig({
scopes: ['frontend', 'backend', 'mobile', 'docs'],
});
Use comma-separated scopes for cross-cutting changes:
git commit -m "feat(auth, api): implement user session management"
# Install dependencies
pnpm install
# Build TypeScript to JavaScript
pnpm build
# Build in watch mode
pnpm dev
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test --watch
# Run specific test file
pnpm test examples.test.ts
# Print resolved configuration
pnpm print-config
# Test commit message
echo "feat: add new feature" | pnpm commitlint
# Test with specific config
echo "feat(scope): message" | pnpm commitlint --config ./commitlint.config.mjs
-
Link Package Locally:
# In this package directory pnpm link --global # In your test project pnpm link --global @lottiefiles/commitlint-config
-
Test Changes:
# Make changes to src/ pnpm build # Test in your project echo "feat: test message" | pnpm commitlint
-
Edit Local Plugin (
src/local-plugin.ts
):const myCustomRule: SyncRule = (parsed, when = 'always') => { // Your validation logic return [isValid, errorMessage]; }; export default { rules: { 'my-custom-rule': myCustomRule, // ... existing rules }, } satisfies Plugin;
-
Add to Configuration (
src/define-config.ts
):rules: { 'my-custom-rule': [RuleConfigSeverity.Error, 'always'], // ... existing rules }
Problem: Linear API key must be available when linearEnabled is true
Solutions:
- Set environment variable:
export LINEAR_API_KEY="lin_api_xxx..."
- Pass directly in config:
linearApiKey: "lin_api_xxx..."
- Disable Linear:
linearEnabled: false
Problem: Valid-looking commits are rejected
Debug Steps:
- Check exact error message:
pnpm commitlint --verbose
- Verify commit type is in allowed list
- Ensure scope is kebab-case:
feat(user-auth): ...
- Check Linear issue exists and is in correct state
Problem: Scope not recognized in monorepo
Solutions:
- Verify
pnpm-workspace.yaml
is properly configured - Use custom scopes:
scopes: ['your', 'custom', 'scopes']
- Check scope format is kebab-case
# Print full configuration
pnpm commitlint --print-config
# Verbose error output
echo "invalid message" | pnpm commitlint --verbose
# Test Linear API connection
curl -H "Authorization: Bearer $LINEAR_API_KEY" \
-H "Content-Type: application/json" \
https://api.linear.app/graphql \
-d '{"query":"{ viewer { id name } }"}'
- Check Configuration: Ensure all required options are set
- Verify Environment: Check Node.js version and dependencies
- Test Incrementally: Start with basic config, add features gradually
- Review Examples: See GUIDE.md for comprehensive examples
Creates a commitlint configuration with the specified options.
-
options
(optional): Configuration options object
-
UserConfig
: Complete commitlint configuration object
interface Options {
issuePrefixes?: string[];
linearApiKey?: string;
linearEnabled?: 'auto' | boolean;
linearIssueStates?: string[];
scopes?: string[];
}
Option | Type | Default | Description |
---|---|---|---|
issuePrefixes |
string[] |
[] |
Linear team/project prefixes (e.g., ['WEB', 'CRE'] ) |
linearApiKey |
string |
process.env.LINEAR_API_KEY |
Linear API key for issue validation |
linearEnabled |
'auto' | boolean |
'auto' |
Enable Linear validation. 'auto' enables if API key is available |
linearIssueStates |
string[] |
['started'] |
Allowed Linear issue states ('unstarted' , 'started' , 'completed' , 'canceled' ) |
scopes |
string[] |
undefined |
Custom scopes (overrides pnpm workspace detection) |
Array of all supported commit types.
Array of all supported Linear reference action keywords.
Details
- commitlint-config
-
LottieFiles
- 3 months ago
- UNLICENSED
- 13 dependencies
Assets
- commitlint-config-3.0.0.tgz
Download activity
- Total downloads 19
- Last 30 days 14
- Last week 6
- Today 0