From f0514810103529f3d0764beb0bf10fbe548538a6 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 8 Mar 2021 17:51:47 +0100 Subject: [PATCH] Devops/reviewdog typescript (#25) * Use reviewdog for TSC * Replace all `type Readonly` with `interface T` * Use --frozen-lockfile for yarn * Give all actions a name * Fix yarn example --- .github/workflows/build-docs.yml | 7 +- .github/workflows/validate-android.yml | 30 +++++- .github/workflows/validate-js.yml | 23 +++-- package.json | 1 - src/CameraDevice.ts | 12 +-- src/Code.ts | 4 +- src/PhotoFile.ts | 132 ++++++++++++------------- src/TemporaryFile.ts | 4 +- src/VideoFile.ts | 22 ++--- 9 files changed, 131 insertions(+), 104 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 500bd5d..56c021b 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -52,9 +52,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - with: - node-version: '12.x' + - name: Add key to allow access to repository env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock @@ -72,7 +70,8 @@ jobs: - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 + - name: Restore node_modules from cache + uses: actions/cache@v2 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} diff --git a/.github/workflows/validate-android.yml b/.github/workflows/validate-android.yml index cc1cb11..ea479b9 100644 --- a/.github/workflows/validate-android.yml +++ b/.github/workflows/validate-android.yml @@ -27,11 +27,35 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Setup node_modules - run: yarn --cwd .. + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Restore node_modules from cache + uses: actions/cache@v2 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install node_modules + run: yarn install --frozen-lockfile --cwd .. + + - name: Restore Gradle cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- - name: Run Gradle Lint run: ./gradlew lint - - uses: yutailang0119/action-android-lint@v1.0.2 + + - name: Parse Gradle Lint Report + uses: yutailang0119/action-android-lint@v1.0.2 with: xml_path: android/build/reports/lint-results.xml ktlint: diff --git a/.github/workflows/validate-js.yml b/.github/workflows/validate-js.yml index 5e4d680..1a75539 100644 --- a/.github/workflows/validate-js.yml +++ b/.github/workflows/validate-js.yml @@ -33,10 +33,14 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Install reviewdog + uses: reviewdog/action-setup@v1 + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 + - name: Restore node_modules from cache + uses: actions/cache@v2 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} @@ -44,13 +48,18 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - - name: Install modules - run: yarn - - name: Install modules (example/) - run: yarn example + - name: Install node_modules + run: yarn install --frozen-lockfile + - name: Install node_modules (example/) + run: yarn install --frozen-lockfile --cwd example - name: Run TypeScript - run: yarn typescript + run: yarn typescript | reviewdog -f=tsc -reporter=github-pr-review + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run ESLint - run: yarn lint-ci + uses: reviewdog/action-eslint@v1 + with: + reporter: github-pr-review + eslint_flags: '--ext .js,.ts,.jsx,.tsx src' diff --git a/package.json b/package.json index 9912a5d..f095223 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,6 @@ "registry": "https://registry.npmjs.org/" }, "devDependencies": { - "@firmnav/eslint-github-actions-formatter": "^1.0.1", "@react-native-community/eslint-config": "^2.0.0", "@react-native-community/eslint-plugin": "^1.1.0", "@release-it/conventional-changelog": "^2.0.0", diff --git a/src/CameraDevice.ts b/src/CameraDevice.ts index e441fec..7eff123 100644 --- a/src/CameraDevice.ts +++ b/src/CameraDevice.ts @@ -74,15 +74,15 @@ export type AutoFocusSystem = 'contrast-detection' | 'phase-detection' | 'none'; */ export type VideoStabilizationMode = 'off' | 'standard' | 'cinematic' | 'cinematic-extended' | 'auto'; -export type FrameRateRange = Readonly<{ +export interface FrameRateRange { minFrameRate: number; maxFrameRate: number; -}>; +} /** * A Camera Device's video format. Do not create instances of this type yourself, only use `Camera.getAvailableCameraDevices(...)`. */ -export type CameraDeviceFormat = Readonly<{ +export interface CameraDeviceFormat { /** * The height of the highest resolution a still image (photo) can be produced in */ @@ -151,12 +151,12 @@ export type CameraDeviceFormat = Readonly<{ * All supported video stabilization modes */ videoStabilizationModes: VideoStabilizationMode[]; -}>; +} /** * Represents a camera device discovered by the `Camera.getAvailableCameraDevices()` function */ -export type CameraDevice = Readonly<{ +export interface CameraDevice { /** * The native ID of the camera device instance. */ @@ -230,4 +230,4 @@ export type CameraDevice = Readonly<{ // * Whether this camera supports taking photos in RAW format // */ // supportsRawCapture: boolean; -}>; +} diff --git a/src/Code.ts b/src/Code.ts index c441112..1044c15 100644 --- a/src/Code.ts +++ b/src/Code.ts @@ -24,7 +24,7 @@ export type CodeType = /** * Represents a Metadata Code read by the Camera. Example: QR Code */ -export type Code = Readonly<{ +export interface Code { /** * The decoded string representation of the code. */ @@ -62,4 +62,4 @@ export type Code = Readonly<{ */ height: number; }; -}>; +} diff --git a/src/PhotoFile.ts b/src/PhotoFile.ts index 712bc1b..e816fac 100644 --- a/src/PhotoFile.ts +++ b/src/PhotoFile.ts @@ -65,74 +65,72 @@ export interface TakePhotoOptions { /** * Represents a Photo taken by the Camera written to the local filesystem. */ -export type PhotoFile = Readonly< - TemporaryFile & { - width: number; - height: number; - isRawPhoto: boolean; - thumbnail?: Record; - metadata: { - Orientation: number; +export interface PhotoFile extends TemporaryFile { + width: number; + height: number; + isRawPhoto: boolean; + thumbnail?: Record; + metadata: { + Orientation: number; + /** + * @platform iOS + */ + DPIHeight: number; + /** + * @platform iOS + */ + DPIWidth: number; + /** + * Represents any data Apple cameras write to the metadata + * + * @platform iOS + */ + '{MakerApple}'?: Record; + '{TIFF}': { + ResolutionUnit: number; + Software: string; + Make: string; + DateTime: string; + XResolution: number; /** * @platform iOS */ - DPIHeight: number; - /** - * @platform iOS - */ - DPIWidth: number; - /** - * Represents any data Apple cameras write to the metadata - * - * @platform iOS - */ - '{MakerApple}'?: Record; - '{TIFF}': { - ResolutionUnit: number; - Software: string; - Make: string; - DateTime: string; - XResolution: number; - /** - * @platform iOS - */ - HostComputer?: string; - Model: string; - YResolution: number; - }; - '{Exif}': { - DateTimeOriginal: string; - ExposureTime: number; - FNumber: number; - LensSpecification: number[]; - ExposureBiasValue: number; - ColorSpace: number; - FocalLenIn35mmFilm: number; - BrightnessValue: number; - ExposureMode: number; - LensModel: string; - SceneType: number; - PixelXDimension: number; - ShutterSpeedValue: number; - SensingMethod: number; - SubjectArea: number[]; - ApertureValue: number; - SubsecTimeDigitized: string; - FocalLength: number; - LensMake: string; - SubsecTimeOriginal: string; - OffsetTimeDigitized: string; - PixelYDimension: number; - ISOSpeedRatings: number[]; - WhiteBalance: number; - DateTimeDigitized: string; - OffsetTimeOriginal: string; - ExifVersion: string; - OffsetTime: string; - Flash: number; - ExposureProgram: number; - MeteringMode: number; - }; + HostComputer?: string; + Model: string; + YResolution: number; }; - } ->; + '{Exif}': { + DateTimeOriginal: string; + ExposureTime: number; + FNumber: number; + LensSpecification: number[]; + ExposureBiasValue: number; + ColorSpace: number; + FocalLenIn35mmFilm: number; + BrightnessValue: number; + ExposureMode: number; + LensModel: string; + SceneType: number; + PixelXDimension: number; + ShutterSpeedValue: number; + SensingMethod: number; + SubjectArea: number[]; + ApertureValue: number; + SubsecTimeDigitized: string; + FocalLength: number; + LensMake: string; + SubsecTimeOriginal: string; + OffsetTimeDigitized: string; + PixelYDimension: number; + ISOSpeedRatings: number[]; + WhiteBalance: number; + DateTimeDigitized: string; + OffsetTimeOriginal: string; + ExifVersion: string; + OffsetTime: string; + Flash: number; + ExposureProgram: number; + MeteringMode: number; + }; + }; +} diff --git a/src/TemporaryFile.ts b/src/TemporaryFile.ts index 1300047..9958fa3 100644 --- a/src/TemporaryFile.ts +++ b/src/TemporaryFile.ts @@ -1,9 +1,9 @@ /** * Represents a temporary file in the local filesystem. */ -export type TemporaryFile = Readonly<{ +export interface TemporaryFile { /** * The path of the file. This file might get deleted once the app closes because it lives in the temp directory. */ path: string; -}>; +} diff --git a/src/VideoFile.ts b/src/VideoFile.ts index e85a0f5..6dfe3fd 100644 --- a/src/VideoFile.ts +++ b/src/VideoFile.ts @@ -47,15 +47,13 @@ export interface RecordVideoOptions { /** * Represents a Video taken by the Camera written to the local filesystem. */ -export type VideoFile = Readonly< - TemporaryFile & { - /** - * Represents the duration of the video, in seconds. - */ - duration: number; - /** - * Represents the file size of the recorded Video File, in bytes. - */ - size: number; - } ->; +export interface VideoFile extends TemporaryFile { + /** + * Represents the duration of the video, in seconds. + */ + duration: number; + /** + * Represents the file size of the recorded Video File, in bytes. + */ + size: number; +}