diff --git a/.eslintrc.js b/.eslintrc.js index f6c4497..66c924b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,7 +10,7 @@ module.exports = { ecmaVersion: 2018, sourceType: 'module', }, - ignorePatterns: ['scripts', 'lib', 'docs', 'app.plugin.js'], + ignorePatterns: ['scripts', 'lib', 'docs', 'example', 'app.plugin.js'], plugins: ['@typescript-eslint'], extends: ['plugin:@typescript-eslint/recommended', '@react-native-community'], rules: { diff --git a/.github/workflows/validate-js.yml b/.github/workflows/validate-js.yml index da97573..f430c2b 100644 --- a/.github/workflows/validate-js.yml +++ b/.github/workflows/validate-js.yml @@ -61,6 +61,12 @@ jobs: env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run TypeScript in example/ # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m + run: | + cd example && yarn typescript | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee && cd .. + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + lint: name: Lint JS (eslint, prettier) runs-on: ubuntu-latest @@ -90,5 +96,11 @@ jobs: - name: Run ESLint with auto-fix run: yarn lint --fix + - name: Run ESLint in example/ + run: cd example && yarn lint -f @jamesacarr/github-actions && cd .. + + - name: Run ESLint in example/ with auto-fix + run: cd example && yarn lint --fix && cd .. + - name: Verify no files have changed after auto-fix run: git diff --exit-code HEAD diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 34c796f..53bc505 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -118,7 +118,7 @@ module.exports = { name: 'VisionCamera', entryPoints: ['../src'], exclude: "../src/index.ts", - tsconfig: '../tsconfig.build.json', + tsconfig: '../tsconfig.json', excludePrivate: true, excludeProtected: true, excludeExternals: true, diff --git a/example/.eslintrc.js b/example/.eslintrc.js new file mode 100644 index 0000000..d2b02b6 --- /dev/null +++ b/example/.eslintrc.js @@ -0,0 +1,16 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + ecmaFeatures: { + jsx: true, + }, + ecmaVersion: 2018, + sourceType: 'module', + }, + ignorePatterns: ['babel.config.js', 'metro.config.js', '.eslintrc.js', 'index.js'], + plugins: ['@typescript-eslint'], + extends: ['plugin:@typescript-eslint/recommended', '@react-native-community', '../.eslintrc.js'], +}; diff --git a/example/package.json b/example/package.json index 673c47c..a28c79a 100644 --- a/example/package.json +++ b/example/package.json @@ -9,7 +9,9 @@ "start": "react-native start", "setup": "cd ios && bundle install", "pods": "cd ios && bundle exec pod install", - "lint": "eslint ." + "lint": "eslint .", + "lint-ci": "yarn lint -f ../node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js", + "typescript": "tsc --noEmit" }, "dependencies": { "@react-native-community/blur": "^3.6.0", diff --git a/example/src/frame-processors/ExamplePlugin.ts b/example/src/frame-processors/ExamplePlugin.ts index 339a125..3ce414c 100644 --- a/example/src/frame-processors/ExamplePlugin.ts +++ b/example/src/frame-processors/ExamplePlugin.ts @@ -1,6 +1,8 @@ -/* global _WORKLET __example_plugin __example_plugin_swift */ +/* global __example_plugin __example_plugin_swift */ import type { Frame } from 'react-native-vision-camera'; +declare let _WORKLET: true | undefined; + export function examplePluginSwift(frame: Frame): string[] { 'worklet'; if (!_WORKLET) throw new Error('examplePluginSwift must be called from a frame processor!'); diff --git a/example/tsconfig.json b/example/tsconfig.json new file mode 100644 index 0000000..2a6716c --- /dev/null +++ b/example/tsconfig.json @@ -0,0 +1,15 @@ + +{ + "extends": "../tsconfig", + "compilerOptions": { + "paths": { + "react-native-vision-camera": ["../src/index"] + }, + }, + "include": [ + "src" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/package.json b/package.json index 95ce2d9..920aac3 100644 --- a/package.json +++ b/package.json @@ -156,7 +156,7 @@ [ "typescript", { - "project": "tsconfig.build.json" + "project": "tsconfig.json" } ] ] diff --git a/src/hooks/useFrameProcessor.ts b/src/hooks/useFrameProcessor.ts index 4623453..697872f 100644 --- a/src/hooks/useFrameProcessor.ts +++ b/src/hooks/useFrameProcessor.ts @@ -1,7 +1,7 @@ /* global _setGlobalConsole */ import { DependencyList, useCallback } from 'react'; -import type { Frame } from 'src/Frame'; +import type { Frame } from '../Frame'; type FrameProcessor = (frame: Frame) => void; diff --git a/src/utils/FormatFilter.ts b/src/utils/FormatFilter.ts index 9bc7c4a..7a8ae67 100644 --- a/src/utils/FormatFilter.ts +++ b/src/utils/FormatFilter.ts @@ -1,5 +1,5 @@ import { Dimensions } from 'react-native'; -import type { CameraDevice, CameraDeviceFormat, FrameRateRange } from 'react-native-vision-camera'; +import type { CameraDevice, CameraDeviceFormat, FrameRateRange } from '../CameraDevice'; /** * Compares two devices by the following criteria: diff --git a/tsconfig.build.json b/tsconfig.build.json deleted file mode 100644 index 999d3f3..0000000 --- a/tsconfig.build.json +++ /dev/null @@ -1,5 +0,0 @@ - -{ - "extends": "./tsconfig", - "exclude": ["example"] -} diff --git a/tsconfig.json b/tsconfig.json index 20db155..2b34e96 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,5 @@ { "compilerOptions": { - "baseUrl": ".", - "paths": { - "react-native-vision-camera": ["./src/index"] - }, "allowJs": false, "allowUnreachableCode": false, "allowUnusedLabels": false, @@ -28,13 +24,13 @@ }, "include": [ "src", - "example", ".eslintrc.js", "babel.config.js", ], "exclude": [ "node_modules", "lib", - "docs" + "docs", + "example" ] }