Skip to content

Commit

Permalink
Add docs for action and package
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Apr 22, 2020
1 parent 89e1f24 commit 3974100
Showing 1 changed file with 64 additions and 25 deletions.
89 changes: 64 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,67 @@
# `@vtex/danger`

Opinionated and configurable `danger.js` rules.
This repo exposes two projects:

<!-- @import "[TOC]" {cmd="toc" depthFrom=2 depthTo=3 orderedList=false} -->
- `@vtex/danger`, a package with an opinionated and configurable danger ruleset;
- `vtex/danger`, a Github Action that automatically runs the default configuration of `@vtex/danger` in a given repository.

<!-- @import "[TOC]" {cmd="toc" depthFrom=2 depthTo=4 orderedList=false} -->

<!-- code_chunk_output -->

- [Usage](#usage)
- [Rules](#rules)
- [`description`](#description)
- [`assignee`](#assignee)
- [`reviewers`](#reviewers)
- [`pr_size`](#pr_size)
- [`lock_file`](#lock_file)
- [`no_dot_only`](#no_dot_only)
- [`no_console_log`](#no_console_log)
- [`no_debugger`](#no_debugger)
- [`enforce_graphql_provider`](#enforce_graphql_provider)
- [Usage as an action](#usage-as-an-action)
- [Usage as a package](#usage-as-a-package)
- [Rules](#rules)
- [`description`](#description)
- [`assignee`](#assignee)
- [`reviewers`](#reviewers)
- [`pr_size`](#pr_size)
- [`lock_file`](#lock_file)
- [`no_dot_only`](#no_dot_only)
- [`no_console_log`](#no_console_log)
- [`no_debugger`](#no_debugger)
- [`enforce_graphql_provider`](#enforce_graphql_provider)

<!-- /code_chunk_output -->

## Usage
## Usage as an action

`vtex/danger` automatically installs your dependencies and run `danger` for you. Your project doesn't even have to have a `dangerfile.js`!

To use it, it's as simple as adding it to one of your project workflows:

```yml
name: Some github action

on:
pull_request:
branches:
- master

jobs:
danger-ci:
name: Danger CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: 12.x
- name: Danger CI
uses: vtex/danger@master
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
REQUIRE_CHANGELOG_VERSION: true
```
The `vtex/danger` action accepts the below options:

- `GITHUB_TOKEN` _(required)_ - A Github token for danger to use. You can you the `secrets.GITHUB_TOKEN` secret.
- `REQUIRE_CHANGELOG_VERSION` _(default: `false`)_ - Define if the changelog rule should look for a new release version entry in the updated changelog.

## Usage as a package

Begin by installing the package:
If you want to use the `@vtex/danger` ruleset separatedly from its action, you can install the package and call it in your `dangerfile.js`.

```shell
$ yarn add -D @vtex/danger
Expand Down Expand Up @@ -75,7 +114,7 @@ const config = {
verify(config)
```

## Rules
### Rules

Rules are configured in a similar manner to `eslint` rules:

Expand All @@ -99,7 +138,7 @@ Rules are configured in a similar manner to `eslint` rules:

---

### `description`
#### `description`

Enforce a minimum description length.

Expand All @@ -118,7 +157,7 @@ Enforce a minimum description length.

---

### `assignee`
#### `assignee`

Enforce having an assigned user to merge the pull request.

Expand All @@ -128,7 +167,7 @@ Enforce having an assigned user to merge the pull request.

---

### `reviewers`
#### `reviewers`

Enforce having at least one person to review the pull request.

Expand All @@ -138,7 +177,7 @@ Enforce having at least one person to review the pull request.

---

### `pr_size`
#### `pr_size`

Enforce smaller pull requests by alerting if its size is relatively big. This rule considers `additions + deletions`.

Expand All @@ -159,7 +198,7 @@ Enforce smaller pull requests by alerting if its size is relatively big. This ru
---

### `lock_file`
#### `lock_file`

Enforce lock files are updated together with the `package.json` file.

Expand All @@ -169,7 +208,7 @@ Enforce lock files are updated together with the `package.json` file.
---

### `no_dot_only`
#### `no_dot_only`

Enforce no `it.only`, `describe.only`, `fdescribe`, `fit(` inside files which respect the specified filename pattern.

Expand All @@ -188,7 +227,7 @@ Enforce no `it.only`, `describe.only`, `fdescribe`, `fit(` inside files which re
---

### `no_console_log`
#### `no_console_log`

Enforce no `console.log` inside files which respect the specified filename pattern.

Expand All @@ -205,7 +244,7 @@ Enforce no `console.log` inside files which respect the specified filename patte

> ⚠️ A wild `console.log` has appeared on `react/components/pages/Details.tsx#L21`. Is this supposed to be here?
### `no_debugger`
#### `no_debugger`

Enforce no `debugger` inside files which respect the specified filename pattern.

Expand All @@ -222,7 +261,7 @@ Enforce no `debugger` inside files which respect the specified filename pattern.

> ⚠️ Is this a `debugger` that I see on [withQuery.tsx#L52](https://github.com/owner/repo/blob/src/withQuery.tsx#L52)?
### `enforce_graphql_provider`
#### `enforce_graphql_provider`

Enforce `.gql` and `.graphql` files to explicitly declare the `@context(provider: "...")` for graphql queries.

Expand Down

0 comments on commit 3974100

Please sign in to comment.