generated from ncsa/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdangerfile.js
41 lines (34 loc) · 1.65 KB
/
dangerfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { danger, warn, fail } from 'danger'
const hasAppChanges = danger.git.modified_files.some(file => file.includes('src'))
const hasChangelog = danger.git.modified_files.includes("CHANGELOG.md")
const isDeclaredTrivial = (danger.github.pr.title + danger.github.pr.body).includes('#trivial') || !hasAppChanges
//Make sure we add changelog
if (!hasChangelog && !isDeclaredTrivial) {
warn("Please add a changelog entry for your changes.");
}
//Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title
if (danger.github.pr.body.length < 3) {
warn('Please add a detailed summary in the description.')
}
//Temporary disable this since tasks like create new page may include more than 500 lines of code
// if (git.lines_of_code > 500) {
// warn('This PR is too big! Consider breaking it down into smaller PRs.')
// }
//Make it more obvious that a PR is a work in progress and shouldn't be merged yet
if (danger.github.pr.title.includes('[WIP]')) {
warn('PR is classed as Work in Progress')
}
//Detect .eslintrc changes and set warnings
if (danger.git.modified_files.includes('.eslintrc')) {
warn('Changes were made to .eslintrc. Please ensure that you have notified the team to change the existing ESLint rule.')
}
// In the future: make sure non-trivial amounts of code changes come with corresponding tests
/*
const has_test_changes = !git.modified_files.grep(/spec/).empty
if (git.lines_of_code > 50 && has_app_changes && !has_test_changes) {
warn('There are code changes, but no corresponding tests. ' \
'Please include tests if this PR introduces any modifications in ' \
'behavior.',
sticky: false)
}
*/