Skip to content

Commit

Permalink
feat: TS + Lint in CI (#77)
Browse files Browse the repository at this point in the history
* feat: TS + Lint in CI

* fix

* feat: Lint CI

* Update lint-typescript.yml

* Update lint-typescript.yml

* Update package.json
  • Loading branch information
mrousavy authored Aug 28, 2024
1 parent 254967a commit a0e2fea
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/lint-typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Lint TypeScript

permissions:
checks: write
contents: read
pull-requests: read

on:
push:
branches:
- main
paths:
- '.github/workflows/lint-typescript.yml'
- '**/*.ts'
- '**/*.tsx'
- '**/*.js'
- '**/*.jsx'
- '**/*.json'
- '**/*.lockb'
- '**/package.json'
pull_request:
paths:
- '.github/workflows/lint-typescript.yml'
- '**/*.ts'
- '**/*.tsx'
- '**/*.js'
- '**/*.jsx'
- '**/*.json'
- '**/*.lockb'
- '**/package.json'

jobs:
tsc:
name: Compile TypeScript (tsc)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- uses: reviewdog/action-setup@v1

- name: Install npm dependencies (bun)
run: bun install

- name: Run TypeScript (tsc)
run: |
bun typescript | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lint:
name: Lint TypeScript (eslint, prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- uses: reviewdog/action-setup@v1

- name: Install npm dependencies (bun)
run: bun install

- name: Run ESLint CI in example/
working-directory: example
run: bun lint-ci
- name: Run ESLint CI in packages/nitrogen
working-directory: packages/nitrogen
run: bun lint-ci
- name: Run ESLint CI in packages/react-native-nitro-image
working-directory: packages/react-native-nitro-image
run: bun lint-ci
- name: Run ESLint CI in packages/react-native-nitro-modules
working-directory: packages/react-native-nitro-modules
run: bun lint-ci

- name: Run ESLint with auto-fix in example/
working-directory: example
run: bun lint
- name: Run ESLint with auto-fix in packages/nitrogen
working-directory: packages/nitrogen
run: bun lint
- name: Run ESLint with auto-fix in packages/react-native-nitro-image
working-directory: packages/react-native-nitro-image
run: bun lint
- name: Run ESLint with auto-fix in packages/react-native-nitro-modules
working-directory: packages/react-native-nitro-modules
run: bun lint

- name: Verify no files have changed after auto-fix
run: git diff --exit-code HEAD
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"android": "react-native run-android",
"ios": "react-native run-ios",
"clean": "del-cli android/build node_modules/**/android/build lib",
"typescript": "tsc --noEmit false",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"start": "react-native start",
"pods": "cd ios && pod install && rm -rf .xcode.env.local",
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"bootstrap": "bun --filter=\"**\" install && bun tsc && bun --filter=\"react-native-nitro-example\" pods",
"typescript": "bun --filter=\"**\" typescript",
"lint": "bun --filter=\"**\" lint",
"lint-fix": "bun --filter=\"**\" lint --fix",
"release": "release-it",
"clean": "rm -rf packages/**/tsconfig.tsbuildinfo packages/**/node_modules packages/**/lib"
},
Expand All @@ -22,6 +23,7 @@
"devDependencies": {
"@release-it/conventional-changelog": "^8.0.1",
"@release-it/bumper": "^6.0.1",
"@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
"release-it": "^17.6.0"
},
"release-it": {
Expand Down
1 change: 1 addition & 0 deletions packages/nitrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"postinstall": "tsc || exit 0;",
"typecheck": "tsc --noEmit",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"release": "tsc && release-it",
"typescript": "tsc --noEmit false"
},
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-nitro-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"typecheck": "tsc --noEmit",
"clean": "del-cli android/build node_modules/**/android/build lib",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"typescript": "tsc --noEmit false",
"specs": "bun run --filter=\"**\" typescript && bun nitro-codegen --logLevel=\"debug\""
},
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-nitro-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"typecheck": "tsc --noEmit",
"clean": "del-cli android/build node_modules/**/android/build lib",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"release": "bob build && release-it",
"typescript": "tsc --noEmit false"
},
Expand Down

0 comments on commit a0e2fea

Please sign in to comment.