Skip to content

Commit

Permalink
Add CI workflow to lint TypeScript and JavaScript code
Browse files Browse the repository at this point in the history
On every push and pull request that affects relevant files, and periodically, run eslint on the repository's TypeScript
and JavaScript files.

eslint is configured via the .eslintrc.yml file:
https://eslint.org/docs/user-guide/configuring/configuration-files
  • Loading branch information
per1234 committed May 7, 2021
1 parent c090b77 commit 884c4e8
Show file tree
Hide file tree
Showing 10 changed files with 6,352 additions and 2,154 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
lib
node_modules
29 changes: 29 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md#configuration

extends:
- airbnb-typescript/base
- prettier
plugins:
- "@typescript-eslint"
parser: "@typescript-eslint/parser"
parserOptions:
project:
- ./tsconfig.eslint.json
rules:
max-len:
- error
- code: 180
"@typescript-eslint/comma-dangle": "off"
no-console: "off"
padded-blocks: "off"
"@typescript-eslint/indent":
- error
- 2
- SwitchCase: 1
spaced-comment: warn
arrow-parens: "off"
consistent-return: "off"
no-useless-escape: "off"
no-underscore-dangle: "off"
import/prefer-default-export: "off"
"@typescript-eslint/type-annotation-spacing": error
54 changes: 54 additions & 0 deletions .github/workflows/check-typescript-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Check TypeScript

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-typescript-task.yml"
- ".eslintignore"
- "**/.eslintrc*"
- "package.json"
- "package-lock.json"
- "Taskfile.yml"
- "tsconfig.eslint.json"
- "tsconfig.json"
- "**.js"
- "**.jsx"
- "**.ts"
- "**.tsx"
pull_request:
paths:
- ".github/workflows/check-typescript-task.yml"
- ".eslintignore"
- "**/.eslintrc*"
- "package.json"
- "package-lock.json"
- "Taskfile.yml"
- "tsconfig.eslint.json"
- "tsconfig.json"
- "**.js"
- "**.jsx"
- "**.ts"
- "**.tsx"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Lint
run: task ts:lint
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# `arduino/setup-taskfile`

[![Check TypeScript status](https://github.com/arduino/setup-taskfile/actions/workflows/check-typescript-task.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-typescript-task.yml)
[![Integration Tests status](https://github.com/arduino/setup-taskfile/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/test-integration.yml)
[![Check Action Metadata status](https://github.com/arduino/setup-taskfile/actions/workflows/check-action-metadata-task.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-action-metadata-task.yml)
[![Spell Check status](https://github.com/arduino/setup-taskfile/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/spell-check.yml)
Expand Down
19 changes: 19 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ tasks:
deps:
- task: action:validate

ts:install-deps:
desc: Install TypeScript development dependencies
cmds:
- npm install

ts:lint:
desc: Lint TypeScript code
deps:
- task: ts:install-deps
cmds:
- npx eslint --ext .js,.jsx,.ts,.tsx .

ts:fix-lint:
desc: Fix TypeScript code linting violations
deps:
- task: ts:install-deps
cmds:
- npx eslint --ext .js,.jsx,.ts,.tsx --fix .

action:validate:
desc: Validate GitHub Actions metadata against JSON schema
cmds:
Expand Down
Loading

0 comments on commit 884c4e8

Please sign in to comment.