fix: lint issues

This commit is contained in:
Fredrik Burmester
2025-11-16 08:50:01 +01:00
parent 2a61124a0d
commit 64ffc8db8b
4 changed files with 72 additions and 204 deletions

177
.vscode/settings.json vendored
View File

@@ -1,178 +1,25 @@
{ {
// ==========================================
// FORMATTING & LINTING
// ==========================================
// Biome as default formatter
"editor.defaultFormatter": "biomejs.biome", "editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.formatOnPaste": true, "editor.codeActionsOnSave": {
"editor.formatOnType": false, "source.fixAll.biome": "explicit"
// Language-specific formatters
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
}, },
"[typescript]": { "[typescript]": {
"editor.defaultFormatter": "biomejs.biome", "editor.defaultFormatter": "biomejs.biome"
"editor.formatOnSave": true
}, },
"[typescriptreact]": { "[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome", "editor.defaultFormatter": "biomejs.biome"
"editor.formatOnSave": true },
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
}, },
"[javascriptreact]": { "[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome", "editor.defaultFormatter": "biomejs.biome"
"editor.formatOnSave": true
}, },
"[json]": { "[json]": {
"editor.defaultFormatter": "biomejs.biome", "editor.defaultFormatter": "biomejs.biome"
"editor.formatOnSave": true
}, },
"[jsonc]": { "typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "biomejs.biome", "typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": true "editor.formatOnSaveMode": "file"
},
"[swift]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
// ==========================================
// TYPESCRIPT & JAVASCRIPT
// ==========================================
// TypeScript performance optimizations
"typescript.preferences.includePackageJsonAutoImports": "auto",
"typescript.suggest.autoImports": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"typescript.preferences.preferTypeOnlyAutoImports": true,
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.includeCompletionsForImportStatements": true,
"typescript.preferences.includeCompletionsWithSnippetText": true,
// JavaScript settings
"javascript.preferences.importModuleSpecifier": "relative",
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
// ==========================================
// REACT NATIVE & EXPO
// ==========================================
// File associations for React Native
"files.associations": {
"*.expo.ts": "typescript",
"*.expo.tsx": "typescriptreact",
"*.expo.js": "javascript",
"*.expo.jsx": "javascriptreact",
"metro.config.js": "javascript",
"babel.config.js": "javascript",
"app.config.js": "javascript",
"eas.json": "jsonc"
},
// React Native specific settings
"emmet.includeLanguages": {
"typescriptreact": "html",
"javascriptreact": "html"
},
"emmet.triggerExpansionOnTab": true,
// Exclude build directories from search
"search.exclude": {
"**/node_modules": true
},
// ==========================================
// EDITOR PERFORMANCE & UX
// ==========================================
// Performance optimizations
"editor.largeFileOptimizations": true,
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/.expo/**": true,
"**/ios/**": true,
"**/android/**": true,
"**/build/**": true,
"**/dist/**": true
},
// Better editor behavior
"editor.suggestSelection": "first",
"editor.quickSuggestions": {
"strings": true,
"comments": true,
"other": true
},
"editor.snippetSuggestions": "top",
"editor.tabCompletion": "on",
"editor.wordBasedSuggestions": "off",
// ==========================================
// TERMINAL & DEVELOPMENT
// ==========================================
// Terminal settings for Bun (Windows-specific)
"terminal.integrated.profiles.windows": {
"Command Prompt": {
"path": "C:\\Windows\\System32\\cmd.exe",
"env": {
"PATH": "${env:PATH};./node_modules/.bin"
}
}
},
// ==========================================
// WORKSPACE & NAVIGATION
// ==========================================
// Better workspace navigation
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.js",
"*.tsx": "${capture}.js",
"*.js": "${capture}.js,${capture}.js.map,${capture}.min.js,${capture}.d.ts",
"*.jsx": "${capture}.js",
"package.json": "package-lock.json,yarn.lock,bun.lock,bun.lockb,.yarnrc,.yarnrc.yml",
"tsconfig.json": "tsconfig.*.json",
".env": ".env.*",
"app.json": "app.config.js,eas.json,expo-env.d.ts",
"README.md": "LICENSE.txt,SECURITY.md,CODE_OF_CONDUCT.md,CONTRIBUTING.md"
},
// Better breadcrumbs and navigation
"breadcrumbs.enabled": true,
"outline.showVariables": true,
"outline.showConstants": true,
// ==========================================
// GIT & VERSION CONTROL
// ==========================================
// Git integration
"git.autofetch": true,
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.ignoreLimitWarning": true,
// ==========================================
// CODE QUALITY & ERRORS
// ==========================================
// Better error detection
"typescript.validate.enable": true,
"javascript.validate.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
// Problem matcher for better error display
"typescript.tsc.autoDetect": "on"
} }

View File

@@ -1,12 +1,19 @@
import type { OrientationChangeEvent } from "expo-screen-orientation";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Platform } from "react-native"; import { Platform } from "react-native";
import * as ScreenOrientation from "@/packages/expo-screen-orientation"; import {
import { OrientationLock } from "@/packages/expo-screen-orientation"; addOrientationChangeListener,
getOrientationAsync,
lockAsync,
Orientation as OrientationEnum,
OrientationLock,
unlockAsync,
} from "@/packages/expo-screen-orientation";
import { Orientation } from "../packages/expo-screen-orientation.tv"; import { Orientation } from "../packages/expo-screen-orientation.tv";
const orientationToOrientationLock = ( const orientationToOrientationLock = (
orientation: Orientation, orientation: (typeof OrientationEnum)[keyof typeof OrientationEnum],
): OrientationLock => { ): (typeof OrientationLock)[keyof typeof OrientationLock] => {
switch (orientation) { switch (orientation) {
case Orientation.LANDSCAPE_LEFT: case Orientation.LANDSCAPE_LEFT:
return OrientationLock.LANDSCAPE_LEFT; return OrientationLock.LANDSCAPE_LEFT;
@@ -21,44 +28,52 @@ const orientationToOrientationLock = (
export const useOrientation = () => { export const useOrientation = () => {
const [orientation, setOrientation] = useState( const [orientation, setOrientation] = useState(
Platform.isTV Platform.isTV ? OrientationLock.LANDSCAPE : OrientationLock.UNKNOWN,
? ScreenOrientation.OrientationLock.LANDSCAPE
: ScreenOrientation.OrientationLock.UNKNOWN,
); );
useEffect(() => { useEffect(() => {
if (Platform.isTV) return; if (Platform.isTV) return;
const orientationSubscription = const orientationSubscription = addOrientationChangeListener(
ScreenOrientation.addOrientationChangeListener((event) => { (event: OrientationChangeEvent) => {
setOrientation( setOrientation(
orientationToOrientationLock(event.orientationInfo.orientation), orientationToOrientationLock(event.orientationInfo.orientation),
); );
}); },
);
ScreenOrientation.getOrientationAsync().then((orientation) => { getOrientationAsync().then(
(orientation: (typeof OrientationEnum)[keyof typeof OrientationEnum]) => {
setOrientation(orientationToOrientationLock(orientation)); setOrientation(orientationToOrientationLock(orientation));
}); },
);
return () => { return () => {
orientationSubscription.remove(); orientationSubscription.remove();
}; };
}, []); }, []);
const lockOrientation = async (lock: OrientationLock) => { const lockOrientation = async (
lock: (typeof OrientationLock)[keyof typeof OrientationLock],
) => {
if (Platform.isTV) return; if (Platform.isTV) return;
if (lock === ScreenOrientation.OrientationLock.DEFAULT) { if (lock === OrientationLock.DEFAULT) {
await ScreenOrientation.unlockAsync(); await unlockAsync();
} else { } else {
await ScreenOrientation.lockAsync(lock); await lockAsync(lock);
} }
}; };
const unlockOrientation = async () => { const unlockOrientationFn = async () => {
if (Platform.isTV) return; if (Platform.isTV) return;
await ScreenOrientation.unlockAsync(); await unlockAsync();
}; };
return { orientation, setOrientation, lockOrientation, unlockOrientation }; return {
orientation,
setOrientation,
lockOrientation,
unlockOrientation: unlockOrientationFn,
};
}; };

View File

@@ -1,24 +1,26 @@
import { Platform } from "react-native"; import { Platform } from "react-native";
// Dummy exports for TV // Dummy exports for TV
const DummyOrientationLock = { enum DummyOrientationLock {
DEFAULT: 0, DEFAULT = 0,
ALL: 1, ALL = 1,
PORTRAIT: 2, PORTRAIT = 2,
PORTRAIT_UP: 3, PORTRAIT_UP = 3,
PORTRAIT_DOWN: 4, PORTRAIT_DOWN = 4,
LANDSCAPE: 5, LANDSCAPE = 5,
LANDSCAPE_LEFT: 6, LANDSCAPE_LEFT = 6,
LANDSCAPE_RIGHT: 7, LANDSCAPE_RIGHT = 7,
}; OTHER = 8,
UNKNOWN = 9,
}
const DummyOrientation = { enum DummyOrientation {
UNKNOWN: 0, UNKNOWN = 0,
PORTRAIT_UP: 1, PORTRAIT_UP = 1,
PORTRAIT_DOWN: 2, PORTRAIT_DOWN = 2,
LANDSCAPE_LEFT: 3, LANDSCAPE_LEFT = 3,
LANDSCAPE_RIGHT: 4, LANDSCAPE_RIGHT = 4,
}; }
const dummyLockAsync = async () => {}; const dummyLockAsync = async () => {};
const dummyUnlockAsync = async () => {}; const dummyUnlockAsync = async () => {};
@@ -38,6 +40,10 @@ export const OrientationLock = Platform.isTV
export const Orientation = Platform.isTV export const Orientation = Platform.isTV
? DummyOrientation ? DummyOrientation
: ScreenOrientation?.Orientation; : ScreenOrientation?.Orientation;
// Export types
export type OrientationLockType = typeof OrientationLock;
export type OrientationType = typeof Orientation;
export const lockAsync = Platform.isTV export const lockAsync = Platform.isTV
? dummyLockAsync ? dummyLockAsync
: ScreenOrientation?.lockAsync; : ScreenOrientation?.lockAsync;

View File

@@ -26,7 +26,7 @@ export type DownloadOption = {
}; };
export const ScreenOrientationEnum: Record< export const ScreenOrientationEnum: Record<
ScreenOrientation.OrientationLock, (typeof ScreenOrientation.OrientationLock)[keyof typeof ScreenOrientation.OrientationLock],
string string
> = { > = {
[ScreenOrientation.OrientationLock.DEFAULT]: [ScreenOrientation.OrientationLock.DEFAULT]:
@@ -154,7 +154,7 @@ export type Settings = {
subtitleMode: SubtitlePlaybackMode; subtitleMode: SubtitlePlaybackMode;
rememberSubtitleSelections: boolean; rememberSubtitleSelections: boolean;
showHomeTitles: boolean; showHomeTitles: boolean;
defaultVideoOrientation: ScreenOrientation.OrientationLock; defaultVideoOrientation: (typeof ScreenOrientation.OrientationLock)[keyof typeof ScreenOrientation.OrientationLock];
forwardSkipTime: number; forwardSkipTime: number;
rewindSkipTime: number; rewindSkipTime: number;
showCustomMenuLinks: boolean; showCustomMenuLinks: boolean;