Skip to content

Commit 5ccf14d

Browse files
Merge pull request #55 from MatteoPologruto/check-typescript
Add CI workflow to lint TypeScript and JavaScript code
2 parents ab6203d + e3ce82e commit 5ccf14d

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 | true

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
@@ -228,3 +228,16 @@ tasks:
228228
else
229229
echo "{{.RAW_PATH}}"
230230
fi
231+
ts:lint:
232+
desc: Lint TypeScript code
233+
deps:
234+
- task: npm:install-deps
235+
cmds:
236+
- npx eslint --ext .js,.jsx,.ts,.tsx .
237+
238+
ts:fix-lint:
239+
desc: Fix TypeScript code linting violations
240+
deps:
241+
- task: npm:install-deps
242+
cmds:
243+
- npx eslint --ext .js,.jsx,.ts,.tsx --fix .

0 commit comments

Comments
 (0)