-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(cookies): migrate cookies package into monorepo #5543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,9 @@ This is the **Eggjs** framework - a progressive Node.js framework for building e | |||||||||||||||||||||||||||||||
| - **`packages/cluster/`** - Cluster management (merged from @eggjs/cluster) | ||||||||||||||||||||||||||||||||
| - `src/` - Cluster TypeScript source code | ||||||||||||||||||||||||||||||||
| - `test/` - Cluster test suite | ||||||||||||||||||||||||||||||||
| - **`packages/cookies/`** - Cookie handling utilities (merged from @eggjs/cookies) | ||||||||||||||||||||||||||||||||
| - `src/` - Cookies TypeScript source code | ||||||||||||||||||||||||||||||||
| - `test/` - Cookies test suite with Mocha | ||||||||||||||||||||||||||||||||
| - **`packages/koa/`** - Koa web framework (merged from @eggjs/koa) | ||||||||||||||||||||||||||||||||
| - `src/` - Koa TypeScript source code | ||||||||||||||||||||||||||||||||
| - `test/` - Koa test suite | ||||||||||||||||||||||||||||||||
|
|
@@ -105,7 +108,9 @@ The framework follows a specific loading order: | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - `pnpm -r run build` - Build all packages | ||||||||||||||||||||||||||||||||
| - `pnpm -r run clean` - Clean dist directories in all packages | ||||||||||||||||||||||||||||||||
| - `pnpm lint` - Run ESLint in all packages | ||||||||||||||||||||||||||||||||
| - `pnpm -r run typecheck` - Run TypeScript type checking with `tsc --noEmit` | ||||||||||||||||||||||||||||||||
| - `pnpm lint` - Run oxlint with type-aware checking in all packages | ||||||||||||||||||||||||||||||||
| - `pnpm lint:fix` - Auto-fix linting issues with oxlint | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ### Examples | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -256,6 +261,10 @@ Plugins should configure their package.json following this pattern: | |||||||||||||||||||||||||||||||
| "scripts": { | ||||||||||||||||||||||||||||||||
| "build": "tsdown", | ||||||||||||||||||||||||||||||||
| "clean": "rimraf dist", | ||||||||||||||||||||||||||||||||
| "typecheck": "tsc --noEmit", | ||||||||||||||||||||||||||||||||
| "lint": "oxlint --type-aware", | ||||||||||||||||||||||||||||||||
| "lint:fix": "npm run lint -- --fix", | ||||||||||||||||||||||||||||||||
| "test": "npm run lint:fix && vitest", | ||||||||||||||||||||||||||||||||
| "prepublishOnly": "npm run build" | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
@@ -281,13 +290,24 @@ Tool packages (like egg-bin) should be placed in the `tools/` directory: | |||||||||||||||||||||||||||||||
| ### Testing Strategy | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - **IMPORTANT: All new packages MUST use Vitest for testing** - this is the standard test runner for the monorepo | ||||||||||||||||||||||||||||||||
| - **Exception: egg-bin uses Mocha** - the CLI tool package uses Mocha for consistency with CLI testing patterns | ||||||||||||||||||||||||||||||||
| - **Exception: egg-bin and cookies use Mocha** - these packages use Mocha for consistency with their testing patterns | ||||||||||||||||||||||||||||||||
| - Use `pnpm --filter=egg run test` for framework tests | ||||||||||||||||||||||||||||||||
| - Test fixtures are in `packages/egg/test/fixtures/apps/` | ||||||||||||||||||||||||||||||||
| - Create apps in fixtures to test specific scenarios | ||||||||||||||||||||||||||||||||
| - Use `pnpm test` to run tests across all packages | ||||||||||||||||||||||||||||||||
| - Follow existing test patterns for consistency | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
292
to
299
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align “Testing Strategy” section: only egg-bin uses Mocha. This block lists cookies as a Mocha exception, but the codebase uses Vitest for cookies tests. Update to avoid drift. Apply this diff: -- **Exception: egg-bin and cookies use Mocha** - these packages use Mocha for consistency with their testing patterns
+- **Exception: egg-bin uses Mocha** - this package uses Mocha for CLI testing; all other packages (including cookies) use Vitest📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| #### Linting and Type Checking Strategy | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - **All packages must include TypeScript type checking** - Use `tsc --noEmit` in `typecheck` script | ||||||||||||||||||||||||||||||||
| - **All packages use oxlint for linting** - No ESLint configurations should be present | ||||||||||||||||||||||||||||||||
| - Use `oxlint --type-aware` for enhanced TypeScript checking | ||||||||||||||||||||||||||||||||
| - oxlint automatically respects `.gitignore` patterns for file exclusion | ||||||||||||||||||||||||||||||||
| - Package-specific scripts: | ||||||||||||||||||||||||||||||||
| - `"typecheck": "tsc --noEmit"` - Pure TypeScript type checking | ||||||||||||||||||||||||||||||||
| - `"lint": "oxlint --type-aware"` - Linting with type awareness | ||||||||||||||||||||||||||||||||
| - Remove any `.eslintrc` or `.eslintrc.js` files when migrating packages | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+300
to
+310
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainGood: oxlint + tsc guidance. Ensure no ESLint leftovers. Recommend verifying no residual ESLint configs remain in migrated packages. Run: 🏁 Script executed: #!/bin/bash
# Find ESLint configs and ESLint dependencies
fd -H '(.eslintrc|.eslintrc.*|eslint.config.*)' .
rg -nP '"eslint[^"]*"\s*:' package.json
rg -nP '\beslint\b' pnpm-workspace.yamlLength of output: 219 Remove leftover ESLint configs and dependencies 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| #### Vitest Configuration | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - Each package should include a `vitest.config.ts` file for test configuration | ||||||||||||||||||||||||||||||||
|
|
@@ -345,11 +365,17 @@ Tool packages (like egg-bin) should be placed in the `tools/` directory: | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ### Linting and Formatting | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - **ESLint** - Used for code linting across all packages | ||||||||||||||||||||||||||||||||
| - **TypeScript Compiler (tsc)** - Type checking with `tsc --noEmit` | ||||||||||||||||||||||||||||||||
| - Ensures type safety without generating output files | ||||||||||||||||||||||||||||||||
| - Run `pnpm -r run typecheck` for all packages | ||||||||||||||||||||||||||||||||
| - **oxlint** - Fast, type-aware linter used across all packages | ||||||||||||||||||||||||||||||||
| - Provides additional linting rules beyond TypeScript checking | ||||||||||||||||||||||||||||||||
| - Significantly faster than ESLint with comparable rules | ||||||||||||||||||||||||||||||||
| - Uses `--type-aware` flag for enhanced TypeScript analysis | ||||||||||||||||||||||||||||||||
| - **Prettier** - Code formatting (primarily for documentation) | ||||||||||||||||||||||||||||||||
| - Run `pnpm lint` to check code quality | ||||||||||||||||||||||||||||||||
| - Run `pnpm lint` to check code quality with oxlint | ||||||||||||||||||||||||||||||||
| - Run `pnpm lint:fix` to auto-fix linting issues | ||||||||||||||||||||||||||||||||
| - Each package has its own `.eslintrc.js` extending from root configuration | ||||||||||||||||||||||||||||||||
| - Each package uses oxlint which automatically respects `.gitignore` patterns | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ### TypeScript Best Practices | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -477,11 +503,14 @@ pnpm install | |||||||||||||||||||||||||||||||
| # Clean all build artifacts | ||||||||||||||||||||||||||||||||
| pnpm -r run clean | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check TypeScript types across all packages | ||||||||||||||||||||||||||||||||
| pnpm -r run typecheck | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check TypeScript configuration for specific package | ||||||||||||||||||||||||||||||||
| pnpm --filter=<package> run typecheck | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Rebuild TypeScript references | ||||||||||||||||||||||||||||||||
| pnpm run build:ts | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check TypeScript configuration | ||||||||||||||||||||||||||||||||
| pnpm --filter=<package> run tsc --noEmit | ||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #### Test Failures | ||||||||||||||||||||||||||||||||
|
|
@@ -524,6 +553,21 @@ NODE_OPTIONS='--inspect-brk' pnpm --filter=egg run test | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ## Migration Guide | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ### Migrating from ESLint to oxlint | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| 1. Remove ESLint dependencies from package.json: | ||||||||||||||||||||||||||||||||
| - Remove `eslint`, `eslint-config-egg`, and any ESLint plugins | ||||||||||||||||||||||||||||||||
| - Add `"oxlint": "catalog:"` to devDependencies | ||||||||||||||||||||||||||||||||
| 2. Delete `.eslintrc`, `.eslintrc.js`, or `.eslintrc.json` files | ||||||||||||||||||||||||||||||||
| 3. Update scripts in package.json: | ||||||||||||||||||||||||||||||||
| - Add `"typecheck": "tsc --noEmit"` for TypeScript type checking | ||||||||||||||||||||||||||||||||
| - Change `"lint": "eslint ..."` to `"lint": "oxlint --type-aware"` | ||||||||||||||||||||||||||||||||
| - Add `"lint:fix": "npm run lint -- --fix"` | ||||||||||||||||||||||||||||||||
| 4. Ensure both type checking and linting are run: | ||||||||||||||||||||||||||||||||
| - Use `tsc --noEmit` for pure TypeScript type checking | ||||||||||||||||||||||||||||||||
| - Use `oxlint --type-aware` for additional linting rules | ||||||||||||||||||||||||||||||||
| 5. Run `pnpm install` to update dependencies | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ### Migrating from Egg v2 to v3 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| 1. Update Node.js to v14+ (v18+ recommended) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| node_modules | ||
| coverage | ||
| test/ts/report | ||
| package-lock.json | ||
| .tshy* | ||
| .eslintcache | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| dist | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix test runner mention for cookies (uses Vitest, not Mocha).
Docs say cookies tests use Mocha, but the new tests import from vitest. Update to Vitest to avoid confusion.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents