prlint icon indicating copy to clipboard operation
prlint copied to clipboard

Add support for rules via commitlint

Open ewolfe opened this issue 7 years ago • 8 comments

Here are some examples

https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/index.js

ewolfe avatar Mar 19 '18 04:03 ewolfe

You probably don't need this if you always follow branch > pr > merge to master flow as PRLint will ensure the commit messages to master (which is the PR title) follows conventional-commit spec. Individual branch commit messages can remain flexible.

mrchief avatar Jan 21 '19 18:01 mrchief

My goal was to expose the same DSL instead of forcing regex upon users.

Side note: the PR title changes based on the number of commits in the pull request. 1 commit and the title is the commit message, 2 or more commits and the title is the branch name. I wish the title was ALWAYS the branch name. I started a project called github-ui-hooks that was supposed to be a chrome extension that would change the behavior of github. One of these days I'll find the time to fully release it :)

ewolfe avatar Jan 22 '19 18:01 ewolfe

My goal was to expose the same DSL instead of forcing regex upon users.

Oh, I get it, yeah that would be a welcome addition if this can support a lintrc file. Makes it easier to adopt.

mrchief avatar Jan 22 '19 19:01 mrchief

Once #96 is merged, we can look for this file first, followed by prlint.json followed by default config. I'm thinking to have lint.js and commitlint.js (for lack of better names) in src\core which can house linting logic and linter.js (name subject to change) can delegate validation to one those based on the file found. Just thinking out loud here, not a well thought out plan. Thoughts?

mrchief avatar Feb 10 '19 15:02 mrchief

We could probably keep it all in prlint.json:

{
  "title": [
    {
      "pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test):\\s",
      "message": "Your title needs to be prefixed with a topic"
    },
+   {
+     "rules": {
+       "header-max-length": [0, "always", 72],
+     },
+     "message": "Your title needs to be less than 72 characters"
+   }
  ]
}

ewolfe avatar Feb 10 '19 19:02 ewolfe

We could probably keep it all in prlint.json:

Yes, but then commitlint will not be able to find those. This might be a good time to open a dialog with commitlint folks if you deem fit.

mrchief avatar Feb 11 '19 00:02 mrchief

Looks like https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/lint would do the job.

ewolfe avatar Feb 11 '19 16:02 ewolfe

I recently modified my internal lambda to lint commits using commitlint.config.json. I did think about adding rules to prlint.json but that doesn't work with cli tools, extensions, etc.

mrchief avatar May 20 '19 14:05 mrchief