Skip to content
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

Support commitlint.config.ts with TypeScript #2652

Closed
2 of 4 tasks
seahindeniz opened this issue Jun 27, 2021 · 5 comments
Closed
2 of 4 tasks

Support commitlint.config.ts with TypeScript #2652

seahindeniz opened this issue Jun 27, 2021 · 5 comments
Labels

Comments

@seahindeniz
Copy link

Expected Behavior

Commitlint should be able to parse the config file written in TypeScript

Current Behavior

Commitlint asks me to add a config file

> git ls-files --stage -- C:\Users\.....(reducted)......\commitlint.config.ts
⧗   input: Add commitlint and husky
✖   Please add rules to your `commitlint.config.js`
    - Getting started guide: https://git.io/fhHij
    - Example config: https://git.io/fhHip [empty-rules]

✖   found 1 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

husky - commit-msg hook exited with code 1 (error)

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Steps to Reproduce (for bugs)

  1. Install
  2. Add commitlint.config.ts
  3. Perform an unconventional commit
  4. See Git log
commitlint.config.ts
export default { extends: ['@commitlint/config-conventional'] };

Context

Well, I want my repo to have only TS files rather than combining with JS files- including config files on my repository and I need Commitlint would also respect this choice.

Your Environment

Executable Version
commitlint --version 12.1.4
git --version 2.31.1.windows.1
node --version v14.16.1
@escapedcat
Copy link
Member

I feel like this was mentioned already but I can't find a related issue or PR.
I guess this should work.

@reverofevil
Copy link

Somehow documentation already mentions using TypeScript for configuration, yet it's unclear how to use it.

@songhn233
Copy link
Contributor

Any update for this feature?

Maybe check for the existence of commitlint.config.ts when commitlint.config.js does not exist, and compile it as a configuration if the current project has dependency ts-node or other methods.

@escapedcat
Copy link
Member

@songhn233 happy for a PR if you want to try

@reverofevil
Copy link

when commitlint.config.js does not exist

@songhn233 If someone accidentally used tsc on all *.ts files, including commitlint.config.ts, now changes to commitlint.config.ts would be magically ignored.

Common resolution strategy is

  • run .ts config if exists, error if no ts-node around;
  • run .js config if exists;
  • use default config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants