// eslint-disable-next-line import/no-extraneous-dependencies, no-unused-vars
import { danger, warn, fail, message } from 'danger';

const modifiedChangelog = danger.git.modified_files.filter((filePath) => {
  const srcFilePattern = /^packages\/([a-z-])*\/CHANGELOG.md/i;
  return srcFilePattern.test(filePath);
});

const modifiedSrcFiles = danger.git.modified_files.filter((filePath) => {
  const srcFilePattern = /^packages\/([a-z-])*\/src/i;
  return srcFilePattern.test(filePath);
});

const hasCHANGELOGChanges = modifiedChangelog.length > 0;
const hasModifiedSrcFiles = modifiedSrcFiles.length > 0;

// Fail if there are src code changes without a CHANGELOG
if (hasModifiedSrcFiles && !hasCHANGELOGChanges) {
  fail('Please include a CHANGELOG entry with this PR.');
}

// Warn when there is a big PR
const bigPRThreshold = 100;
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
  warn(':exclamation: Big PR. Consider breaking this into smaller PRs if applicaple');
}

@@ -126,16 +126,194 @@
 nger';%0A%0A
+const newChangelog = danger.git.created_files.filter((filePath) =%3E %7B%0A  const srcFilePattern = /%5Epackages%5C/(%5Ba-z-%5D)*%5C/CHANGELOG.md/i;%0A  return srcFilePattern.test(filePath);%0A%7D);%0A%0A
 const mo
@@ -712,24 +712,51 @@
 log.length %3E
+ 0 %7C%7C newChangelog.length %3E
  0;%0Aconst ha
@@ -862,16 +862,23 @@
 HANGELOG
+ update
 %0Aif (has
@@ -1039,16 +1039,17 @@
 ld = 100
+0
 ;%0Aif (da

Update dangerfile rules