I study patterns used in an open source project found on Github Trending. For this week, I reviewed some parts of Storybook codebase and wrote this article.
Danger is a NPM module that evals a Dangerfile. You set up a Dangerfile per-project. The Dangerfile contains a collection of home-grown rules specific to your project as a dangerfile.js or dangerfile.ts.
Danger can be installed via NPM or Yarn.
Use yarn add danger -D to add it to your package.json.
You can integrate Danger into your own project using AppCenter, Bamboo, BitbucketPipelines, Bitrise, BuddyBuild, BuddyWorks, Buildkite, Circle, Cirrus, CodeBuild, Codefresh, Codemagic, Codeship, Concourse, DockerCloud, Drone, GitHubActions, GitLabCI, Jenkins, Netlify, Nevercode, Screwdriver, Semaphore, Surf, TeamCity, Travis, VSTS.
You would then need to generate a GitHub access token or a BitBucket Server user, and expose some credentials as ENV vars. Then add yarn danger ci to your CI test run.
const checkPrTitle = (title: string) => { const match = title.match(/^[A-Z].+:\s[A-Z].+$/); if (!match) { fail( `PR title must be in the format of "Area: Summary", With both Area and Summary starting with a capital letterGood examples:- "Docs: Describe Canvas Doc Block"- "Svelte: Support Svelte v4"Bad examples:- "add new api docs"- "fix: Svelte 4 support"- "Vue: improve docs"` ); }};
Both these functions are invoked based on the following condition: