Today I Learned

TIL, 2021-11-26, more Dangerfile shenanigans

console.log(`**${}** by ${}`);
console.log('# Test Cases')[1]);

// This is a playground where you can explore the Danger JS
// API and share code samples. Once the red lines below "danger"
// and "path" are gone then you can start to explore writing
// rules for Dangerfiles.

import { danger, fail, markdown, warn, message } from "danger"
import * as path from "path"

// API reference:

const pr =

// Find out if some particular files have changed in this PR
const documentation = danger.git.fileMatch("**/*.md")
const changelog = danger.git.fileMatch("")
const packageJson = danger.git.fileMatch("package.json")
const lockfile = danger.git.fileMatch("yarn.lock", "package-lock.json")

// Rules

// Thank folks for making doc changes
if (documentation.edited) {
    message("Thanks - We :heart: our [documentarians](!")

// Remind people to update lockfiles
if (packageJson.modified && !lockfile.modified) {
    warn("This PR modified package.json, but not the lockfile")

// When there are app-changes and it us not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const trivialPR = pr.body.includes("trivial")
if (!changelog.edited && !trivialPR) {
  fail("No CHANGELOG added.")

// No PR is too small to warrant a paragraph or two of summary
if (pr.body.length === 0) {
  fail("Please add a description to your PR.")
// Always ensure we assign someone to a PR, if its a
if (pr.assignee === null) {
  const method = pr.title.includes("WIP") ? warn : fail
  method("Please assign someone to merge this PR, and optionally include people who should review.")

// Ensure that a label has been set
if (danger.github.issue.labels.length === 0) {
  warn("This PR does not have any labels.")

This project is maintained by daryllxd