Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI workflow to lint TypeScript and JavaScript code #55

Merged
merged 2 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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