Skip to content

Commit a2293e8

Browse files
authored
fix: Fix TypeScript relative imports (mrousavy#358)
* fix: Fix TypeScript relative imports * Decouple `example` from tsconfig * fix ESLint config * add lint-ci script * move example running to workflow * test ts * test eslint * test ts * fix ESLint formatter * Revert "fix ESLint formatter" This reverts commit 21aca0d. * Revert "test ts" This reverts commit becc346. * Revert "test eslint" This reverts commit 9c9f0b8. * Revert "test ts" This reverts commit 3cbe720.
1 parent b5452ac commit a2293e8

12 files changed

+56
-18
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
ecmaVersion: 2018,
1111
sourceType: 'module',
1212
},
13-
ignorePatterns: ['scripts', 'lib', 'docs', 'app.plugin.js'],
13+
ignorePatterns: ['scripts', 'lib', 'docs', 'example', 'app.plugin.js'],
1414
plugins: ['@typescript-eslint'],
1515
extends: ['plugin:@typescript-eslint/recommended', '@react-native-community'],
1616
rules: {

.github/workflows/validate-js.yml

+12
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ jobs:
6161
env:
6262
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6363

64+
- name: Run TypeScript in example/ # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m
65+
run: |
66+
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 ..
67+
env:
68+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
6470
lint:
6571
name: Lint JS (eslint, prettier)
6672
runs-on: ubuntu-latest
@@ -90,5 +96,11 @@ jobs:
9096
- name: Run ESLint with auto-fix
9197
run: yarn lint --fix
9298

99+
- name: Run ESLint in example/
100+
run: cd example && yarn lint -f @jamesacarr/github-actions && cd ..
101+
102+
- name: Run ESLint in example/ with auto-fix
103+
run: cd example && yarn lint --fix && cd ..
104+
93105
- name: Verify no files have changed after auto-fix
94106
run: git diff --exit-code HEAD

docs/docusaurus.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module.exports = {
118118
name: 'VisionCamera',
119119
entryPoints: ['../src'],
120120
exclude: "../src/index.ts",
121-
tsconfig: '../tsconfig.build.json',
121+
tsconfig: '../tsconfig.json',
122122
excludePrivate: true,
123123
excludeProtected: true,
124124
excludeExternals: true,

example/.eslintrc.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
tsconfigRootDir: __dirname,
6+
project: ['./tsconfig.json'],
7+
ecmaFeatures: {
8+
jsx: true,
9+
},
10+
ecmaVersion: 2018,
11+
sourceType: 'module',
12+
},
13+
ignorePatterns: ['babel.config.js', 'metro.config.js', '.eslintrc.js', 'index.js'],
14+
plugins: ['@typescript-eslint'],
15+
extends: ['plugin:@typescript-eslint/recommended', '@react-native-community', '../.eslintrc.js'],
16+
};

example/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"start": "react-native start",
1010
"setup": "cd ios && bundle install",
1111
"pods": "cd ios && bundle exec pod install",
12-
"lint": "eslint ."
12+
"lint": "eslint .",
13+
"lint-ci": "yarn lint -f ../node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js",
14+
"typescript": "tsc --noEmit"
1315
},
1416
"dependencies": {
1517
"@react-native-community/blur": "^3.6.0",

example/src/frame-processors/ExamplePlugin.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
/* global _WORKLET __example_plugin __example_plugin_swift */
1+
/* global __example_plugin __example_plugin_swift */
22
import type { Frame } from 'react-native-vision-camera';
33

4+
declare let _WORKLET: true | undefined;
5+
46
export function examplePluginSwift(frame: Frame): string[] {
57
'worklet';
68
if (!_WORKLET) throw new Error('examplePluginSwift must be called from a frame processor!');

example/tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{
3+
"extends": "../tsconfig",
4+
"compilerOptions": {
5+
"paths": {
6+
"react-native-vision-camera": ["../src/index"]
7+
},
8+
},
9+
"include": [
10+
"src"
11+
],
12+
"exclude": [
13+
"node_modules"
14+
]
15+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
[
157157
"typescript",
158158
{
159-
"project": "tsconfig.build.json"
159+
"project": "tsconfig.json"
160160
}
161161
]
162162
]

src/hooks/useFrameProcessor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global _setGlobalConsole */
22

33
import { DependencyList, useCallback } from 'react';
4-
import type { Frame } from 'src/Frame';
4+
import type { Frame } from '../Frame';
55

66
type FrameProcessor = (frame: Frame) => void;
77

src/utils/FormatFilter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Dimensions } from 'react-native';
2-
import type { CameraDevice, CameraDeviceFormat, FrameRateRange } from 'react-native-vision-camera';
2+
import type { CameraDevice, CameraDeviceFormat, FrameRateRange } from '../CameraDevice';
33

44
/**
55
* Compares two devices by the following criteria:

tsconfig.build.json

-5
This file was deleted.

tsconfig.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
4-
"paths": {
5-
"react-native-vision-camera": ["./src/index"]
6-
},
73
"allowJs": false,
84
"allowUnreachableCode": false,
95
"allowUnusedLabels": false,
@@ -28,13 +24,13 @@
2824
},
2925
"include": [
3026
"src",
31-
"example",
3227
".eslintrc.js",
3328
"babel.config.js",
3429
],
3530
"exclude": [
3631
"node_modules",
3732
"lib",
38-
"docs"
33+
"docs",
34+
"example"
3935
]
4036
}

0 commit comments

Comments
 (0)