https://github.com/ewolfe/prlint
GitHub App for linting pull request meta data
https://github.com/ewolfe/prlint
continuous-integration github-app linter pull-requests
Last synced: 6 months ago
JSON representation
GitHub App for linting pull request meta data
- Host: GitHub
- URL: https://github.com/ewolfe/prlint
- Owner: ewolfe
- License: mit
- Created: 2017-11-26T21:40:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-30T14:06:39.000Z (about 5 years ago)
- Last Synced: 2024-08-09T13:16:17.366Z (9 months ago)
- Topics: continuous-integration, github-app, linter, pull-requests
- Language: JavaScript
- Homepage: https://github.com/apps/prlint
- Size: 3.36 MB
- Stars: 126
- Watchers: 4
- Forks: 9
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# PRLint
> GitHub App for linting pull requests
[](https://stats.uptimerobot.com/ZzYnEf2BW)
[](https://greenkeeper.io/)
[](https://travis-ci.org/ewolfe/prlint)
[](https://codeclimate.com/github/ewolfe/prlint)
[](#contributors)
[](https://spectrum.chat/prlint)## The Problem
You want your pull requests to have a consistent convention for titles, descriptions, branch names, labels, milestones, and more.
## This Solution
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.
## Screenshots
[](https://cdn.rawgit.com/ewolfe/prlint/master/assets/screenshot-success.png)
[](https://cdn.rawgit.com/ewolfe/prlint/master/assets/screenshot-error.png)
## Example Rules
`.github/prlint.json`
```javascript
{
"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](https://developer.github.com/v3/pulls/#get-a-single-pull-request)
## Install
1. Install via https://github.com/apps/prlint
1. Add this file `.github/prlint.json` to the root of your project:```javascript
{
"title": [
{
"pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test)((.+))?:\\s.+",
"message": "Your title needs to be prefixed with a topic"
}
]
}
```3. Test it by opening a pull request with the title "chore: add prlint"
![]()
## Usage
### Keys:
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](https://developer.github.com/v3/pulls/#get-a-single-pull-request)To target a nested object, you can use dot notation encoded within the key string. i.e.:
```javascript
{
"assignee.login": [
{
"pattern": "octocat"
}
]
}
```### Values:
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).
* Each item in the array needs to be an object:
* `pattern:` javascript [Regular Expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Syntax)
* _Special characters must be escaped_
i.e. If you want to check for a whitespace, use `"pattern": "\\s"` vs `"pattern": "\s"`
* `flags:` optional array of strings used in the [Regular Expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
* For example, this can be used to make your regex case insensitive
* `message`: optional string for customizing the error message on the pull request page## Credits
* [“Dust Bunny”](https://thenounproject.com/term/lint/176538/) icon by Erika Kim from [the Noun Project](https://thenounproject.com/).
## License
MIT
## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
| [
Hrusikesh Panda](http://about.me/hkpanda)
[🚇](#infra-mrchief "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/ewolfe/prlint/commits?author=mrchief "Tests") [💻](https://github.com/ewolfe/prlint/commits?author=mrchief "Code") |
| :---: |This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!