Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lightyears1998 committed Apr 14, 2020
0 parents commit d4a9e4e
Show file tree
Hide file tree
Showing 103 changed files with 13,185 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TypeScript编译生成的JS文件
/lib/**
157 changes: 157 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
env:
es6: true
node: true
parser: '@typescript-eslint/parser'
parserOptions:
project: ./tsconfig.json
plugins:
- '@typescript-eslint'
- import
extends:
- plugin:@typescript-eslint/recommended
- plugin:import/errors
- plugin:import/warnings
- plugin:import/typescript
globals:
Atomics: readonly
SharedArrayBuffer: readonly
rules:
require-await:
- error
brace-style:
- warn
- 1tbs
curly:
- warn
- all
dot-location:
- warn
- property
dot-notation:
- warn
eqeqeq:
- warn
- smart
indent:
- off
"@typescript-eslint/indent":
- warn
- 4
linebreak-style:
- off
no-console:
- warn
no-trailing-spaces:
- warn
no-else-return:
- error
no-implicit-coercion:
- error
no-multi-spaces:
- warn
- {
ignoreEOLComments: true
}
no-return-await:
- error
wrap-iife:
- error
- inside
quotes:
- warn
- double
semi:
- warn
- always
yoda:
- warn
- never
block-spacing:
- warn
- always
camelcase:
- warn
- {
properties: always,
ignoreDestructuring: false,
allow: []
}
comma-dangle:
- warn
- never
comma-spacing:
- warn
- {
before: false,
after: true
}
comma-style:
- warn
- last
eol-last:
- warn
- always
func-call-spacing:
- warn
- never
jsx-quotes:
- warn
- prefer-double
key-spacing:
- warn
- {
beforeColon: false,
afterColon: true,
align: value
}
keyword-spacing:
- warn
- {
before: true,
after: true
}
new-parens:
- warn
- always
no-lonely-if:
- warn
no-whitespace-before-property:
- warn
object-curly-spacing:
- warn
- always
array-bracket-spacing:
- warn
- never
space-before-blocks:
- warn
- always
space-before-function-paren:
- warn
- {
anonymous: always,
named: never,
asyncArrow: always
}
space-in-parens:
- warn
- never
spaced-comment:
- warn
- always
switch-colon-spacing:
- warn
- {
before: false,
after: true
}
template-tag-spacing:
- warn
- never
unicode-bom:
- warn
- never
wrap-regex:
- warn
import/order:
- warn
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
19 changes: 19 additions & 0 deletions .github/actions/action-eslint/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
}
};
6 changes: 6 additions & 0 deletions .github/actions/action-eslint/.github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"config:base"
],
"rangeStrategy": "replace"
}
14 changes: 14 additions & 0 deletions .github/actions/action-eslint/.github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Docker Image CI

on: [push]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Build the Docker image
run: docker build . --file Dockerfile --tag reviewdog-eslint:$(date +%s)
19 changes: 19 additions & 0 deletions .github/actions/action-eslint/.github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: reviewdog
on: [pull_request]
jobs:
eslint:
name: runner / eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: eslint-github-pr-check
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.github_token }}
eslint_flags: 'testdata/'
- name: eslint-github-pr-review
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
eslint_flags: 'testdata/'
1 change: 1 addition & 0 deletions .github/actions/action-eslint/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
19 changes: 19 additions & 0 deletions .github/actions/action-eslint/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:current-alpine

# Install python
RUN apk add --update \
python \
python-dev \
py-pip \
build-base \
&& pip install virtualenv \
&& rm -rf /var/cache/apk/*

RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ v0.9.13
RUN apk --update add jq git && \
rm -rf /var/lib/apt/lists/* && \
rm /var/cache/apk/*

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
64 changes: 64 additions & 0 deletions .github/actions/action-eslint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# GitHub Action: Run eslint with reviewdog

[![Docker Image CI](https://github.com/reviewdog/action-eslint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/reviewdog/action-eslint/actions)
[![Release](https://img.shields.io/github/release/reviewdog/action-eslint.svg?maxAge=43200)](https://github.com/reviewdog/action-eslint/releases)

This action runs [eslint](https://github.com/eslint/eslint) with
[reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve
code review experience.

[![github-pr-check sample](https://user-images.githubusercontent.com/3797062/65439130-a6043b80-de61-11e9-98b5-bd9567e184b0.png)](https://github.com/reviewdog/action-eslint/pull/1)
[![github-pr-review sample](https://user-images.githubusercontent.com/3797062/65439073-91c03e80-de61-11e9-9077-39d480fbad0d.png)](https://github.com/reviewdog/action-eslint/pull/1)

## Inputs

### `github_token`

**Required**. Must be in form of `github_token: ${{ secrets.github_token }}`'.

### `level`

Optional. Report level for reviewdog [info,warning,error].
It's same as `-level` flag of reviewdog.

### `reporter`

Reporter of reviewdog command [github-pr-check,github-pr-review].
Default is github-pr-check.
github-pr-review can use Markdown and add a link to rule page in reviewdog reports.

### `eslint_flags`

Optional. Flags and args of eslint command. Default: '.'

## Example usage

You also need to install [eslint](https://github.com/eslint/eslint).

```shell
# Example
$ npm install eslint -D
```

You can create [eslint
config](https://eslint.org/docs/user-guide/configuring)
and this action uses that config too.

### [.github/workflows/reviewdog.yml](.github/workflows/reviewdog.yml)

```yml
name: reviewdog
on: [pull_request]
jobs:
eslint:
name: runner / eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: eslint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review # Change reporter.
eslint_flags: 'src/'
```
30 changes: 30 additions & 0 deletions .github/actions/action-eslint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Run eslint with reviewdog'
description: '🐶 Run eslint with reviewdog on pull requests to improve code review experience.'
author: 'haya14busa (reviewdog)'
inputs:
github_token:
description: 'GITHUB_TOKEN.'
required: true
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
reporter:
description: |
Reporter of reviewdog command [github-pr-check,github-pr-review].
Default is github-pr-check.
github-pr-review can use Markdown and add a link to rule page in reviewdog reports.
default: 'github-pr-check'
eslint_flags:
description: "flags and args of eslint command. Default: '.'"
default: '.'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.github_token }}
- ${{ inputs.level }}
- ${{ inputs.reporter }}
- ${{ inputs.eslint_flags }}
branding:
icon: 'alert-octagon'
color: 'blue'
23 changes: 23 additions & 0 deletions .github/actions/action-eslint/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

cd "$GITHUB_WORKSPACE"

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

if [ ! -f "$(npm bin)/eslint" ]; then
npm install
fi

echo "eslint --version"
$(npm bin)/eslint --version

if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then
# Use jq and github-pr-review reporter to format result to include link to rule page.
$(npm bin)/eslint -f="json" ${INPUT_ESLINT_FLAGS:-'.'} \
| jq -r '.[] | {filePath: .filePath, messages: .messages[]} | "\(.filePath):\(.messages.line):\(.messages.column):\(.messages.message) [\(.messages.ruleId)](https://eslint.org/docs/rules/\(.messages.ruleId))"' \
| reviewdog -efm="%f:%l:%c:%m" -name="eslint" -reporter=github-pr-review -level="${INPUT_LEVEL}"
else
# github-pr-check (GitHub Check API) doesn't support markdown annotation.
$(npm bin)/eslint -f="stylish" ${INPUT_ESLINT_FLAGS:-'.'} \
| reviewdog -f="eslint" -reporter=github-pr-check -level="${INPUT_LEVEL}"
fi
Loading

0 comments on commit d4a9e4e

Please sign in to comment.