Skip to content

Commit 884c4e8

Browse files
committed
Add CI workflow to lint TypeScript and JavaScript code
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
1 parent c090b77 commit 884c4e8

10 files changed

+6352
-2154
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
lib
3+
node_modules

.eslintrc.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md#configuration
2+
3+
extends:
4+
- airbnb-typescript/base
5+
- prettier
6+
plugins:
7+
- "@typescript-eslint"
8+
parser: "@typescript-eslint/parser"
9+
parserOptions:
10+
project:
11+
- ./tsconfig.eslint.json
12+
rules:
13+
max-len:
14+
- error
15+
- code: 180
16+
"@typescript-eslint/comma-dangle": "off"
17+
no-console: "off"
18+
padded-blocks: "off"
19+
"@typescript-eslint/indent":
20+
- error
21+
- 2
22+
- SwitchCase: 1
23+
spaced-comment: warn
24+
arrow-parens: "off"
25+
consistent-return: "off"
26+
no-useless-escape: "off"
27+
no-underscore-dangle: "off"
28+
import/prefer-default-export: "off"
29+
"@typescript-eslint/type-annotation-spacing": error
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Check TypeScript
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-typescript-task.yml"
8+
- ".eslintignore"
9+
- "**/.eslintrc*"
10+
- "package.json"
11+
- "package-lock.json"
12+
- "Taskfile.yml"
13+
- "tsconfig.eslint.json"
14+
- "tsconfig.json"
15+
- "**.js"
16+
- "**.jsx"
17+
- "**.ts"
18+
- "**.tsx"
19+
pull_request:
20+
paths:
21+
- ".github/workflows/check-typescript-task.yml"
22+
- ".eslintignore"
23+
- "**/.eslintrc*"
24+
- "package.json"
25+
- "package-lock.json"
26+
- "Taskfile.yml"
27+
- "tsconfig.eslint.json"
28+
- "tsconfig.json"
29+
- "**.js"
30+
- "**.jsx"
31+
- "**.ts"
32+
- "**.tsx"
33+
schedule:
34+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
35+
- cron: "0 8 * * TUE"
36+
workflow_dispatch:
37+
repository_dispatch:
38+
39+
jobs:
40+
check:
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v2
46+
47+
- name: Install Taskfile
48+
uses: arduino/actions/setup-taskfile@master
49+
with:
50+
repo-token: ${{ secrets.GITHUB_TOKEN }}
51+
version: 3.x
52+
53+
- name: Lint
54+
run: task ts:lint

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# `arduino/setup-taskfile`
22

3+
[![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)
34
[![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)
45
[![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)
56
[![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)

Taskfile.yml

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ tasks:
99
deps:
1010
- task: action:validate
1111

12+
ts:install-deps:
13+
desc: Install TypeScript development dependencies
14+
cmds:
15+
- npm install
16+
17+
ts:lint:
18+
desc: Lint TypeScript code
19+
deps:
20+
- task: ts:install-deps
21+
cmds:
22+
- npx eslint --ext .js,.jsx,.ts,.tsx .
23+
24+
ts:fix-lint:
25+
desc: Fix TypeScript code linting violations
26+
deps:
27+
- task: ts:install-deps
28+
cmds:
29+
- npx eslint --ext .js,.jsx,.ts,.tsx --fix .
30+
1231
action:validate:
1332
desc: Validate GitHub Actions metadata against JSON schema
1433
cmds:

0 commit comments

Comments
 (0)