dev-booster 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/.devbooster/MANIFEST.md +34 -1
- package/template/.devbooster/boosters/advisor.md +5 -0
- package/template/.devbooster/boosters/audit.md +20 -0
- package/template/.devbooster/boosters/auto-triage.md +5 -0
- package/template/.devbooster/boosters/backend.md +12 -0
- package/template/.devbooster/boosters/builder.md +5 -0
- package/template/.devbooster/boosters/code-audit.md +19 -0
- package/template/.devbooster/boosters/coder.md +5 -0
- package/template/.devbooster/boosters/create.md +5 -0
- package/template/.devbooster/boosters/debug.md +19 -0
- package/template/.devbooster/boosters/deploy.md +12 -0
- package/template/.devbooster/boosters/discovery.md +5 -0
- package/template/.devbooster/boosters/frontend.md +12 -0
- package/template/.devbooster/boosters/implementation.md +5 -0
- package/template/.devbooster/boosters/investigation.md +5 -0
- package/template/.devbooster/boosters/performance.md +12 -0
- package/template/.devbooster/boosters/planning.md +5 -0
- package/template/.devbooster/boosters/refactor.md +12 -0
- package/template/.devbooster/boosters/review.md +12 -0
- package/template/.devbooster/boosters/security.md +14 -0
- package/template/.devbooster/boosters/smart-task.md +27 -16
- package/template/.devbooster/boosters/stack-refresh.md +20 -0
- package/template/.devbooster/boosters/testing.md +12 -0
- package/template/.devbooster/hub/knowledge/angular-patterns.md +185 -0
- package/template/.devbooster/hub/knowledge/dependency-guide.md +175 -0
- package/template/.devbooster/hub/knowledge/eslint-migration.md +206 -0
- package/template/.devbooster/hub/knowledge/index.md +91 -0
- package/template/.devbooster/hub/knowledge/migration-guides.md +137 -0
- package/template/.devbooster/hub/knowledge/monorepo-patterns.md +121 -0
- package/template/.devbooster/hub/knowledge/nestjs-patterns.md +185 -0
- package/template/.devbooster/hub/knowledge/nextjs-pitfalls.md +226 -0
- package/template/.devbooster/hub/knowledge/nodejs-patterns.md +148 -0
- package/template/.devbooster/hub/knowledge/package-manager-patterns.md +143 -0
- package/template/.devbooster/hub/knowledge/prisma-postgresql-patterns.md +188 -0
- package/template/.devbooster/hub/knowledge/react-patterns.md +500 -0
- package/template/.devbooster/hub/knowledge/tailwind-shadcn-patterns.md +146 -0
- package/template/.devbooster/hub/knowledge/tanstack-patterns.md +278 -0
- package/template/.devbooster/hub/knowledge/testing-patterns.md +164 -0
- package/template/.devbooster/hub/knowledge/trpc-patterns.md +212 -0
- package/template/.devbooster/hub/knowledge/typescript-patterns.md +219 -0
- package/template/.devbooster/hub/knowledge/upgrade-fallout.md +154 -0
- package/template/.devbooster/hub/knowledge/vite-patterns.md +177 -0
- package/template/.devbooster/rules/GUIDE.md +24 -0
- package/template/.devbooster/rules/PROTOCOL.md +3 -2
- package/template/.devbooster/rules/TRIGGERS.md +14 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# 🚚 Migration Guides
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Migration guides for specific libraries with breaking changes observed in real projects
|
|
4
|
+
> **Primary official sources:** [react-to-print repository](https://github.com/MatthewHerbst/react-to-print) · [React documentation](https://react.dev/) · [Radix UI documentation](https://www.radix-ui.com/) · [shadcn/ui documentation](https://ui.shadcn.com/docs)
|
|
5
|
+
|
|
6
|
+
## Project Convention Decision Rule
|
|
7
|
+
|
|
8
|
+
Before applying this guidance, verify the installed versions, local rules, existing abstractions, configuration, and tests. Preserve a valid established project convention; do not replace it only because another documented approach is also valid. Use official sources to verify API behavior, compatibility, constraints, and migrations. Recommend a change only when the developer requests it or evidence shows the current approach is incompatible, unsafe, deprecated, broken, or responsible for a verified issue.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Index
|
|
13
|
+
|
|
14
|
+
1. [react-to-print v2 → v3](#react-to-print-v2--v3)
|
|
15
|
+
2. [Formik + React 19 — HTML Form Types](#formik--react-19)
|
|
16
|
+
3. [Radix UI — Meta-package vs Individual Packages](#radix-ui-meta-package)
|
|
17
|
+
4. [shadcn/ui — Missing Dependencies](#shadcn-ui-missing-dependencies)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## react-to-print v2 → v3
|
|
22
|
+
|
|
23
|
+
### Problem
|
|
24
|
+
The `useReactToPrint` API changed significantly from v2 to v3. The `content` option was renamed to `contentRef` and now receives a ref object rather than a callback.
|
|
25
|
+
|
|
26
|
+
### Code (symptom)
|
|
27
|
+
```tsx
|
|
28
|
+
// BEFORE (v2)
|
|
29
|
+
useReactToPrint({ content: () => ref.current })
|
|
30
|
+
|
|
31
|
+
// AFTER (v3)
|
|
32
|
+
useReactToPrint({ contentRef: ref })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Expected type error
|
|
36
|
+
```
|
|
37
|
+
'content' does not exist in type 'UseReactToPrintOptions'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Fix
|
|
41
|
+
```tsx
|
|
42
|
+
const contentRef = useRef<HTMLDivElement>(null)
|
|
43
|
+
const print = useReactToPrint({ contentRef })
|
|
44
|
+
|
|
45
|
+
// Attach contentRef to the element to print, then call print from the print trigger.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Scope
|
|
49
|
+
The documented v3 breaking change is the rename and type change from `content` to `contentRef`. Review the v3 migration notes for its other breaking changes.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Formik + React 19
|
|
54
|
+
|
|
55
|
+
### Problem
|
|
56
|
+
React 19 form type errors can result from misaligned `react`, `react-dom`, and `@types/react` versions, including duplicate React type packages. Do not assume that a Formik version alone is the cause.
|
|
57
|
+
|
|
58
|
+
### Type error
|
|
59
|
+
```
|
|
60
|
+
Type '{ children: Element; }' is missing the following properties from type
|
|
61
|
+
'Pick<DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, ...>':
|
|
62
|
+
placeholder, onPointerEnterCapture, onPointerLeaveCapture
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Check first
|
|
66
|
+
1. Align the installed `react`, `react-dom`, `@types/react`, and `@types/react-dom` versions.
|
|
67
|
+
2. Inspect the lockfile and dependency tree for duplicate or incompatible React type packages.
|
|
68
|
+
3. Re-run type checking before changing form markup.
|
|
69
|
+
|
|
70
|
+
### Native form fallback
|
|
71
|
+
Use a native `<form>` only when type alignment does not resolve the issue, and preserve the semantics provided by Formik's `<Form>`:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<form
|
|
75
|
+
onReset={formik.handleReset}
|
|
76
|
+
onSubmit={formik.handleSubmit}
|
|
77
|
+
{...formProps}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</form>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Preserve any required forwarded props and refs. `noValidate` is a standard HTML form attribute and can be passed directly when needed.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Radix UI Meta-package
|
|
88
|
+
|
|
89
|
+
### Problem
|
|
90
|
+
A component can import either the unified `radix-ui` package or an individual `@radix-ui/react-*` package. The required installation depends on the actual import specifier in the component source.
|
|
91
|
+
|
|
92
|
+
### Symptom
|
|
93
|
+
```
|
|
94
|
+
Cannot find module 'radix-ui'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Choose the matching package
|
|
98
|
+
```bash
|
|
99
|
+
# Source imports from "radix-ui"
|
|
100
|
+
yarn add radix-ui
|
|
101
|
+
|
|
102
|
+
# Source imports from "@radix-ui/react-dialog"
|
|
103
|
+
yarn add @radix-ui/react-dialog
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Migration
|
|
107
|
+
For existing shadcn/ui components that use individual Radix imports, use the documented Radix migration to rewrite imports before removing individual packages. Do not add the unified package solely because another component uses a different import style.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## shadcn/ui — Missing Dependencies
|
|
112
|
+
|
|
113
|
+
### Problem
|
|
114
|
+
The standard shadcn CLI installs the dependencies required by the component it adds. Manually copied components, custom registries, or incomplete installs may still reference packages that are absent.
|
|
115
|
+
|
|
116
|
+
### Component-specific patterns
|
|
117
|
+
- `class-variance-authority` — only when the component calls `cva()`
|
|
118
|
+
- `tailwind-merge` — only when the project utility imports it
|
|
119
|
+
- `lucide-react` — only when the component imports Lucide icons
|
|
120
|
+
- `tailwindcss-animate` — legacy Tailwind v3 animation plugin
|
|
121
|
+
- `tw-animate-css` — Tailwind v4 animation package
|
|
122
|
+
|
|
123
|
+
### Fix
|
|
124
|
+
Inspect the component imports and registry metadata, then install only the missing direct dependency. For animations, match the package to the Tailwind version:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Tailwind v3
|
|
128
|
+
yarn add -D tailwindcss-animate
|
|
129
|
+
|
|
130
|
+
# Tailwind v4
|
|
131
|
+
yarn add -D tw-animate-css
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Missing dependency symptom
|
|
135
|
+
```
|
|
136
|
+
Cannot find module 'class-variance-authority'
|
|
137
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Monorepo Patterns
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Keep workspace packages, dependency resolution, shared configuration, and task execution reproducible in JavaScript/TypeScript monorepos.
|
|
4
|
+
> **Primary official sources:** [npm workspaces](https://docs.npmjs.com/cli/v11/using-npm/workspaces) · [Yarn workspaces](https://yarnpkg.com/features/workspaces) · [pnpm workspaces](https://pnpm.io/workspaces) · [Turborepo documentation](https://turborepo.com/docs) · [Nx documentation](https://nx.dev/)
|
|
5
|
+
|
|
6
|
+
## Project Convention Decision Rule
|
|
7
|
+
|
|
8
|
+
Before applying this guidance, verify the installed versions, local rules, existing abstractions, configuration, lockfile, workspace layout, and tests. Preserve a valid established project convention; do not replace it only because another documented approach is also valid. Use official sources to verify API behavior, compatibility, constraints, and migrations. Recommend a change only when the developer requests it or evidence shows the current approach is incompatible, unsafe, deprecated, broken, or responsible for a verified issue.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
1. [Workspace Package Boundaries](#workspace-package-boundaries)
|
|
15
|
+
2. [Declared Dependencies and Phantom Dependencies](#declared-dependencies-and-phantom-dependencies)
|
|
16
|
+
3. [Shared Configuration Resolution](#shared-configuration-resolution)
|
|
17
|
+
4. [Task Runner Cache Hygiene](#task-runner-cache-hygiene)
|
|
18
|
+
5. [Workspace-Aware Commands](#workspace-aware-commands)
|
|
19
|
+
6. [Lockfile and Root Toolchain Consistency](#lockfile-and-root-toolchain-consistency)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Workspace Package Boundaries
|
|
24
|
+
|
|
25
|
+
### Symptom
|
|
26
|
+
A package imports source files from another package's internals, builds only by accident, or cannot be independently published, tested, or consumed.
|
|
27
|
+
|
|
28
|
+
### Verify first
|
|
29
|
+
Check each workspace's `package.json`: `name`, `private`, `exports` (when published), build output, and declared dependencies. Verify that consumers import the package's public name rather than a relative path into its source tree. Workspace discovery is manager-specific; see [npm workspaces](https://docs.npmjs.com/cli/v11/using-npm/workspaces), [Yarn workspaces](https://yarnpkg.com/features/workspaces), and [pnpm workspaces](https://pnpm.io/workspaces).
|
|
30
|
+
|
|
31
|
+
### Fix
|
|
32
|
+
- Give each independently consumed unit an explicit package boundary and public API.
|
|
33
|
+
- Import internal packages by package name, not by relative paths that bypass packaging and export rules.
|
|
34
|
+
- Mark packages not intended for publication as `private`.
|
|
35
|
+
- Keep generated output, package entry points, and export maps consistent with the files produced by the package build.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Declared Dependencies and Phantom Dependencies
|
|
40
|
+
|
|
41
|
+
### Symptom
|
|
42
|
+
A package builds locally but fails in isolation, after a clean install, or when consumed outside the repository.
|
|
43
|
+
|
|
44
|
+
### Problem
|
|
45
|
+
The package imports a dependency that is only available because another workspace or a hoisted install placed it nearby. This is a phantom dependency.
|
|
46
|
+
|
|
47
|
+
### Fix
|
|
48
|
+
- Declare every runtime, build-time, and type dependency in the package that directly imports it, using the appropriate dependency section.
|
|
49
|
+
- Declare internal workspace relationships explicitly and use the package manager's supported workspace protocol where applicable.
|
|
50
|
+
- Do not rely on hoisting layout, transitive dependencies, or root-level tooling to make an import resolve.
|
|
51
|
+
|
|
52
|
+
### Verify first
|
|
53
|
+
Install from a clean checkout and test/build the affected workspace directly. For publishable packages, validate the packed artifact in a clean temporary consumer. pnpm explains why workspace linking and protocol use are explicit in [workspace settings](https://pnpm.io/workspaces#workspace-protocol-workspace).
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Shared Configuration Resolution
|
|
58
|
+
|
|
59
|
+
### Symptom
|
|
60
|
+
A linter, TypeScript compiler, test runner, or bundler behaves differently when launched from the root versus a workspace.
|
|
61
|
+
|
|
62
|
+
### Verify first
|
|
63
|
+
Determine which config file is found, the current working directory, and whether plugins/presets resolve from the root, the workspace, or the config package. Check the tool's own configuration-resolution documentation before moving files or adding duplicate dependencies.
|
|
64
|
+
|
|
65
|
+
### Fix
|
|
66
|
+
- Make shared configuration a versioned workspace package or a clearly owned root configuration, according to the consuming tool's resolution model.
|
|
67
|
+
- Reference shared config through supported package/config mechanisms rather than brittle relative paths when the tool supports it.
|
|
68
|
+
- Put plugins and parsers where the resolver expects them; do not depend on incidental hoisting.
|
|
69
|
+
- Run configuration-sensitive commands from the same scope in local development and CI.
|
|
70
|
+
|
|
71
|
+
For TypeScript project structure and references, use the [TypeScript project references handbook](https://www.typescriptlang.org/docs/handbook/project-references.html).
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Task Runner Cache Hygiene
|
|
76
|
+
|
|
77
|
+
### Symptom
|
|
78
|
+
A cached task returns stale output, misses a required rebuild after configuration changes, or appears successful without producing expected artifacts.
|
|
79
|
+
|
|
80
|
+
### Verify first
|
|
81
|
+
For the affected task, list its declared inputs, environment variables, dependency tasks, outputs, working directory, and cache mode. Turborepo documents task inputs/outputs and caching in [Turborepo caching](https://turborepo.com/docs/crafting-your-repository/caching); Nx documents inputs and task caching in [Nx cache inputs](https://nx.dev/concepts/how-caching-works#inputs).
|
|
82
|
+
|
|
83
|
+
### Fix
|
|
84
|
+
- Declare outputs precisely so restored cache artifacts match what downstream tasks consume.
|
|
85
|
+
- Include relevant source, lockfile, configuration, generated-schema, and environment inputs in the cache definition.
|
|
86
|
+
- Exclude secrets from cache keys and outputs; use non-secret version markers when configuration must affect caching.
|
|
87
|
+
- Make task dependencies explicit rather than relying on execution order or existing files.
|
|
88
|
+
- Clear or bypass cache only to diagnose incorrect cache inputs; repair the task definition before re-enabling it.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Workspace-Aware Commands
|
|
93
|
+
|
|
94
|
+
### Symptom
|
|
95
|
+
A command runs in every package, runs only at the root, resolves the wrong binary, or changes dependencies in an unintended workspace.
|
|
96
|
+
|
|
97
|
+
### Verify first
|
|
98
|
+
Use the package manager's workspace-listing capability and confirm the target package name. Review the exact command's workspace flags rather than assuming equivalent syntax across managers. npm provides [workspace command guidance](https://docs.npmjs.com/cli/v11/using-npm/workspaces#running-commands-in-the-context-of-workspaces).
|
|
99
|
+
|
|
100
|
+
### Fix
|
|
101
|
+
- Prefer explicit workspace/package selectors for focused install, run, test, and build commands.
|
|
102
|
+
- Use recursive/all-workspace execution only when the task is designed to be independent or ordered by declared dependencies.
|
|
103
|
+
- Keep root scripts as orchestration entry points and package scripts as package-local behavior.
|
|
104
|
+
- In CI, log the selected workspace and command to make scope errors visible.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Lockfile and Root Toolchain Consistency
|
|
109
|
+
|
|
110
|
+
### Problem
|
|
111
|
+
Different packages or CI jobs use different package-manager versions, lockfile policies, Node versions, or root tool versions, producing incompatible dependency trees and task results.
|
|
112
|
+
|
|
113
|
+
### Fix
|
|
114
|
+
- Maintain a single root lockfile and use the repository's declared package manager everywhere.
|
|
115
|
+
- Pin or otherwise declare the package-manager version with the repository-supported mechanism; Corepack recognizes `packageManager` metadata. See [Node.js Corepack](https://nodejs.org/docs/latest/api/corepack.html).
|
|
116
|
+
- Align Node selection across local development, CI, and containers with the root `engines` policy.
|
|
117
|
+
- Put monorepo-wide task-runner and shared-tool configuration under clear root ownership.
|
|
118
|
+
- Validate CI with a non-mutating install mode, then execute workspace-aware checks from a clean checkout.
|
|
119
|
+
|
|
120
|
+
### Verify first
|
|
121
|
+
Confirm that a clean clone has one expected lockfile, uses the intended manager/runtime, and completes a focused package build followed by the repository's dependency-aware build. Any lockfile modification during validation is a reproducibility failure to investigate, not a change to commit automatically.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# NestJS Patterns
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Practical patterns for dependable NestJS application boundaries.
|
|
4
|
+
> **Primary official sources:** [Nest modules](https://docs.nestjs.com/modules) · [Nest providers](https://docs.nestjs.com/providers) · [Nest validation](https://docs.nestjs.com/techniques/validation) · [Nest authentication](https://docs.nestjs.com/security/authentication) · [Nest exception filters](https://docs.nestjs.com/exception-filters) · [Nest configuration](https://docs.nestjs.com/techniques/configuration)
|
|
5
|
+
|
|
6
|
+
## Project Convention Decision Rule
|
|
7
|
+
|
|
8
|
+
Before applying this guidance, verify the installed versions, local rules, existing abstractions, configuration, and tests. Preserve a valid established project convention; do not replace it only because another documented approach is also valid. Use official sources to verify API behavior, compatibility, constraints, and migrations. Recommend a change only when the developer requests it or evidence shows the current approach is incompatible, unsafe, deprecated, broken, or responsible for a verified issue.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
1. [Module and Provider Visibility](#module-and-provider-visibility)
|
|
15
|
+
2. [Circular Dependencies and forwardRef](#circular-dependencies-and-forwardref)
|
|
16
|
+
3. [Validation Pipes and DTO Transformation](#validation-pipes-and-dto-transformation)
|
|
17
|
+
4. [Authentication Guards and Execution Context](#authentication-guards-and-execution-context)
|
|
18
|
+
5. [Global Exception Filters and Error Contracts](#global-exception-filters-and-error-contracts)
|
|
19
|
+
6. [Configuration and Environment Validation](#configuration-and-environment-validation)
|
|
20
|
+
7. [Request-Scoped Provider Caveats](#request-scoped-provider-caveats)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Module and Provider Visibility
|
|
25
|
+
|
|
26
|
+
### Symptom
|
|
27
|
+
Nest cannot resolve a dependency even though a provider exists elsewhere, or a feature accidentally depends on an implementation that should be private.
|
|
28
|
+
|
|
29
|
+
### Verify first
|
|
30
|
+
- Read the consuming module's `imports`, the providing module's `providers`, and its `exports`.
|
|
31
|
+
- Confirm injection tokens match exactly, especially for custom providers and interfaces (which do not exist at runtime).
|
|
32
|
+
- Check whether the module was registered in the application graph rather than merely imported by a TypeScript file.
|
|
33
|
+
|
|
34
|
+
### Fix
|
|
35
|
+
- Keep a provider private by default. Export only the provider token or service intended as the module's public API.
|
|
36
|
+
- Import the module that exports the provider; adding the provider directly to a second module creates a separate instance and may hide the ownership problem.
|
|
37
|
+
- Use explicit tokens for abstractions and bind them in one composition location.
|
|
38
|
+
|
|
39
|
+
### Verify
|
|
40
|
+
- Bootstrap a test module using the same imports as the production consumer.
|
|
41
|
+
- Confirm stateful providers have the intended instance lifetime.
|
|
42
|
+
|
|
43
|
+
*Sources: [Nest modules](https://docs.nestjs.com/modules), [Nest custom providers](https://docs.nestjs.com/fundamentals/custom-providers).*
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Circular Dependencies and forwardRef
|
|
48
|
+
|
|
49
|
+
### Problem
|
|
50
|
+
Two providers or modules require each other, leading to unresolved dependencies, undefined imports, or tightly coupled business behavior.
|
|
51
|
+
|
|
52
|
+
### Verify first
|
|
53
|
+
- Distinguish a Nest dependency cycle from a TypeScript import cycle; inspect the dependency direction and runtime tokens.
|
|
54
|
+
- Identify whether the services are coordinating two responsibilities that should be extracted behind a third service, event, or interface.
|
|
55
|
+
|
|
56
|
+
### Fix
|
|
57
|
+
- Prefer removing the cycle by extracting the shared orchestration or introducing a narrower dependency direction.
|
|
58
|
+
- Use `forwardRef(() => Dependency)` only when the cycle is intentional, limited, and understood. Apply it at the matching module/provider injection point.
|
|
59
|
+
- Do not rely on constructor order between circular providers; Nest documents that instantiation order is indeterminate.
|
|
60
|
+
|
|
61
|
+
### Verify
|
|
62
|
+
- Bootstrap the affected module and exercise both paths through the cycle.
|
|
63
|
+
- Check that unit tests can replace each side independently; difficult substitution is a sign that the boundary remains too coupled.
|
|
64
|
+
|
|
65
|
+
*Source: [Nest circular dependency fundamentals](https://docs.nestjs.com/fundamentals/circular-dependency).*
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Validation Pipes and DTO Transformation
|
|
70
|
+
|
|
71
|
+
### Symptom
|
|
72
|
+
Requests accept unexpected fields, route/query values retain string types, nested objects are not validated, or validation behavior differs between endpoints.
|
|
73
|
+
|
|
74
|
+
### Verify first
|
|
75
|
+
- Identify the transport and source: body, query, params, headers, or a message payload.
|
|
76
|
+
- Confirm the runtime DTO is a concrete class with `class-validator` decorators; TypeScript types/interfaces alone cannot be reflected for validation.
|
|
77
|
+
- Test representative invalid input, unknown fields, nested DTOs, and coercion edge cases such as empty strings and dates.
|
|
78
|
+
|
|
79
|
+
### Fix
|
|
80
|
+
- Apply a global `ValidationPipe` only after choosing an API policy for `whitelist`, `forbidNonWhitelisted`, and transformation.
|
|
81
|
+
- Use DTO classes for input contracts. For nested values, provide type metadata such as `@Type(() => ChildDto)` where required by `class-transformer`.
|
|
82
|
+
- Enable `transform` when handlers need converted primitive route/query values, but declare expected types and test coercion. Transformation is not a substitute for semantic validation.
|
|
83
|
+
- Keep validation rules at the boundary; preserve domain-specific invariants in application/domain logic as well.
|
|
84
|
+
|
|
85
|
+
### Verify
|
|
86
|
+
- Add end-to-end tests asserting the status code and error body for malformed input.
|
|
87
|
+
- Confirm successful inputs arrive at the handler with the expected runtime types.
|
|
88
|
+
|
|
89
|
+
*Sources: [Nest validation](https://docs.nestjs.com/techniques/validation), [class-validator](https://github.com/typestack/class-validator), [class-transformer](https://github.com/typestack/class-transformer).*
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Authentication Guards and Execution Context
|
|
94
|
+
|
|
95
|
+
### Problem
|
|
96
|
+
Authentication works for one transport but is bypassed or reads the wrong request object for another; authorization logic becomes duplicated across controllers.
|
|
97
|
+
|
|
98
|
+
### Verify first
|
|
99
|
+
- Identify the active transport and context: HTTP, GraphQL, WebSocket, or RPC. `ExecutionContext` exposes different arguments for each.
|
|
100
|
+
- Separate authentication (establishing identity) from authorization (deciding access).
|
|
101
|
+
- Define which routes are public and how metadata inheritance at controller and handler levels should work.
|
|
102
|
+
|
|
103
|
+
### Fix
|
|
104
|
+
- Put identity extraction and verification in a guard or strategy appropriate to the transport.
|
|
105
|
+
- Use `ExecutionContext` APIs rather than assuming `switchToHttp().getRequest()` is valid everywhere.
|
|
106
|
+
- Express authorization requirements as explicit metadata and enforce them in a guard. Keep resource-level checks close to the use case when they require loading the resource.
|
|
107
|
+
- Attach only the normalized identity/claims needed downstream; do not treat unverified decoded token data as authenticated identity.
|
|
108
|
+
|
|
109
|
+
### Verify
|
|
110
|
+
- Test absent, malformed, expired, and valid credentials plus forbidden-but-authenticated access.
|
|
111
|
+
- Exercise every supported transport and both controller- and method-level metadata paths.
|
|
112
|
+
|
|
113
|
+
*Sources: [Nest guards](https://docs.nestjs.com/guards), [Nest execution context](https://docs.nestjs.com/fundamentals/execution-context), [Nest authorization](https://docs.nestjs.com/security/authorization).*
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Global Exception Filters and Error Contracts
|
|
118
|
+
|
|
119
|
+
### Symptom
|
|
120
|
+
Clients receive inconsistent error bodies, internal details leak, or exceptions from different layers map to arbitrary status codes.
|
|
121
|
+
|
|
122
|
+
### Verify first
|
|
123
|
+
- Define the public error contract: status, stable machine-readable code, safe message, field errors where applicable, and correlation/request identifier policy.
|
|
124
|
+
- Identify adapter behavior and existing global filters/interceptors. A filter that writes an HTTP response is transport-specific.
|
|
125
|
+
- Classify expected domain/application errors separately from programming errors and infrastructure failures.
|
|
126
|
+
|
|
127
|
+
### Fix
|
|
128
|
+
- Use Nest's built-in HTTP exceptions for straightforward transport errors.
|
|
129
|
+
- Add a global filter to translate known application errors into one documented public contract, log unexpected errors with safe context, and avoid exposing stack traces or secrets.
|
|
130
|
+
- Preserve the original cause for observability when wrapping errors, but do not return it to clients.
|
|
131
|
+
- Avoid catching every exception inside controllers; doing so fragments error policy and can hide defects.
|
|
132
|
+
|
|
133
|
+
### Verify
|
|
134
|
+
- Test validation, not-found, forbidden, conflict, and unexpected-error responses.
|
|
135
|
+
- Ensure production responses do not contain stack traces, tokens, database errors, or internal file paths.
|
|
136
|
+
|
|
137
|
+
*Sources: [Nest exception filters](https://docs.nestjs.com/exception-filters), [Nest validation errors](https://docs.nestjs.com/techniques/validation#disable-detailed-errors).*
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Configuration and Environment Validation
|
|
142
|
+
|
|
143
|
+
### Problem
|
|
144
|
+
The application starts with missing or malformed configuration, discovers it only under traffic, or reads environment variables throughout business code.
|
|
145
|
+
|
|
146
|
+
### Verify first
|
|
147
|
+
- Inventory required settings, optional settings with defaults, secret sources, and environment-specific constraints.
|
|
148
|
+
- Confirm how configuration is loaded in each runtime; `.env` files are not automatically a production secret-management strategy.
|
|
149
|
+
- Decide which invalid settings must fail startup versus which can be disabled safely.
|
|
150
|
+
|
|
151
|
+
### Fix
|
|
152
|
+
- Centralize configuration with `@nestjs/config` and expose typed, focused configuration access to consumers.
|
|
153
|
+
- Validate required environment values during startup with a schema or custom validation function. Validate format and range, not only presence.
|
|
154
|
+
- Keep secrets out of logs, errors, repository files, and client-side configuration.
|
|
155
|
+
- Prefer injecting configuration over reading `process.env` across arbitrary services, which makes tests and runtime behavior harder to control.
|
|
156
|
+
|
|
157
|
+
### Verify
|
|
158
|
+
- Start the application with missing, malformed, and valid configurations.
|
|
159
|
+
- Confirm failures identify the setting safely without printing its secret value.
|
|
160
|
+
|
|
161
|
+
*Source: [Nest configuration](https://docs.nestjs.com/techniques/configuration).*
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Request-Scoped Provider Caveats
|
|
166
|
+
|
|
167
|
+
### Problem
|
|
168
|
+
A request-scoped dependency unexpectedly increases latency/memory use, causes broad scope propagation, or behaves inconsistently in non-HTTP code.
|
|
169
|
+
|
|
170
|
+
### Verify first
|
|
171
|
+
- Confirm that mutable per-request state cannot instead be passed as an explicit argument or carried by a transport context.
|
|
172
|
+
- Inspect the dependency tree: a request-scoped provider can make dependent providers request-scoped.
|
|
173
|
+
- Measure the allocation and latency impact under expected concurrency, and identify whether the code also runs in jobs, events, or WebSockets.
|
|
174
|
+
|
|
175
|
+
### Fix
|
|
176
|
+
- Keep services singleton-scoped by default; make dependencies request-scoped only for a concrete per-request lifecycle requirement.
|
|
177
|
+
- Pass request-specific values explicitly when practical. This preserves singleton reuse and makes behavior easier to test.
|
|
178
|
+
- For non-singleton scenarios, use Nest's documented context/request-provider mechanisms rather than assuming an HTTP request exists.
|
|
179
|
+
- Do not use request scope as a substitute for authorization isolation or transaction management.
|
|
180
|
+
|
|
181
|
+
### Verify
|
|
182
|
+
- Load-test the affected route and check instance lifecycle behavior.
|
|
183
|
+
- Exercise background and non-HTTP invocation paths if the provider is shared with them.
|
|
184
|
+
|
|
185
|
+
*Sources: [Nest injection scopes](https://docs.nestjs.com/fundamentals/injection-scopes), [Nest request lifecycle](https://docs.nestjs.com/faq/request-lifecycle).*
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# ▲ Next.js Pitfalls
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Common pitfalls and issues in Next.js 16+ projects
|
|
4
|
+
> **Primary official sources:** [Next.js TypeScript configuration](https://nextjs.org/docs/app/api-reference/config/next-config-js/typescript) · [Next.js 16 upgrade guide](https://nextjs.org/docs/app/guides/upgrading/version-16) · [Next.js Image configuration](https://nextjs.org/docs/app/api-reference/components/image#configuration-options)
|
|
5
|
+
|
|
6
|
+
## Project Convention Decision Rule
|
|
7
|
+
|
|
8
|
+
Before applying this guidance, verify the installed versions, router and rendering model, local rules, existing abstractions, configuration, and tests. Preserve a valid established project convention; do not replace it only because another documented approach is also valid. Use official sources to verify API behavior, compatibility, constraints, and migrations. Recommend a change only when the developer requests it or evidence shows the current approach is incompatible, unsafe, deprecated, broken, or responsible for a verified issue.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
1. [Framework-level Masking — ignoreBuildErrors](#framework-level-masking)
|
|
15
|
+
2. [Legacy Build-time Lint Masking — Next.js 15 and Earlier](#legacy-build-time-lint-masking)
|
|
16
|
+
3. [Broken Lint Script After a Next.js 16 Upgrade](#broken-lint-script-after-a-nextjs-16-upgrade)
|
|
17
|
+
4. [Invalid next.config Properties](#invalid-nextconfig-properties)
|
|
18
|
+
5. [TSConfig Changes Triggered by Next.js](#tsconfig-changes-triggered-by-nextjs)
|
|
19
|
+
6. [New Lint Findings After an Upgrade](#new-lint-findings-after-an-upgrade)
|
|
20
|
+
7. [Warnings Need Triage](#warnings-need-triage)
|
|
21
|
+
8. [Choose Server and Client Boundaries Deliberately](#choose-server-and-client-boundaries-deliberately)
|
|
22
|
+
9. [Use Route Loading and Error Boundaries Before Rebuilding Them](#use-route-loading-and-error-boundaries-before-rebuilding-them)
|
|
23
|
+
10. [Avoid Hydration Mismatches by Preserving Initial Output](#avoid-hydration-mismatches-by-preserving-initial-output)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Framework-level Masking
|
|
28
|
+
|
|
29
|
+
### Problem
|
|
30
|
+
The `typescript.ignoreBuildErrors: true` option in `next.config.*` skips Next.js's built-in TypeScript type-checking step during production builds. It does not run the check and suppress its errors, so it can allow type errors to reach deployment.
|
|
31
|
+
|
|
32
|
+
*Source: [Next.js TypeScript configuration](https://nextjs.org/docs/app/api-reference/config/next-config-js/typescript)*
|
|
33
|
+
|
|
34
|
+
> The official Next.js documentation warns: "If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous."
|
|
35
|
+
|
|
36
|
+
### Code (symptom)
|
|
37
|
+
```js
|
|
38
|
+
// next.config.js — bypasses Next.js type checking
|
|
39
|
+
typescript: { ignoreBuildErrors: true }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Fix
|
|
43
|
+
Remove the flag; `false` is the default:
|
|
44
|
+
```js
|
|
45
|
+
module.exports = {
|
|
46
|
+
typescript: {
|
|
47
|
+
ignoreBuildErrors: false,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If a project temporarily keeps the flag, run an explicit type check such as `tsc --noEmit` in CI or the deployment pipeline.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Legacy Build-time Lint Masking
|
|
57
|
+
|
|
58
|
+
**Evidence:** Field-validated in a real audit.
|
|
59
|
+
|
|
60
|
+
### Applicability
|
|
61
|
+
Next.js 15 and earlier. The `eslint.ignoreDuringBuilds` option was supported in these versions and allowed production builds to complete with ESLint errors.
|
|
62
|
+
|
|
63
|
+
*Source: [Next.js 15 ESLint configuration](https://nextjs.org/docs/15/app/api-reference/config/next-config-js/eslint)*
|
|
64
|
+
|
|
65
|
+
### Code (symptom)
|
|
66
|
+
```js
|
|
67
|
+
module.exports = {
|
|
68
|
+
eslint: {
|
|
69
|
+
ignoreDuringBuilds: true,
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Why it matters
|
|
75
|
+
This setting bypasses Next.js's built-in build-time lint failure. It may have been introduced as a temporary deployment workaround, but it hides lint failures unless ESLint runs independently in CI or another verified workflow.
|
|
76
|
+
|
|
77
|
+
### Version boundary
|
|
78
|
+
Next.js 16 removed `next lint`, build-time linting, and the `eslint` key in `next.config.*`. For Next.js 16+, remove this legacy config and run ESLint directly as a separate validation command.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Broken Lint Script After a Next.js 16 Upgrade
|
|
83
|
+
|
|
84
|
+
### Problem
|
|
85
|
+
Starting with Next.js 16, `next lint` is removed. `next build` no longer runs linting, and the `eslint` key in `next.config.*` is removed.
|
|
86
|
+
|
|
87
|
+
Invoking the removed command can produce an error such as:
|
|
88
|
+
```
|
|
89
|
+
Invalid project directory provided, no such directory: .../lint
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Fix
|
|
93
|
+
Run ESLint directly and make linting a separate CI or deployment step:
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"scripts": {
|
|
97
|
+
"lint": "eslint ."
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For flat-config setup and migration details, see [ESLint Migration](./eslint-migration.md).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Invalid next.config Properties
|
|
107
|
+
|
|
108
|
+
### Problem
|
|
109
|
+
A property in an unsupported location in `next.config.*` can produce a configuration warning or be ignored. For example, `unoptimized` is not a top-level Next.js config option.
|
|
110
|
+
|
|
111
|
+
### Code (symptom)
|
|
112
|
+
```js
|
|
113
|
+
// Invalid location
|
|
114
|
+
module.exports = { unoptimized: true }
|
|
115
|
+
|
|
116
|
+
// Valid location
|
|
117
|
+
module.exports = { images: { unoptimized: true } }
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Fix
|
|
121
|
+
Use the documented `images.unoptimized` option:
|
|
122
|
+
```js
|
|
123
|
+
module.exports = {
|
|
124
|
+
images: {
|
|
125
|
+
unoptimized: true,
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## TSConfig Changes Triggered by Next.js
|
|
133
|
+
|
|
134
|
+
### Problem
|
|
135
|
+
When TypeScript is added to a project, `next dev` and `next build` can create or update `tsconfig.json` with recommended settings and generated-type includes.
|
|
136
|
+
|
|
137
|
+
### Handling
|
|
138
|
+
- Review the complete `tsconfig.json` diff and identify why each change was made.
|
|
139
|
+
- Keep required generated-type includes, such as `.next/types/**/*.ts`, when the project uses Next.js route-aware types.
|
|
140
|
+
- Validate compiler-option changes, including `moduleResolution`, against the project's Next.js and TypeScript versions before accepting or reverting them.
|
|
141
|
+
- Commit intentional configuration changes so they are visible in review.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## New Lint Findings After an Upgrade
|
|
146
|
+
|
|
147
|
+
### Problem
|
|
148
|
+
After migrating to ESLint flat config or updating Next.js, ESLint, or plugins, new rules or changed analysis can reveal existing issues or introduce upgrade-specific incompatibilities.
|
|
149
|
+
|
|
150
|
+
### Common examples
|
|
151
|
+
- A callback referenced before declaration
|
|
152
|
+
- Non-deterministic logic during render, such as `Math.random()` in a component body
|
|
153
|
+
- An unused import that was previously not reported
|
|
154
|
+
|
|
155
|
+
### Handling
|
|
156
|
+
1. Analyze each finding individually.
|
|
157
|
+
2. Classify it as a pre-existing issue now detected, a configuration change, or an upgrade regression.
|
|
158
|
+
3. Apply a specific fix or document a narrowly justified exception.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Warnings Need Triage
|
|
163
|
+
|
|
164
|
+
### Problem
|
|
165
|
+
A successful build can still emit warnings about configuration, deprecations, or behavior that affects production.
|
|
166
|
+
|
|
167
|
+
### Checklist
|
|
168
|
+
After a framework upgrade:
|
|
169
|
+
1. Run `next build` and capture the full output.
|
|
170
|
+
2. Review warnings as well as errors.
|
|
171
|
+
3. Determine the source, impact, and owner of each warning.
|
|
172
|
+
4. Fix the warning or document an accepted disposition according to the project's release policy.
|
|
173
|
+
|
|
174
|
+
### Rule of thumb
|
|
175
|
+
**A passing build with warnings requires triage; warnings are neither automatically deploy-blocking nor automatically acceptable.**
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Choose Server and Client Boundaries Deliberately
|
|
180
|
+
|
|
181
|
+
### Decision
|
|
182
|
+
In the App Router, components are Server Components by default. Add `'use client'` only when the component or one of its direct responsibilities requires client-side capabilities such as state, Effects, browser APIs, or event handlers.
|
|
183
|
+
|
|
184
|
+
### Verify first
|
|
185
|
+
- Identify the active router; do not apply App Router guidance to a Pages Router project.
|
|
186
|
+
- Keep the client boundary as narrow as the existing architecture permits.
|
|
187
|
+
- Inspect existing component boundaries and shared providers before moving a component to the client.
|
|
188
|
+
- Pass serializable props across the Server-to-Client boundary.
|
|
189
|
+
|
|
190
|
+
Do not convert a server-rendered subtree to a Client Component merely to solve a small interactive concern. Extract the interactive leaf when that preserves the project’s established composition pattern.
|
|
191
|
+
|
|
192
|
+
*Sources: [Next.js — Server and Client Components](https://nextjs.org/docs/app/getting-started/server-and-client-components) · [Next.js — use client](https://nextjs.org/docs/app/api-reference/directives/use-client)*
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Use Route Loading and Error Boundaries Before Rebuilding Them
|
|
197
|
+
|
|
198
|
+
### Decision
|
|
199
|
+
For App Router route segments, inspect existing `loading.*`, `error.*`, and shared layout conventions before adding component-local loading or error state. These files define framework-native boundaries for the segment and its descendants.
|
|
200
|
+
|
|
201
|
+
### Verify first
|
|
202
|
+
- Confirm whether the loading state is route-level, component-level, or owned by an existing client query abstraction.
|
|
203
|
+
- Preserve existing fallback, retry, error-reporting, and accessibility conventions.
|
|
204
|
+
- Do not use `loading.*` as a substitute for errors in a client-side mutation or interaction; use the project’s local feedback pattern there.
|
|
205
|
+
- Confirm the required error boundary shape for the installed Next version before creating one.
|
|
206
|
+
|
|
207
|
+
Use the smallest boundary that gives the intended user experience. A project may intentionally prefer a shared route skeleton or a local component state; preserve either approach when valid.
|
|
208
|
+
|
|
209
|
+
*Sources: [Next.js — Loading UI and Streaming](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming) · [Next.js — Error Handling](https://nextjs.org/docs/app/building-your-application/routing/error-handling)*
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Avoid Hydration Mismatches by Preserving Initial Output
|
|
214
|
+
|
|
215
|
+
### Symptom
|
|
216
|
+
The server-rendered HTML differs from the first client render, producing a hydration warning, discarded markup, or visible flicker.
|
|
217
|
+
|
|
218
|
+
### Verify first
|
|
219
|
+
Look for browser-only values (`window`, storage, viewport), time, randomness, locale, and data that changes between the server and first client render. Confirm whether the component is intended to render consistently on both sides.
|
|
220
|
+
|
|
221
|
+
### Fix
|
|
222
|
+
Render the same initial output on server and client, then read browser-only state after mount when necessary. For an intentionally client-only widget, isolate it behind the project’s established client boundary rather than scattering hydration suppressions.
|
|
223
|
+
|
|
224
|
+
Do not use `suppressHydrationWarning` as a general fix; it is a narrow escape hatch and does not reconcile the underlying output.
|
|
225
|
+
|
|
226
|
+
*Source: [Next.js — React Hydration Error](https://nextjs.org/docs/messages/react-hydration-error)*
|