Skip to content

Commit 04d1856

Browse files
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 64e2156 commit 04d1856

File tree

8 files changed

+8762
-4834
lines changed

8 files changed

+8762
-4834
lines changed

.eslintrc.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/assets/check-typescript/.eslintrc.yml
2+
# See: https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/README.md#configuration
3+
# The code style defined in this file is the official standardized style to be used in all Arduino projects and should
4+
# not be modified.
5+
6+
extends:
7+
- airbnb-typescript/base
8+
- prettier
9+
- 'eslint:recommended'
10+
- 'plugin:@typescript-eslint/recommended'
11+
- 'plugin:import/recommended'
12+
plugins:
13+
- "@typescript-eslint"
14+
parser: "@typescript-eslint/parser"
15+
parserOptions:
16+
project:
17+
- "./tsconfig.eslint.json"
18+
rules:
19+
max-len:
20+
- error
21+
- code: 180
22+
no-console: "off"
23+
no-underscore-dangle: "off"
24+
root: true
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/check-typescript-task.md
2+
name: Check TypeScript
3+
4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
8+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/check-typescript-task.ya?ml"
13+
- ".eslintignore"
14+
- "**/.eslintrc*"
15+
- "package.json"
16+
- "package-lock.json"
17+
- "Taskfile.ya?ml"
18+
- "tsconfig.eslint.json"
19+
- "tsconfig.json"
20+
- "**.[jt]sx?"
21+
pull_request:
22+
paths:
23+
- ".github/workflows/check-typescript-task.ya?ml"
24+
- ".eslintignore"
25+
- "**/.eslintrc*"
26+
- "package.json"
27+
- "package-lock.json"
28+
- "Taskfile.ya?ml"
29+
- "tsconfig.eslint.json"
30+
- "tsconfig.json"
31+
- "**.[jt]sx?"
32+
workflow_dispatch:
33+
repository_dispatch:
34+
35+
permissions:
36+
contents: read
37+
38+
jobs:
39+
check:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v3
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v3
48+
with:
49+
node-version: ${{ env.NODE_VERSION }}
50+
51+
- name: Install Task
52+
uses: arduino/setup-task@v1
53+
with:
54+
repo-token: ${{ secrets.GITHUB_TOKEN }}
55+
version: 3.x
56+
57+
- name: Lint
58+
run: task ts:lint

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[![Check Taskfiles status](https://github.com/arduino/setup-protoc/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-taskfiles.yml)
99
[![Integration Tests status](https://github.com/arduino/setup-protoc/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/test-integration.yml)
1010
[![Check npm status](https://github.com/arduino/setup-protoc/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-npm-task.yml)
11+
[![Check TypeScript status](https://github.com/arduino/setup-protoc/actions/workflows/check-typescript-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-typescript-task.yml)
1112

1213
This action makes the `protoc` compiler available to Workflows.
1314

Taskfile.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,16 @@ tasks:
219219
else
220220
echo "{{.RAW_PATH}}"
221221
fi
222+
ts:lint:
223+
desc: Lint TypeScript code
224+
deps:
225+
- task: npm:install-deps
226+
cmds:
227+
- npx eslint --ext .js,.jsx,.ts,.tsx .
228+
229+
ts:fix-lint:
230+
desc: Fix TypeScript code linting violations
231+
deps:
232+
- task: npm:install-deps
233+
cmds:
234+
- npx eslint --ext .js,.jsx,.ts,.tsx --fix .

0 commit comments

Comments
 (0)