Skip to content

Commit 4bafb28

Browse files
bteaCopilot
andauthored
fix: pin en-US locale in builtin MDN type links (#997)
* fix: pin en-US locale in builtin MDN type links * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: update --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent c334823 commit 4bafb28

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

.changeset/mdn-type-link-locale.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@node-core/doc-kit': patch
3+
---
4+
5+
Pin the `en-US` locale on builtin MDN type links that carry a hash fragment
6+
(e.g. `number`, `string`, `any`). Locale-less MDN URLs redirect to the
7+
visitor's preferred language, where heading anchor IDs are translated, so the
8+
original fragment (e.g. `#number_type`) no longer matches any anchor on the
9+
redirected page and the link fails to jump to the target section.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"asynciterable": "https://tc39.github.io/ecma262/#sec-asynciterable-interface",
3-
"iterable": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol",
3+
"iterable": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol",
44
"void": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/void",
55
"module namespace object": "https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects",
6-
"null": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#null_type",
7-
"undefined": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#undefined_type",
8-
"boolean": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type",
9-
"number": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type",
10-
"bigint": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#bigint_type",
11-
"string": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type",
12-
"symbol": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#symbol_type",
13-
"integer": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type",
14-
"any": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#Data_types",
6+
"null": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type",
7+
"undefined": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type",
8+
"boolean": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type",
9+
"number": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type",
10+
"bigint": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type",
11+
"string": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type",
12+
"symbol": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#symbol_type",
13+
"integer": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type",
14+
"any": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types",
1515
"this": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/this"
1616
}

packages/core/src/generators/metadata/utils/__tests__/resolveTypes.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('resolveTypeAnnotations', () => {
125125
],
126126
[
127127
'string',
128-
'https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type',
128+
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type',
129129
],
130130
['Buffer', 'buffer.html#buffer'],
131131
]
@@ -135,7 +135,7 @@ describe('resolveTypeAnnotations', () => {
135135

136136
it('resolves every annotation in a nested tree', () => {
137137
const STRING_URL =
138-
'https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type';
138+
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type';
139139

140140
// Two per paragraph: a visitor that skips siblings still reaches the first
141141
const nodes = ['string', 'HTTP/2 Headers Object', 'string', 'string'].map(

packages/core/src/generators/metadata/utils/__tests__/transformers.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('lookupTypeName', () => {
1111
it('resolves JavaScript primitives from the built-in map', () => {
1212
strictEqual(
1313
lookupTypeName('string'),
14-
'https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type'
14+
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type'
1515
);
1616
});
1717

0 commit comments

Comments
 (0)