Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
pre-commit:
parallel: true
parallel: false
commands:
xo:
# lint --fix first, then oxfmt last (avoids write races); stage_fixed re-stages edits
oxlint:
priority: 1
glob: '*.{js,mjs,ts,tsx}'
run: pnpm xo {staged_files}
run: pnpm oxlint --fix {staged_files}
stage_fixed: true
oxfmt:
priority: 2
glob: '*.{js,mjs,ts,tsx}'
run: pnpm oxfmt {staged_files}
stage_fixed: true
32 changes: 32 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"singleQuote": true,
"tabWidth": 2,
"printWidth": 80,
"trailingComma": "es5",
"bracketSpacing": true,
"endOfLine": "lf",
"sortPackageJson": true,
"sortTailwindcss": {
"stylesheet": "packages/ui/src/styles/globals.css",
"functions": ["clsx", "cn", "cva"]
},
"sortImports": {
"internalPattern": [
"@/",
"@app/",
"@ui/",
"@public/",
"@background/",
"@helpers/",
"@popup/",
"@store/"
]
},
"ignorePatterns": [
"packages/ui/src",
"**/.output/**",
"**/.next/**",
"**/.wxt/**"
]
}
85 changes: 85 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "unicorn", "oxc", "react", "import", "promise"],
"jsPlugins": ["oxlint-tailwindcss"],
"categories": {
"correctness": "error"
},
"settings": {
"next": {
"rootDir": "apps/web/"
},
"tailwindcss": {
"entryPoint": "packages/ui/src/styles/globals.css"
}
},
"options": {
"typeAware": true,
"reportUnusedDisableDirectives": "warn"
},
Comment thread
amitsingh-007 marked this conversation as resolved.
"rules": {
"react/react-in-jsx-scope": "off",

"typescript/no-unsafe-assignment": "off",
"typescript/no-unsafe-return": "off",
"typescript/no-unsafe-argument": "off",
"typescript/no-unsafe-call": "off",
"typescript/no-dynamic-delete": "off",
"typescript/triple-slash-reference": "off",

"typescript/no-floating-promises": "off",
"typescript/no-useless-default-assignment": "off",
"typescript/unbound-method": "off",

"typescript/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"typescript/consistent-type-definitions": ["error", "interface"],
"typescript/no-confusing-void-expression": [
"error",
{ "ignoreArrowShorthand": true }
],
"typescript/no-base-to-string": [
"error",
{ "ignoredTypeNames": ["TRPCError", "URL", "URLSearchParams"] }
],
"typescript/restrict-template-expressions": [
"error",
{ "allow": ["TRPCError", "Date"] }
],
"typescript/switch-exhaustiveness-check": [
"error",
{
"considerDefaultExhaustiveForUnions": true,
"requireDefaultForNonUnion": true
}
],

"tailwindcss/no-unknown-classes": [
"error",
{ "allowlist": ["max-w-panel"] }
],
"tailwindcss/no-conflicting-classes": "error",
"tailwindcss/no-duplicate-classes": "error",
"tailwindcss/no-deprecated-classes": "error"
},
"overrides": [
{
"files": ["apps/web/**/*.{ts,tsx}"],
"plugins": ["nextjs"]
},
{
"files": [
"apps/extension/**/*.{ts,tsx}",
"packages/shared/**/*.{ts,tsx}"
],
"rules": {
"react/react-compiler": "warn"
}
}
],
"ignorePatterns": [
"apps/web/next-env.d.ts",
"apps/extension/.output/**",
"apps/extension/.wxt/**",
"packages/ui/**"
Comment thread
amitsingh-007 marked this conversation as resolved.
]
}
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["oxc.oxc-vscode", "TypeScriptTeam.native-preview"]
}
20 changes: 19 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
{
"js/ts.tsdk.path": "node_modules/typescript/lib"
"js/ts.experimental.useTsgo": true,
"js/ts.tsdk.path": "./node_modules/typescript",

"oxc.enable": true,
"oxc.enable.oxfmt": true,
"oxc.lint.run": "onSave",
"oxc.typeAware": true,

"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "explicit"
},

"[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[typescriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[javascript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[javascriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" }
}
12 changes: 9 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ pnpm build # Build Chrome extension to .output/chrome-mv3
pnpm dev # Chrome dev server with hot reload

# Code Quality
pnpm lint # Lint all files (XO linter)
pnpm lint # Lint all files (oxlint, type-aware) with autofix
pnpm lint:ci # Lint without autofix (CI)
pnpm format # Format all files (oxfmt)
pnpm format:check # Check formatting without writing (oxfmt --check)
pnpm typecheck # Type check root only
pnpm typecheck:all # Type check all workspaces

Expand All @@ -45,7 +48,7 @@ This is a **Turbo + pnpm monorepo** with the following structure:
- **apps/web** - Next.js web interface for downloads and admin
- **packages/shared** - Shared React components, types, utilities, and stores (Zustand)
- **packages/ui** - Shared UI components using shadcn/ui Base UI + Tailwind CSS
- **packages/configs** - Shared TypeScript, ESLint (XO), and build configs
- **packages/configs** - Shared TypeScript and build configs
- **packages/trpc** - tRPC router with Firebase backend (type-safe API)

## Build System
Expand Down Expand Up @@ -76,7 +79,9 @@ Playwright tests use setup/teardown projects for both web and extension flows:
- **API**: tRPC for type-safe client-server communication
- **Backend**: Firebase with Admin SDK
- **Testing**: Playwright
- **Linting**: XO with custom config
- **Linting**: oxlint (type-aware via oxlint-tsgolint), config in `.oxlintrc.json`
- **Formatting**: oxfmt, config in `.oxfmtrc.json`
- **Tailwind linting**: `oxlint-tailwindcss` (native oxlint plugin)

## Code Patterns

Expand Down Expand Up @@ -119,6 +124,7 @@ Always after making changes, run the following commands:

```bash
pnpm lint
pnpm format:check
pnpm typecheck:all
pnpm e2e <relative-filepath>
```
4 changes: 2 additions & 2 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@bypass/extension",
"type": "module",
"version": "24.12.1",
"version": "24.13.0",
"private": true,
"description": "Bypass links from various sites to required links, with added functionality of Bookmarks Manager, Tagging Panel.",
"type": "module",
"scripts": {
"build": "wxt zip",
"dev": "wxt",
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/apis/trpcApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AppRouter } from '@bypass/trpc';
import { createTRPCClient, httpBatchLink, loggerLink } from '@trpc/client';

import { env } from '@/constants/env';
import useFirebaseStore from '@/store/firebase/useFirebaseStore';

Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/apis/wretchApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import wretch from 'wretch';

import { env } from '@/constants/env';
import useFirebaseStore from '@/store/firebase/useFirebaseStore';

Expand Down
14 changes: 8 additions & 6 deletions apps/extension/src/entrypoints/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { defineBackground } from 'wxt/utils/define-background';
import turnOffInputSuggestions from './misc/turnOffInputSuggestions';
import { redirect } from './redirections';
import { isValidTabUrl, isValidUrl, setExtensionIcon } from './utils';
import { receiveRuntimeMessage } from './utils/receiveRuntimeMessage';
import { type RuntimeInput } from '@/utils/sendRuntimeMessage';
import { getIsExtensionActive } from '@/utils/common';

import { EExtensionState } from '@/constants';
import {
extStateItem,
hasPendingBookmarksItem,
hasPendingPersonsItem,
} from '@/storage/items';
import { getIsExtensionActive } from '@/utils/common';
import { type RuntimeInput } from '@/utils/sendRuntimeMessage';

import turnOffInputSuggestions from './misc/turnOffInputSuggestions';
import { redirect } from './redirections';
import { isValidTabUrl, isValidUrl, setExtensionIcon } from './utils';
import { receiveRuntimeMessage } from './utils/receiveRuntimeMessage';

export default defineBackground({
type: 'module',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { mapRedirections } from './mapper';
import { startHistoryWatch } from '@/utils/history';
import { trpcApi } from '@/apis/trpcApi';
import { redirectionsItem, mappedRedirectionsItem } from '@/storage/items';
import { startHistoryWatch } from '@/utils/history';

import { mapRedirections } from './mapper';

export const redirect = async (tabId: number, url: URL) => {
url.protocol = 'http:';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type IRedirections } from '@bypass/shared';

import { type IMappedRedirections } from '../interfaces/redirections';

export const mapRedirections = (
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/entrypoints/background/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type EExtensionState } from '@/constants';
import { extStateItem } from '@/storage/items';
import { getIsExtensionActive } from '@/utils/common';
import { type EExtensionState } from '@/constants';

const restrictedProtocols = new Set([
'chrome:', // Chrome browser internal URLs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getForumPageLinks } from '../misc/forumPageLinks';
import {
type RuntimeInput,
type RuntimeKeys,
type RuntimeOutput,
} from '@/utils/sendRuntimeMessage';

import { getForumPageLinks } from '../misc/forumPageLinks';

export const receiveRuntimeMessage = (
message: RuntimeInput,
sendMessage: <T extends RuntimeKeys>(data: RuntimeOutput[T]) => void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type IWebsites } from '@bypass/shared';

import { trpcApi } from '@/apis/trpcApi';
import { websitesItem } from '@/storage/items';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { HugeiconsIcon } from '@hugeicons/react';
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuTrigger,
} from '@bypass/ui';
import { HugeiconsIcon } from '@hugeicons/react';
import { useRef } from 'react';

export interface IMenuOption {
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/entrypoints/popup/components/Global.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Toaster } from '@bypass/ui';
import { useHotkeys } from '@mantine/hooks';

import StoreListener from './StoreListener';

function Global() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Suspense } from 'react';
import { Switch } from 'wouter';

import { BookmarksPanelRoute } from '../panels/BookmarksPanel/routes';
import { HomePageRoute } from '../panels/HomePopup/routes';
import { PersonsPanelRoute } from '../panels/PersonsPanel/routes';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import useHistoryStore from '@store/history';
import { useEffect } from 'react';

import { startHistoryWatch } from '@/utils/history';
import useHistoryStore from '@store/history';

function StoreListener() {
const monitorHistory = useHistoryStore((state) => state.monitorHistory);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react';

import { getCurrentTab } from '@popup/utils/tabs';

const useCurrentTab = () => {
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/entrypoints/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '@bypass/ui/styles/globals.css';
import { TooltipProvider } from '@bypass/ui';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import './fonts.css';
import Global from './components/Global';
import PopupRoutes from './components/PopupRoutes';
Expand Down
Loading
Loading