idea-conventional-commit-commitlint icon indicating copy to clipboard operation
idea-conventional-commit-commitlint copied to clipboard

Support for commitlint YAML file

Open galak75 opened this issue 4 years ago • 11 comments

Hi

First of all, thank you for the amazing work on this plugin.

Would it be possible to add support for yaml file format ? Or is it already supported ?

galak75 avatar Feb 17 '21 14:02 galak75

@galak75 hi! No, currently only JSON is supported, but YAML shouldn't be difficult to add. Could you point me to an example of YAML config? So I can tell you what I can support and what I cannot.

lppedd avatar Feb 17 '21 15:02 lppedd

I will look for a reference documentation, but here is a small example:

extends:
  - '@commitlint/config-conventional'
rules:
  header-max-length: [1, 'always', 72]
  type-enum:
  - 2
  - always
  - - ci
    - feat
    - fix
    - docs
    - style
    - refactor
    - perf
    - test
    - revert
help: |
  **Possible types**:
  `ci`:       Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  `feat`:     Adds a new feature.
  `fix`:      Solves a bug.
  `docs`:     Adds or alters documentation.
  `style`:    Improves formatting, white-space.
  `refactor`: Rewrites code without feature, performance or bug changes.
  `perf`:     Improves performance.
  `test`:     Adds or modifies tests.
  `revert`:   Changes that reverting other changes

galak75 avatar Feb 17 '21 16:02 galak75

I couldn't find any yaml-specific documentation, but I hope the official configuration reference (and the link about rules at the bottom) combined with the example above should help?

galak75 avatar Feb 17 '21 16:02 galak75

@galak75 thanks! I cannot support extends as of now unfortunately. Is it ok anyway?

lppedd avatar Feb 17 '21 18:02 lppedd

It may be great to support all available configuration formats (javascript, json and yaml) with the current supported features.

The day extends is supported, it would probably be for all formats :-)

galak75 avatar Feb 17 '21 22:02 galak75

@galak75 the issue is how to read a JavaScript file. I can read YAML and JSON because the document format is fixed, but I cannot read a JavaScript file as a user could throw everything inside of it: functions, variables, imports.

lppedd avatar Feb 18 '21 12:02 lppedd

Prettier and commitlint both use cosmiconfig for loading/merging config files, so JetBrains' Prettier plugin might have some useful config-loader recipes that would (presumably) work the same for other tools using cosmiconfig.

ParkerM avatar Feb 27 '21 20:02 ParkerM

@ParkerM I had already explored the Prettier plugin some time ago. They interface with NodeJs directly, which means they have their own plugin and process to load the configuration file. It's not really straightforward and requires Node to be always present.

lppedd avatar Feb 27 '21 21:02 lppedd

@ParkerM A good alternative is JCEF https://plugins.jetbrains.com/docs/intellij/jcef.html?from=jetbrains.org Although I never tried it.

lppedd avatar Feb 27 '21 21:02 lppedd

@ParkerM what I could do is try to bundle cosmiconfig and execute it inside the JCEF environment. Thanks for mentioning the tool!

lppedd avatar Feb 27 '21 21:02 lppedd

@lppedd Interesting, thanks for the explanation. And sure thing! 👍

ParkerM avatar Feb 27 '21 22:02 ParkerM