Skip to content

Commit 1b37add

Browse files
authored
Merge pull request #41780 from github/repo-sync
Repo sync
2 parents 9ff1047 + abf0033 commit 1b37add

File tree

26 files changed

+3943
-535
lines changed

26 files changed

+3943
-535
lines changed

content/get-started/start-your-journey/index.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Start your journey
3-
intro: 'Learn the basics of {% data variables.product.github %}.'
3+
intro: "Brand new to {% data variables.product.github %}? Learn the basics here."
44
versions:
55
fpt: '*'
66
ghes: '*'
@@ -22,4 +22,18 @@ children:
2222
redirect_from:
2323
- /github/getting-started-with-github/quickstart
2424
- /get-started/quickstart
25+
layout: journey-landing
26+
journeyTracks:
27+
- id: 'learn_the_basics'
28+
title: 'Get started'
29+
description: 'Master the fundamentals of {% data variables.product.github %} and Git.'
30+
guides:
31+
- '/get-started/start-your-journey/about-github-and-git'
32+
- '/get-started/start-your-journey/creating-an-account-on-github'
33+
- '/get-started/start-your-journey/hello-world'
34+
- '/get-started/start-your-journey/setting-up-your-profile'
35+
- '/get-started/start-your-journey/finding-inspiration-on-github'
36+
- '/get-started/start-your-journey/downloading-files-from-github'
37+
- '/get-started/start-your-journey/uploading-a-project-to-github'
38+
- '/get-started/start-your-journey/git-and-github-learning-resources'
2539
---

data/features/dependabot-option-cooldown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
versions:
44
fpt: '*'
55
ghec: '*'
6-
ghes: '>3.19'
6+
ghes: '>3.18'

src/article-api/middleware/article.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,19 @@ function incrementArticleLookup(
172172

173173
// logs the source of the request, if it's for hovercards it'll have the header X-Request-Source.
174174
// see src/links/components/LinkPreviewPopover.tsx
175-
const source =
176-
req.get('X-Request-Source') ||
177-
(req.get('Referer')
178-
? `external-${new URL(req.get('Referer') || '').hostname || 'unknown'}`
179-
: 'external')
175+
let source = req.get('X-Request-Source')
176+
if (!source) {
177+
const referer = req.get('Referer')
178+
if (referer) {
179+
try {
180+
source = `external-${new URL(referer).hostname || 'unknown'}`
181+
} catch {
182+
source = 'external'
183+
}
184+
} else {
185+
source = 'external'
186+
}
187+
}
180188

181189
const tags = [
182190
// According to https://docs.datadoghq.com/getting_started/tagging/#define-tags

src/article-api/tests/article-body.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,13 @@ describe('article body api', () => {
6666
const { error } = JSON.parse(res.body)
6767
expect(error).toContain("isn't yet available in markdown")
6868
})
69+
70+
test('invalid Referer header does not crash', async () => {
71+
const res = await get(makeURL('/en/get-started/start-your-journey/hello-world'), {
72+
headers: {
73+
Referer: 'invalid-url',
74+
},
75+
})
76+
expect(res.statusCode).toBe(200)
77+
})
6978
})

src/codeql-cli/scripts/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function main() {
2929
includeBasePath: true,
3030
globs: ['**/*.md'],
3131
})
32-
const cliMarkdownContents: Record<string, { data: any; content: string }> = {}
32+
const cliMarkdownContents: Record<string, { data: Record<string, unknown>; content: string }> = {}
3333

3434
for (const file of markdownFiles) {
3535
const sourceContent = await readFile(file, 'utf8')

src/content-linter/lib/linting-rules/ctas-schema.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ export const ctasSchema: Rule = {
105105
for (const error of errors) {
106106
let message = ''
107107
if (error.keyword === 'required') {
108-
message = `Missing required parameter: ${(error.params as any)?.missingProperty}`
108+
message = `Missing required parameter: ${(error.params as { missingProperty?: string })?.missingProperty}`
109109
} else if (error.keyword === 'enum') {
110110
const paramName = error.instancePath.substring(1)
111111
// Get the actual invalid value from refParams and allowed values from params
112112
const invalidValue = refParams[paramName]
113-
const allowedValues = (error.params as any)?.allowedValues || []
113+
const allowedValues =
114+
(error.params as { allowedValues?: unknown[] })?.allowedValues || []
114115
message = `Invalid value for ${paramName}: "${invalidValue}". Valid values are: ${allowedValues.join(', ')}`
115116
} else if (error.keyword === 'additionalProperties') {
116-
message = `Unexpected parameter: ${(error.params as any)?.additionalProperty}`
117+
message = `Unexpected parameter: ${(error.params as { additionalProperty?: string })?.additionalProperty}`
117118
} else {
118119
message = `CTA URL validation error: ${error.message}`
119120
}

src/content-linter/lib/linting-rules/link-punctuation.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@ import type { RuleParams, RuleErrorCallback, Rule } from '../../types'
33

44
import { doesStringEndWithPeriod, getRange, isStringQuoted } from '../helpers/utils'
55

6+
// Minimal type for markdownit tokens used in this rule
7+
interface MarkdownToken {
8+
children?: MarkdownToken[]
9+
line?: string
10+
type?: string
11+
content?: string
12+
lineNumber?: number
13+
}
14+
615
export const linkPunctuation: Rule = {
716
names: ['GHD001', 'link-punctuation'],
817
description: 'Internal link titles must not contain punctuation',
918
tags: ['links', 'url'],
1019
parser: 'markdownit',
1120
function: (params: RuleParams, onError: RuleErrorCallback) => {
12-
// Using 'any' type for token as markdownlint-rule-helpers doesn't provide TypeScript types
13-
filterTokens(params, 'inline', (token: any) => {
21+
filterTokens(params, 'inline', (token: MarkdownToken) => {
1422
const { children, line } = token
1523
let inLink = false
16-
for (const child of children) {
24+
for (const child of children || []) {
1725
if (child.type === 'link_open') {
1826
inLink = true
1927
} else if (child.type === 'link_close') {
2028
inLink = false
21-
} else if (inLink && child.type === 'text') {
29+
} else if (inLink && child.type === 'text' && child.content) {
2230
const content = child.content.trim()
2331
const hasPeriod = doesStringEndWithPeriod(content)
2432
const hasQuotes = isStringQuoted(content)
2533

2634
if (hasPeriod || hasQuotes) {
27-
const range = getRange(line, content)
35+
const range = line ? getRange(line, content) : []
2836
addError(
2937
onError,
30-
child.lineNumber,
38+
child.lineNumber || 1,
3139
'Remove quotes and/or period punctuation from the link title.',
3240
child.content,
3341
range,

src/content-render/liquid/data.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import { getDataByLanguage } from '@/data-directory/lib/get-data'
77
const Syntax = /([a-z0-9/\\_.\-[\]]+)/i
88
const SyntaxHelp = "Syntax Error in 'data' - Valid syntax: data [path]"
99

10-
// Using any for scope because it has custom environments property not in Liquid's Scope type
10+
// Using unknown for scope because it has custom environments property not in Liquid's Scope type
1111
interface CustomScope {
12-
environments: any
13-
[key: string]: any
12+
environments: {
13+
currentLanguage?: string
14+
[key: string]: unknown
15+
}
16+
[key: string]: unknown
1417
}
1518

1619
interface DataTag {
@@ -32,7 +35,7 @@ export default {
3235
},
3336

3437
async render(scope: CustomScope) {
35-
let text = getDataByLanguage(this.path, scope.environments.currentLanguage)
38+
let text = getDataByLanguage(this.path, scope.environments.currentLanguage || '')
3639
if (text === undefined) {
3740
if (scope.environments.currentLanguage === 'en') {
3841
const message = `Can't find the key 'data ${this.path}' in the scope.`

src/fixtures/tests/internal-links.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('autotitle', () => {
99
test('internal links with AUTOTITLE resolves', async () => {
1010
const $: cheerio.Root = await getDOM('/get-started/foo/autotitling')
1111
const links = $('#article-contents a[href]')
12-
links.each((i: number, element: any) => {
12+
links.each((i: number, element: cheerio.Element) => {
1313
if ($(element).attr('href')?.includes('/get-started/start-your-journey/hello-world')) {
1414
expect($(element).text()).toBe('Hello World')
1515
}
@@ -49,13 +49,14 @@ describe('cross-version-links', () => {
4949

5050
// Tests that the hardcoded prefix is always removed
5151
const firstLink = links.filter(
52-
(i: number, element: any) => $(element).text() === 'Hello world always in free-pro-team',
52+
(i: number, element: cheerio.Element) =>
53+
$(element).text() === 'Hello world always in free-pro-team',
5354
)
5455
expect(firstLink.attr('href')).toBe('/en/get-started/start-your-journey/hello-world')
5556

5657
// Tests that the second link always goes to [email protected]
5758
const secondLink = links.filter(
58-
(i: number, element: any) =>
59+
(i: number, element: cheerio.Element) =>
5960
$(element).text() === 'Autotitling page always in enterprise-server latest',
6061
)
6162
expect(secondLink.attr('href')).toBe(
@@ -72,29 +73,33 @@ describe('link-rewriting', () => {
7273

7374
{
7475
const link = links.filter(
75-
(i: number, element: any) => $(element).text() === 'Cross Version Linking',
76+
(i: number, element: cheerio.Element) => $(element).text() === 'Cross Version Linking',
7677
)
7778
expect(link.attr('href')).toMatch('/en/get-started/')
7879
}
7980

8081
// Some links are left untouched
8182

8283
{
83-
const link = links.filter((i: number, element: any) =>
84+
const link = links.filter((i: number, element: cheerio.Element) =>
8485
$(element).text().includes('Enterprise 11.10'),
8586
)
8687
expect(link.attr('href')).toMatch('/en/enterprise/')
8788
}
8889
{
89-
const link = links.filter((i: number, element: any) => $(element).text().includes('peterbe'))
90+
const link = links.filter((i: number, element: cheerio.Element) =>
91+
$(element).text().includes('peterbe'),
92+
)
9093
expect(link.attr('href')).toMatch(/^https:/)
9194
}
9295
{
93-
const link = links.filter((i: number, element: any) => $(element).text().includes('Picture'))
96+
const link = links.filter((i: number, element: cheerio.Element) =>
97+
$(element).text().includes('Picture'),
98+
)
9499
expect(link.attr('href')).toMatch(/^\/assets\//)
95100
}
96101
{
97-
const link = links.filter((i: number, element: any) =>
102+
const link = links.filter((i: number, element: cheerio.Element) =>
98103
$(element).text().includes('GraphQL Schema'),
99104
)
100105
expect(link.attr('href')).toMatch(/^\/public\//)
@@ -108,7 +113,7 @@ describe('link-rewriting', () => {
108113
const links = $('#article-contents a[href]')
109114

110115
const link = links.filter(
111-
(i: number, element: any) => $(element).text() === 'Cross Version Linking',
116+
(i: number, element: cheerio.Element) => $(element).text() === 'Cross Version Linking',
112117
)
113118
expect(link.attr('href')).toMatch('/en/enterprise-cloud@latest/get-started/')
114119
})
@@ -121,7 +126,7 @@ describe('link-rewriting', () => {
121126
const links = $('#article-contents a[href]')
122127

123128
const link = links.filter(
124-
(i: number, element: any) => $(element).text() === 'Cross Version Linking',
129+
(i: number, element: cheerio.Element) => $(element).text() === 'Cross Version Linking',
125130
)
126131
expect(link.attr('href')).toMatch(
127132
`/en/enterprise-server@${enterpriseServerReleases.latestStable}/get-started/`,
@@ -133,14 +138,14 @@ describe('subcategory links', () => {
133138
test('no free-pro-team prefix', async () => {
134139
const $: cheerio.Root = await getDOM('/rest/actions')
135140
const links = $('[data-testid="table-of-contents"] a[href]')
136-
links.each((i: number, element: any) => {
141+
links.each((i: number, element: cheerio.Element) => {
137142
expect($(element).attr('href')).not.toContain('/free-pro-team@latest')
138143
})
139144
})
140145
test('enterprise-server prefix', async () => {
141146
const $: cheerio.Root = await getDOM('/enterprise-server@latest/rest/actions')
142147
const links = $('[data-testid="table-of-contents"] a[href]')
143-
links.each((i: number, element: any) => {
148+
links.each((i: number, element: cheerio.Element) => {
144149
expect($(element).attr('href')).toMatch(/\/enterprise-server@\d/)
145150
})
146151
})

0 commit comments

Comments
 (0)