Skip to content

Commit 47863b2

Browse files
authored
Merge pull request #227 from vercel-labs/shu/rBVLn
Update incorrect example
2 parents 6938f37 + dc8367e commit 47863b2

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

packages/react-best-practices-build/test-cases.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
"ruleId": "",
180180
"ruleTitle": "Prefer Statically Analyzable Paths",
181181
"type": "bad",
182-
"code": "const CONTENT_DIRS = {\n blog: 'content/blog',\n docs: 'content/docs',\n} as const\n\nconst baseDir = path.join(process.cwd(), CONTENT_DIRS[contentKind])",
182+
"code": "const baseDir = path.join(process.cwd(), 'content/' + contentKind)",
183183
"language": "ts",
184184
"description": "a 2-value enum still hides the final path from static analysis"
185185
},
@@ -1111,4 +1111,4 @@
11111111
"language": "tsx",
11121112
"description": "serializes only 1 field"
11131113
}
1114-
]
1114+
]

skills/react-best-practices/AGENTS.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,7 @@ const Page = await PAGE_MODULES[pageName]()
622622
**Incorrect: a 2-value enum still hides the final path from static analysis**
623623

624624
```ts
625-
const CONTENT_DIRS = {
626-
blog: 'content/blog',
627-
docs: 'content/docs',
628-
} as const
629-
630-
const baseDir = path.join(process.cwd(), CONTENT_DIRS[contentKind])
625+
const baseDir = path.join(process.cwd(), 'content/' + contentKind)
631626
```
632627

633628
**Correct: make each final path literal at the callsite**

skills/react-best-practices/rules/bundle-analyzable-paths.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ const Page = await PAGE_MODULES[pageName]()
4646
**Incorrect (a 2-value enum still hides the final path from static analysis):**
4747

4848
```ts
49-
const CONTENT_DIRS = {
50-
blog: 'content/blog',
51-
docs: 'content/docs',
52-
} as const
53-
54-
const baseDir = path.join(process.cwd(), CONTENT_DIRS[contentKind])
49+
const baseDir = path.join(process.cwd(), 'content/' + contentKind)
5550
```
5651

5752
**Correct (make each final path literal at the callsite):**

0 commit comments

Comments
 (0)