ewolfe / prlint

GitHub App for linting pull request meta data
https://github.com/apps/prlint
MIT License
126 stars 9 forks source link

Add support for rules via commitlint #35

Open ewolfe opened 6 years ago

ewolfe commented 6 years ago

Here are some examples

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

mrchief commented 5 years ago

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.

ewolfe commented 5 years ago

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 :)

mrchief commented 5 years ago

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 commented 5 years ago

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?

ewolfe commented 5 years ago

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"
+   }
  ]
}
mrchief commented 5 years ago

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.

ewolfe commented 5 years ago

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

mrchief commented 5 years ago

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.