- Notifications
You must be signed in to change notification settings - Fork 949
Open
Labels
Description
Steps to Reproduce
Only modules accept top level await. const config = require("@commitlint/config-conventional") const createPreset = require("conventional-changelog-conventionalcommits") cosnt { merge } = require("lodash-es") async function createEmojiParser() { const emojiRegexPart = Object.values(config.prompt.questions.type.enum) .map((value) => value.emoji.trim()) .join('|') const parserOpts = { breakingHeaderPattern: new RegExp( `^(?:${emojiRegexPart})\\s+(\\w*)(?:\\((.*)\\))?!:\\s+(.*)$` ), headerPattern: new RegExp( `^(?:${emojiRegexPart})\\s+(\\w*)(?:\\((.*)\\))?!?:\\s+(.*)$` ), } const defaultPreset = await createPreset() return merge({}, defaultPreset, { conventionalChangelog: { parserOpts }, parserOpts, recommendedBumpOpts: { parserOpts }, }) } const emojiParser = await createEmojiParser() /** * @type {import('@commitlint/types').UserConfig} */ module.exports = { extends: ['@commitlint/config-conventional'], parserPreset: emojiParser, prompt: { questions: { type: { description: 'Select the type of change that you\'re committing', headerWithEmoji: true, enum: { feat: { description: 'A new feature', title: 'Features', emoji: '✨', }, fix: { description: 'A bug fix', title: 'Bug Fixes', emoji: '🐛', }, docs: { description: 'Documentation only changes', title: 'Documentation', emoji: '📚', }, style: { description: 'Changes that do not affect the meaning of the code (linters)', title: 'Styles', emoji: '🎨', }, refactor: { description: 'A code change that neither fixes a bug nor adds a feature', title: 'Code Refactoring', emoji: '♻️ ', }, perf: { description: 'A code change that improves performance', title: 'Performance Improvements', emoji: '🚀', }, test: { description: 'Adding missing tests or correcting existing tests', title: 'Tests', emoji: '🧪', }, build: { description: 'Changes that affect the build system or external dependencies (yarn)', title: 'Builds', emoji: '🏗️ ', }, ci: { description: 'Changes to our CI configuration files and scripts (GitActions)', title: 'Continuous Integrations', emoji: '⚙️ ', }, chore: { description: 'Other changes that don\'t modify src or test files', title: 'Chores', emoji: '🧩', }, revert: { description: 'Reverts a previous commit', title: 'Reverts', emoji: '⏪', }, }, }, }, }, }Current Behavior
This doesnt work with commonJS.
Expected Behavior
Should a option for CommomJS.
A tried changed the imports for require
and tried to change await files for .then
tried to
export.module = (async () => { emojiParser = await createEmojiParser() return { extends: ['@commitlint/config-conventional'], parserPreset: emojiParser , prompt: { questions: { type: { description: 'Select the type of change that you\'re committing', headerWithEmoji: true, enum: { feat: { description: 'A new feature', title: 'Features', emoji: '✨', }, fix: { description: 'A bug fix', title: 'Bug Fixes', emoji: '🐛', }, docs: { description: 'Documentation only changes', title: 'Documentation', emoji: '📚', }, style: { description: 'Changes that do not affect the meaning of the code (linters)', title: 'Styles', emoji: '🎨', }, refactor: { description: 'A code change that neither fixes a bug nor adds a feature', title: 'Code Refactoring', emoji: '♻️ ', }, perf: { description: 'A code change that improves performance', title: 'Performance Improvements', emoji: '🚀', }, test: { description: 'Adding missing tests or correcting existing tests', title: 'Tests', emoji: '🧪', }, build: { description: 'Changes that affect the build system or external dependencies (yarn)', title: 'Builds', emoji: '🏗️ ', }, ci: { description: 'Changes to our CI configuration files and scripts (GitActions)', title: 'Continuous Integrations', emoji: '⚙️ ', }, chore: { description: 'Other changes that don\'t modify src or test files', title: 'Chores', emoji: '🧩', }, revert: { description: 'Reverts a previous commit', title: 'Reverts', emoji: '⏪', }, }, }, }, }, } } Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
Works with commomJS
Context
No response
commitlint --version
"@commitlint/cli": "^20.1.0",
git --version
2.37.0
node --version
22.15.1