How to use the danger.message function in danger

To help you get started, we’ve selected a few danger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thibaudcolas / draftjs-filters / dangerfile.js View on Github external
const isBug =
    danger.github.issue.labels.some((l) => l.name === "bug") ||
    danger.github.pr.title.includes("fix") ||
    danger.github.pr.title.includes("bug")

  if (!hasLabels) {
    message("What labels should we add to this PR?")
  }

  // Fails if the description is too short.
  if (!danger.github.pr.body || danger.github.pr.body.length < 10) {
    fail(":grey_question: This pull request needs a description.")
  }

  if (hasLibChanges && !hasLibTestChanges && (isEnhancement || isBug)) {
    message("This PR may require new test cases")
  }

  // Warns if the PR title contains [WIP]
  const isWIP = danger.github.pr.title.includes("WIP")
  if (isWIP) {
    const title = ":construction_worker: Work In Progress"
    const idea =
      "This PR appears to be a work in progress, and may not be ready to be merged yet."
    warn(`${title} - <i>${idea}</i>`)
  }
}

if (hasLibChanges &amp;&amp; !hasREADMEChanges) {
  warn("This pull request updates the library. Should the docs be updated?")
}
github uber / baseweb / dangerfile.js View on Github external
/*
Copyright (c) 2018-2019 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/

// @flow

const {message} = require('danger');

message('hello world');
github tinacms / tinacms / dangerfile.ts View on Github external
function checkForMilestone() {
  // @ts-ignore
  if (danger.github.pr.milestone) {
    // @ts-ignore
    let milestone: Milestone = danger.github.pr.milestone
    message(
      // @ts-ignore
      `You can expect the changes in this PR to be published on ${formatDate(
        new Date(milestone.due_on)
      )}`
    )
  } else {
    warn(`@tinacms/dev please add to a Milestone before merging `)
  }
}
github thibaudcolas / draftjs-conductor / dangerfile.js View on Github external
filepath.endsWith("test.js") || filepath.endsWith("test.js.snap"),
  ).length &gt; 0;
const hasREADMEChanges = danger.git.modified_files.includes("README.md");

if (!isLocal) {
  const hasLabels = danger.github.issue.labels.length !== 0;
  const isEnhancement =
    danger.github.issue.labels.some((l) =&gt; l.name === "enhancement") ||
    danger.github.pr.title.includes("feature");
  const isBug =
    danger.github.issue.labels.some((l) =&gt; l.name === "bug") ||
    danger.github.pr.title.includes("fix") ||
    danger.github.pr.title.includes("bug");

  if (!hasLabels) {
    message("What labels should we add to this PR?");
  }

  // Fails if the description is too short.
  if (!danger.github.pr.body || danger.github.pr.body.length &lt; 10) {
    fail(":grey_question: This pull request needs a description.");
  }

  if (hasLibChanges &amp;&amp; !hasLibTestChanges &amp;&amp; (isEnhancement || isBug)) {
    message("This PR may require new test cases");
  }

  // Warns if the PR title contains [WIP]
  const isWIP = danger.github.pr.title.includes("WIP");
  if (isWIP) {
    const title = ":construction_worker: Work In Progress";
    const idea =
github danreeves / react-tether / dangerfile.js View on Github external
}, thanks for submitting a pull request! :smile_cat:`
);

// Updates to the source require changelog updates
if (modifiedSrc.length > 1 && !changelogChanges) {
  warn(`You changed a source file but didn't add to the changelog`);
}

// Pull requests should have descriptions
if (danger.github.pr.body.length === 0) {
  warn('Please add a description to your PR');
}

// You added tests :tada:
if (testChanges.length > 0) {
  message(':tada: Thanks for working on tests!');
}

schedule(istanbulCoverage());
github twilio-labs / open-pixel-art / dangerfile.js View on Github external
function handleSuccessfulSubmission() {
  message('Thank you so much for contributing your pixel! 💖');
}
github getsentry / sentry-javascript / dangerfile.ts View on Github external
const formattedResults = prettyResults(results);
                res(`TSLint failed: **@sentry/${packageName}**\n\n${formattedResults}`);
              } else {
                res('');
              }
            },
          });
        });
      }),
    )).filter(str => str.length);
    if (tsLintResult.length) {
      tsLintResult.forEach(tsLintFail => {
        fail(`${tsLintFail}`);
      });
    } else {
      message('✅ TSLint passed');
    }
  });
github badges / shields / dangerfile.js View on Github external
)
}

if (legacyHelpers.created) {
  warn(['This PR added helper modules in `lib/` which is deprecated.'].join(''))
} else if (legacyHelpers.edited &amp;&amp; !legacyHelperTests.edited) {
  warn(
    [
      'This PR modified helper functions in `lib/` but not accompanying tests. <br>',
      "That's okay so long as it's refactoring existing code.",
    ].join('')
  )
}

if (logos.created) {
  message(
    [
      ':art: Thanks for submitting a logo. <br>',
      'Please ensure your contribution follows our ',
      '[guidance](https://github.com/badges/shields/blob/master/doc/logos.md#contributing-logos) ',
      'for logo submissions.',
    ].join('')
  )
}

if (capitals.created || underscores.created) {
  fail(
    [
      'JavaScript source files should be named with `kebab-case` ',
      '(dash-separated lowercase).',
    ].join('')
  )