Skip to content

refactor(commitlint): update commitlint configuration and prompts #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 25, 2025

Conversation

jcppkkk
Copy link
Contributor

@jcppkkk jcppkkk commented Apr 15, 2025

refactor(commitlint): update commitlint configuration and prompts for improved clarity and consistency

The commitlint configuration and prompts have been refactored to enhance clarity and maintain consistency throughout the codebase. The type assertion for commitLintConfig is updated to use 'as any' for better type handling. Additionally, formatting adjustments are made in the prompts to ensure proper readability and alignment with the defined conventions. These changes aim to streamline the commit message generation process and improve overall code maintainability.


This merge request is the 2nd of 5 commits intended to archive feat(commitlint): Improve consistency handling and prompt structure. I have split the changes into five reviewable merge requests that will be submitted sequentially.

feat(commitlint): Improve consistency handling and prompt structure

Problem:
The current commitlint integration has limitations in generating commit messages that strictly follow commitlint rules. For example, when commitlint config has body-leading-blank: [2, 'always'], the default prompt cannot generate messages with proper blank line between header and body:

- feat(scope): add new feature
- This is the body text
+ feat(scope): add new feature
+ 
+ This is the body text

Solution:
We refactor the consistency handling to use the default commit message format as a reference style, while ensuring the generated messages strictly follow commitlint rules. This approach:

  1. Uses the default content as a reference for style and features
  2. Generates dynamic requirements based on config settings
  3. Ensures the message follows all commitlint rules
  4. Maintains backward compatibility

jcppkkk added 2 commits April 15, 2025 14:00
… improved clarity and consistency

The commitlint configuration and prompts have been refactored to enhance
clarity and maintain consistency throughout the codebase. The type
assertion for commitLintConfig is updated to use 'as any' for better
type handling. Additionally, formatting adjustments are made in the
prompts to ensure proper readability and alignment with the defined
conventions. These changes aim to streamline the commit message
generation process and improve overall code maintainability.
…ved file management

Including rimraf in the project allows for easier and more efficient
removal of files and directories, enhancing the development workflow,
especially for tasks like cleaning up build artifacts.
@jcppkkk jcppkkk force-pushed the master branch 8 times, most recently from 48da90d to 2e46a63 Compare April 15, 2025 07:55
Resolves persistent `ReferenceError: exports is not defined` errors
encountered during unit tests (`unit-test (20.x)` job) in the GitHub
Actions CI environment. These errors occurred specifically when
importing `cli-testing-library` in the global Jest setup file
(`test/jest-setup.ts`), despite tests passing locally with the same
Node.js version (v20.19.0).

After iterative testing, the following Jest configuration combination
was identified as necessary to ensure consistent ESM handling and test
success in both local and CI environments:

- Set preset to `ts-jest/presets/default-esm` for stricter ESM rules.

- Configured `transformIgnorePatterns` to ensure Jest transforms specific ESM dependencies (`cli-testing-library`, `@clack`, `cleye`) within `node_modules`.

- Expanded the `transform` pattern (`^.+\\.(ts|tsx|js|jsx|mjs)$`) to explicitly cover various script types handled by `ts-jest`.

- Included explicit `tsconfig` overrides (`module: 'ESNext'`, `target: 'ES2022'`) within the `ts-jest` transform options to resolve potential environment discrepancies.

- Retained `moduleNameMapper` for `.js` imports for reliable module resolution.

- Ensured `cli-testing-library` imports remain in the global setup (`test/jest-setup.ts`).

- Removed test cache clearing from the `test:unit` script in `package.json`.

This configuration now passes reliably across environments.
The space normalization logic is updated to replace only multiple spaces
and tabs with a single space, while preserving newlines. This change
ensures that the formatting of the content is maintained, especially
when dealing with empty line requirements and max line length.
@di-sukharev di-sukharev merged commit 25c6a0d into di-sukharev:master Apr 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants