Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/package-lock-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
run: |
npm --version

# Save the current top-level dependencies from package-lock.json
node -e "console.log(JSON.stringify(require('./package-lock.json').packages['']))" > /tmp/before.json

# From https://docs.npmjs.com/cli/v7/commands/npm-install
#
# The --package-lock-only argument will only update the
Expand All @@ -45,9 +48,16 @@ jobs:
#
npm install --package-lock-only --ignore-scripts --include=optional

# If the package.json (dependencies and devDependencies) is
# in correct sync with package-lock.json running the above command
# should *not* make an edit to the package-lock.json. I.e.
# running `git status` should
# say "nothing to commit, working tree clean".
git diff --exit-code
# Extract the top-level dependencies after regeneration
node -e "console.log(JSON.stringify(require('./package-lock.json').packages['']))" > /tmp/after.json

# Compare only the top-level package dependencies
# This ignores platform-specific differences in nested dependency resolution
# (like "peer" flags) that don't affect actual installed versions
if ! diff /tmp/before.json /tmp/after.json; then
echo "ERROR: Top-level dependencies in package-lock.json are out of sync with package.json"
echo "Please run 'npm install' locally and commit the updated package-lock.json"
exit 1
fi

echo "✓ Top-level dependencies are in sync"
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ These terms apply to the pre-release software made available to you by GitHub. T

## 4. Data Collection and Usage.

a. **Consent to Data Collection.** The pre-release software may collect telemetry information about you and your use of the software, and send that information to GitHub. Subject to the limitations in Section 4(b) below, GitHub may use this information to provide services, to improve our products and services, or for any other purpose permitted under the GitHub Data Protection Agreement or GitHub Privacy Statement. Your use of the pre-release software operates as your consent to these practices.
a. **Processing of Personal Data.** By default, GitHub is the data controller in relation to the Personal Data processed in connection with the pre-release software and follows the terms below. As the pre-release software is developed, it may reach a stage where data is handled the same as it will when the software becomes generally available. Pre-release software that has progressed to that stage of development is listed at [https://gh.io/dpa-previews](https://gh.io/dpa-previews). At that point, the customer becomes the data controller and the software is governed by the terms of the GitHub Data Protection Agreement instead of this Section 4.

b. **Use of Collected Data.**
b. **Consent to Data Collection.** The pre-release software may collect telemetry information about you and your use of the software, and send that information to GitHub. Subject to the limitations in Section 4(c) below, GitHub may use this information to provide services, to improve our products and services, or for any other purpose permitted under the GitHub Data Protection Agreement or GitHub Privacy Statement. Your use of the pre-release software operates as your consent to these practices.

c. **Use of Collected Data.**
* GitHub will use collected data for analytics and measurement to understand how our pre-release software and related products are used.
* The software will collect data and usage information about events generated when interacting with it. These events help us analyze and measure performance and features used. This usage information is used by GitHub and may be shared with affiliates and other third parties to help deliver, develop, evaluate, and improve the software and related products.
* We analyze data to ensure the pre-release software is working as intended, to evaluate the safety, reliability, and user experience of the software, and to investigate and detect potential abuse.
Expand All @@ -66,8 +68,6 @@ These terms apply to the pre-release software made available to you by GitHub. T
* GitHub does not own the output sent to you by the software.
* GitHub will not use your inputs or the outputs generated to train AI language models, unless you have instructed us in writing to do so.

c. **Processing of Personal Data.** GitHub is the data controller in relation to the Personal Data processed in connection with the pre-release software.

d. **Data Collection by You.** There may be some features in the pre-release software that enable you and GitHub to collect data from users of your applications. If you use these features, you must comply with all applicable laws on data collection, including providing appropriate notices to users of your applications as well as a copy of GitHub’s Privacy Statement. You can learn more about data collection and use in the software documentation.

e. **Revocation of Consent to Data Collection.** You may revoke your consent to data collection by the prerelease software by contacting GitHub and requesting removal from the technical preview. Please note that, if you request removal from the preview, you will no longer be able to use the pre-release software.
Expand Down Expand Up @@ -120,4 +120,4 @@ You bear the sole risk of using the pre-release software.

## 15. Nature of Terms for Microsoft Customers.

If you license GitHub through Microsoft, these terms shall be considered an amendment to the Microsoft Product Terms for GitHub Offerings for the duration of your use of the pre-release software.
If you license GitHub through Microsoft and your agreement with Microsoft does not already provide for the inclusion of these terms, these terms shall be considered an amendment to the Microsoft Product Terms for GitHub Offerings for the duration of your use of the pre-release software.
4 changes: 3 additions & 1 deletion data/reusables/copilot/ccr-model-settings.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
> [!NOTE]
> {% data variables.copilot.copilot_code-review_short %} may use models that are not enabled on your organization's "Models" settings page. See [AUTOTITLE](/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies).
> {% data variables.copilot.copilot_code-review_short %} may use models that are not enabled on your organization's "Models" settings page. The "Models" settings page only controls {% data variables.copilot.copilot_chat_short %}.
>
> Since {% data variables.copilot.copilot_code-review_short %} is generally available, all model usage will be subject to the generally available terms. See [AUTOTITLE](/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies).
57 changes: 57 additions & 0 deletions eslint-plugins.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Type declarations for ESLint plugins without official TypeScript definitions

declare module 'eslint-plugin-github' {
import type { ESLint, Linter } from 'eslint'

const plugin: ESLint.Plugin & {
configs: {
recommended: Linter.FlatConfig
}
}

export default plugin
}

declare module 'eslint-plugin-primer-react' {
import type { ESLint, Linter } from 'eslint'

const plugin: ESLint.Plugin & {
configs: {
recommended: Linter.FlatConfig
}
}

export default plugin
}

declare module 'eslint-plugin-eslint-comments' {
import type { ESLint } from 'eslint'

const plugin: ESLint.Plugin

export default plugin
}

declare module 'eslint-plugin-i18n-text' {
import type { ESLint } from 'eslint'

const plugin: ESLint.Plugin

export default plugin
}

declare module 'eslint-plugin-filenames' {
import type { ESLint } from 'eslint'

const plugin: ESLint.Plugin

export default plugin
}

declare module 'eslint-plugin-no-only-tests' {
import type { ESLint } from 'eslint'

const plugin: ESLint.Plugin

export default plugin
}
83 changes: 0 additions & 83 deletions eslint.config.js → eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,89 +14,6 @@ import prettier from 'eslint-config-prettier'
import globals from 'globals'

export default [
// JavaScript and MJS files configuration
{
files: ['**/*.{js,mjs}'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.commonjs,
...globals.es2020,
},
parserOptions: {
requireConfigFile: false,
},
},
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},
plugins: {
github,
import: importPlugin,
'eslint-comments': eslintComments,
'i18n-text': i18nText,
filenames,
'no-only-tests': noOnlyTests,
prettier: prettierPlugin,
},
rules: {
// ESLint recommended rules
...js.configs.recommended.rules,

// GitHub plugin recommended rules
...github.configs.recommended.rules,

// Import plugin error rules
...importPlugin.configs.errors.rules,

// JavaScript-specific overrides
'import/no-extraneous-dependencies': [
'error',
{
packageDir: '.',
},
],
'import/extensions': 'off',
'no-console': 'off',
camelcase: 'off',
'no-shadow': 'off',
'prefer-template': 'off',
'no-constant-condition': 'off',
'no-unused-vars': 'off',
'import/no-named-as-default-member': 'off',
'one-var': 'off',
'import/no-namespace': 'off',
'import/no-anonymous-default-export': 'off',
'object-shorthand': 'off',
'no-empty': 'off',
'prefer-const': 'off',
'import/no-named-as-default': 'off',
'no-useless-concat': 'off',
'func-style': 'off',

// Disable GitHub plugin rules that were disabled in original config
'github/array-foreach': 'off',
'github/no-then': 'off',

// Disable rules that might not exist or cause issues initially
'i18n-text/no-en': 'off',
'filenames/match-regex': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'eslint-comments/no-unlimited-disable': 'off',

// Disable new ESLint 9 rules that are causing issues
'no-constant-binary-expression': 'off',
},
},

// TypeScript and TSX files configuration
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
Expand Down
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"@types/connect-timeout": "1.9.0",
"@types/cookie": "0.6.0",
"@types/cookie-parser": "1.4.8",
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
"@types/event-to-promise": "^0.7.5",
"@types/express": "^5.0.3",
"@types/imurmurhash": "^0.1.4",
Expand Down Expand Up @@ -298,6 +299,7 @@
"graphql": "^16.9.0",
"http-status-code": "^2.1.0",
"husky": "^9.1.7",
"jiti": "^2.6.1",
"json-schema-merge-allof": "^0.8.1",
"lint-staged": "^16.0.0",
"markdownlint": "^0.34.0",
Expand Down
2 changes: 0 additions & 2 deletions src/ai-tools/scripts/ai-tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import { fileURLToPath } from 'url'
import { Command } from 'commander'
import fs from 'fs'
Expand Down
89 changes: 89 additions & 0 deletions src/content-linter/lib/linting-rules/frontmatter-hero-image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import fs from 'fs'
import path from 'path'
// @ts-ignore - markdownlint-rule-helpers doesn't have TypeScript declarations
import { addError } from 'markdownlint-rule-helpers'

import { getFrontmatter } from '../helpers/utils'
import type { RuleParams, RuleErrorCallback, Rule } from '@/content-linter/types'

interface Frontmatter {
heroImage?: string
[key: string]: any
}

// Get the list of valid hero images
function getValidHeroImages(): string[] {
const ROOT = process.env.ROOT || '.'
const heroImageDir = path.join(ROOT, 'assets/images/banner-images')

try {
if (!fs.existsSync(heroImageDir)) {
return []
}

const files = fs.readdirSync(heroImageDir)
// Return absolute paths as they would appear in frontmatter
return files.map((file) => `/assets/images/banner-images/${file}`)
} catch {
return []
}
}

export const frontmatterHeroImage: Rule = {
names: ['GHD061', 'frontmatter-hero-image'],
description:
'Hero image paths must be absolute and point to valid images in /assets/images/banner-images/',
tags: ['frontmatter', 'images'],
function: (params: RuleParams, onError: RuleErrorCallback) => {
// Only check index.md files
if (!params.name.endsWith('index.md')) return

const fm = getFrontmatter(params.lines) as Frontmatter | null
if (!fm || !fm.heroImage) return

const heroImage = fm.heroImage

// Check if heroImage is an absolute path
if (!heroImage.startsWith('/')) {
const line = params.lines.find((line: string) => line.trim().startsWith('heroImage:'))
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1
addError(
onError,
lineNumber,
`Hero image path must be absolute (start with /). Found: ${heroImage}`,
line || '',
null, // No fix possible
)
return
}

// Check if heroImage points to banner-images directory
if (!heroImage.startsWith('/assets/images/banner-images/')) {
const line = params.lines.find((line: string) => line.trim().startsWith('heroImage:'))
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1
addError(
onError,
lineNumber,
`Hero image must point to /assets/images/banner-images/. Found: ${heroImage}`,
line || '',
null, // No fix possible
)
return
}

// Check if the file actually exists
const validHeroImages = getValidHeroImages()
if (validHeroImages.length > 0 && !validHeroImages.includes(heroImage)) {
const line = params.lines.find((line: string) => line.trim().startsWith('heroImage:'))
const lineNumber = line ? params.lines.indexOf(line) + 1 : 1
const availableImages = validHeroImages.join(', ')
addError(
onError,
lineNumber,
`Hero image file does not exist: ${heroImage}. Available images: ${availableImages}`,
line || '',
null, // No fix possible
)
}
},
}
2 changes: 2 additions & 0 deletions src/content-linter/lib/linting-rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { ctasSchema } from '@/content-linter/lib/linting-rules/ctas-schema'
import { journeyTracksLiquid } from './journey-tracks-liquid'
import { journeyTracksGuidePathExists } from './journey-tracks-guide-path-exists'
import { journeyTracksUniqueIds } from './journey-tracks-unique-ids'
import { frontmatterHeroImage } from './frontmatter-hero-image'

// Using any type because @github/markdownlint-github doesn't provide TypeScript declarations
// The elements in the array have a 'names' property that contains rule identifiers
Expand Down Expand Up @@ -130,6 +131,7 @@ export const gitHubDocsMarkdownlint = {
journeyTracksLiquid, // GHD058
journeyTracksGuidePathExists, // GHD059
journeyTracksUniqueIds, // GHD060
frontmatterHeroImage, // GHD061

// Search-replace rules
searchReplace, // Open-source plugin
Expand Down
Loading
Loading