Skip to content

Commit

Permalink
Merge pull request #55 from MatteoPologruto/check-typescript
Browse files Browse the repository at this point in the history
Add CI workflow to lint TypeScript and JavaScript code
  • Loading branch information
MatteoPologruto authored May 17, 2023
2 parents ab6203d + e3ce82e commit 5ccf14d
Show file tree
Hide file tree
Showing 8 changed files with 8,762 additions and 4,834 deletions.
24 changes: 24 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/assets/check-typescript/.eslintrc.yml
# See: https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/README.md#configuration
# The code style defined in this file is the official standardized style to be used in all Arduino projects and should
# not be modified.

extends:
- airbnb-typescript/base
- prettier
- 'eslint:recommended'
- 'plugin:@typescript-eslint/recommended'
- 'plugin:import/recommended'
plugins:
- "@typescript-eslint"
parser: "@typescript-eslint/parser"
parserOptions:
project:
- "./tsconfig.eslint.json"
rules:
max-len:
- error
- code: 180
no-console: "off"
no-underscore-dangle: "off"
root: true
58 changes: 58 additions & 0 deletions .github/workflows/check-typescript-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/check-typescript-task.md
name: Check TypeScript

env:
# See: https://github.com/actions/setup-node/#readme
NODE_VERSION: 16.x

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-typescript-task.ya?ml"
- ".eslintignore"
- "**/.eslintrc*"
- "package.json"
- "package-lock.json"
- "Taskfile.ya?ml"
- "tsconfig.eslint.json"
- "tsconfig.json"
- "**.[jt]sx?"
pull_request:
paths:
- ".github/workflows/check-typescript-task.ya?ml"
- ".eslintignore"
- "**/.eslintrc*"
- "package.json"
- "package-lock.json"
- "Taskfile.ya?ml"
- "tsconfig.eslint.json"
- "tsconfig.json"
- "**.[jt]sx?"
workflow_dispatch:
repository_dispatch:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest

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

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Lint
run: task ts:lint | true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![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)
[![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)
[![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)
[![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)

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

Expand Down
13 changes: 13 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,16 @@ tasks:
else
echo "{{.RAW_PATH}}"
fi
ts:lint:
desc: Lint TypeScript code
deps:
- task: npm:install-deps
cmds:
- npx eslint --ext .js,.jsx,.ts,.tsx .

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

0 comments on commit 5ccf14d

Please sign in to comment.