Skip to content

Commit

Permalink
Merge branch 'develop' into em-date-input-#79
Browse files Browse the repository at this point in the history
  • Loading branch information
eamahanna committed May 13, 2020
2 parents 2b2ac8e + 1601208 commit 21b76fd
Show file tree
Hide file tree
Showing 18 changed files with 948 additions and 269 deletions.
3 changes: 1 addition & 2 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path')

module.exports = ({ config }) => {
config.module.rules = config.module.rules.filter(
rule => rule.test.toString() !== '/\\.css$/'
(rule) => rule.test.toString() !== '/\\.css$/'
)

config.module.rules.push({
Expand All @@ -29,7 +29,6 @@ module.exports = ({ config }) => {
include: path.resolve(__dirname, '../src'),
use: [
'style-loader',
'css-modules-typescript-loader',
{
loader: 'css-loader',
options: {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added form dateInput component
- Added yarn audit check to dangerfile (on package change)
- Added search component
- Added Grid, GridContainer components

## [1.2.0] - 2020-04-30

Expand Down
10 changes: 10 additions & 0 deletions custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ declare module '*.svg' {
const content: any
export default content
}

declare module '*.module.css' {
const classes: { [key: string]: string }
export default classes
}

declare module '*.module.scss' {
const classes: { [key: string]: string }
export default classes
}
70 changes: 46 additions & 24 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,67 @@
import { includes } from 'lodash';
import { danger, warn, fail } from 'danger';
import { includes } from 'lodash'
import { danger, warn } from 'danger'

// No PR is too small to include a description of why you made a change
if (danger.github && danger.github.pr.body.length < 10) {
warn('Please include a description of your PR changes.');
warn('Please include a description of your PR changes.')
}

// Load all modified and new files
const allFiles = danger.git.modified_files.concat(danger.git.created_files);
const allFiles = danger.git.modified_files.concat(danger.git.created_files)

// Request changes to package source code to also include changes to tests.
const hasCodeChanges = allFiles.some(p => !!p.match(/src\/.*\.[jt]sx?/));
const hasTestChanges = allFiles.some(p => !!p.match(/src\/.*\.test\.[jt]sx?/));
const hasCodeChanges = allFiles.some((p) => !!p.match(/src\/.*\.[jt]sx?/))
const hasTestChanges = allFiles.some((p) => !!p.match(/src\/.*\.test\.[jt]sx?/))
if (hasCodeChanges && !hasTestChanges) {
warn('This PR does not include changes to tests, even though it affects source code.');
warn(
'This PR does not include changes to tests, even though it affects source code.'
)
}

// Make sure to export new components (src/components/*.[jt]sx)
const hasNewComponents = danger.git.created_files.some(
(p) => !!p.match(/src\/components\/.*\.[jt]sx/)
)
const hasEntrypointChanges = includes(allFiles, 'src/index.ts')
if (hasNewComponents && !hasEntrypointChanges) {
const message = `It looks like there are new component (JSX/TSX) files, but the entrypoint (index.ts) has not changed.`
const idea = `Did you forget to export new components from the library entrypoint?`
warn(`${message} - <em>${idea}</em>`)
}

// Require new src/components files to include changes to storybook
const hasStorybookChanges = allFiles.some(p => !!p.match(/src\/.*\.stories\.[jt]sx?/));
const hasStorybookChanges = allFiles.some(
(p) => !!p.match(/src\/.*\.stories\.[jt]sx?/)
)

if (hasCodeChanges && !hasStorybookChanges) {
warn('This PR does not include changes to storybook, even though it affects component code.');
warn(
'This PR does not include changes to storybook, even though it affects component code.'
)
}

// Request update of yarn.lock if package.json changed but yarn.lock isn't
const packageChanged = includes(allFiles, 'package.json');
const lockfileChanged = includes(allFiles, 'yarn.lock');
const packageChanged = includes(allFiles, 'package.json')
const lockfileChanged = includes(allFiles, 'yarn.lock')
if (packageChanged && !lockfileChanged) {
const message = 'Changes were made to package.json, but not to yarn.lock';
const idea = 'Perhaps you need to run `yarn install`?';
warn(`${message} - <i>${idea}</i>`);
const message = 'Changes were made to package.json, but not to yarn.lock'
const idea = 'Perhaps you need to run `yarn install`?'
warn(`${message} - <i>${idea}</i>`)
}

// Ensure we have access to github for these checks
let isTrivial = false;
let isYarnAuditMissing = false;
let isTrivial = false
let isYarnAuditMissing = false
if (danger.github) {
let prBody = danger.github.pr.body
isTrivial = includes((prBody + danger.github.pr.title), '#trivial')
const prBody = danger.github.pr.body

isTrivial = includes(prBody + danger.github.pr.title, '#trivial')

if (lockfileChanged && danger.github.pr.user.type == 'User') {
isYarnAuditMissing = !(includes(prBody, 'vulnerabilities found:') && includes(prBody, 'Packages audited:'));
isYarnAuditMissing = !(
includes(prBody, 'vulnerabilities found:') &&
includes(prBody, 'Packages audited:')
)
}
}

Expand All @@ -54,7 +74,9 @@ if (!hasChangelog && !isTrivial) {

// Encourage adding `yarn audit` output on package change
if (isYarnAuditMissing) {
const message = 'Changes were made to yarn.lock, but no plain text yarn audit output was found in PR description.'
const idea = 'Can you run `yarn audit` in your branch and paste the results inside a markdown code block?'
warn(`${ message } - <i>${idea}</i>`)
const message =
'Changes were made to yarn.lock, but no plain text yarn audit output was found in PR description.'
const idea =
'Can you run `yarn audit` in your branch and paste the results inside a markdown code block?'
warn(`${message} - <i>${idea}</i>`)
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"storybook": "start-storybook",
"storybook": "start-storybook -p 9009",
"storybook:deploy": "storybook-to-ghpages",
"build": "webpack",
"build:watch": "webpack --watch",
Expand Down Expand Up @@ -76,18 +76,17 @@
"@typescript-eslint/parser": "^2.3.2",
"awesome-typescript-loader": "^5.2.1",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
"babel-jest": "^26.0.1",
"babel-loader": "^8.0.6",
"css-loader": "^3.2.0",
"css-modules-typescript-loader": "^4.0.0",
"danger": "^10.0.0",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-no-only-tests": "^2.3.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^3.0.0",
"eslint-plugin-react-hooks": "^4.0.0",
"eslint-plugin-security": "^1.4.0",
"file-loader": "^6.0.0",
"husky": "^4.2.3",
Expand Down
7 changes: 0 additions & 7 deletions src/components/Alert/Alert.module.css.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/components/Modal/Modal.module.scss.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/components/Table/Table.module.css.d.ts

This file was deleted.

Loading

0 comments on commit 21b76fd

Please sign in to comment.