GitHub App for linting pull request meta data
GitHub App for linting pull requests
You want your pull requests to have a consistent convention for titles, descriptions, branch names, labels, milestones, and more.
PRLint will let you run regular expressions against your pull request meta data. You can then enable PRLint status checks to pass before a pull request can be merged.
.github/prlint.json
{
"title": [
{
"pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test):\\s",
"message": "Your title needs to be prefixed with a topic"
}
],
"body": [
{
"pattern": "JIRA-\\d{1,4}",
"flags": ["i"],
"message": "You need a JIRA ticket in your description"
},
{
"pattern": ".{1,}",
"message": "You need literally anything in your description"
}
],
"head.ref": [
{
"pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test)/",
"message": "Your branch name is invalid"
}
],
"assignee.login": [
{
"pattern": ".+",
"message": "You need to assign someone"
}
],
"requested_teams.0.id": [
{
"pattern": "2691982",
"message": "The product team needs to be added as a reviewer"
}
],
"additions": [
{
"pattern": "0|^[1-9]$|^[1-9]\\d$",
"message": "Your PR is too big (over 99 additions)"
}
],
"labels.0.name": [
{
"pattern": "bug|enhancement|question",
"message": "Please add a label"
}
]
}
You can check anything listed in the pull request object
.github/prlint.json
to the root of your project:{
"title": [
{
"pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test)((.+))?:\\s.+",
"message": "Your title needs to be prefixed with a topic"
}
]
}
The top level keys are keys that the GitHub API exposes when a pull request is opened, edited, etc.
You can use anything listed in the sample response object here sample response object here
To target a nested object, you can use dot notation encoded within the key string. i.e.:
{
"assignee.login": [
{
"pattern": "octocat"
}
]
}
The top level values are where you get to define your validation rules. You can have multiples rules, so we expect an array (even if you only have a single validation rule).
pattern:
javascript Regular Expression
"pattern": "\\s"
vs "pattern": "\s"
flags:
optional array of strings used in the Regular Expression
message
: optional string for customizing the error message on the pull request pageMIT
Thanks goes to these wonderful people (emoji key):
Hrusikesh Panda 🚇 ⚠️ 💻 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!