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
Binary file removed assets/images/search/copilot-action.png
Binary file not shown.

This file was deleted.

This file was deleted.

66 changes: 18 additions & 48 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,63 +67,33 @@ export default [
// JSX A11y recommended rules
...jsxA11y.configs.recommended.rules,

// TypeScript-specific overrides
// 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',
'no-undef': 'off',
'no-use-before-define': 'off',
'no-redeclare': 'off', // Allow function overloads in TypeScript
'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',

// TypeScript ESLint specific rules
'import/extensions': ['error', { json: 'always' }],
'no-empty': ['error', { allowEmptyCatch: true }],
'@typescript-eslint/no-unused-vars': 'error',
'prefer-const': ['error', { destructuring: 'all' }],

// 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',

// Disable stricter TypeScript rules initially
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/prefer-as-const': 'off',
// Rules that must be disabled
'no-redeclare': 'off', // Allow function overloads in TypeScript
'i18n-text/no-en': 'off', // This rule causes eslint to not run at all
'filenames/match-regex': 'off', // This rule causes eslint to not run at all

// React/JSX specific rules
'jsx-a11y/no-onchange': 'off',
// Disabled rules to review
'github/no-then': 'off', // 30+
'@typescript-eslint/ban-ts-comment': 'off', // 50+
'no-undef': 'off', // 50+
'no-shadow': 'off', // 150+
'prefer-template': 'off', // 150+
'github/array-foreach': 'off', // 250+
camelcase: 'off', // 600+
'no-console': 'off', // 800+
'@typescript-eslint/no-explicit-any': 'off', // 1000+
},
},

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"index-general-search": "tsx src/search/scripts/index/index-cli general-search",
"index-test-fixtures": "./src/search/scripts/index-test-fixtures.sh",
"labeler": "tsx .github/actions/labeler/labeler.ts",
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
"lint": "eslint '**/*.{ts,tsx}'",
"lint-content": "tsx src/content-linter/scripts/lint-content.ts",
"lint-translation": "vitest src/content-linter/tests/lint-files.ts",
"liquid-markdown-tables": "tsx src/tools/scripts/liquid-markdown-tables/index.ts",
Expand All @@ -67,8 +67,8 @@
"postinstall": "cp package-lock.json .installed.package-lock.json && echo \"Updated .installed.package-lock.json\" # see husky/post-checkout and husky/post-merge",
"precompute-pageinfo": "tsx src/article-api/scripts/precompute-pageinfo.ts",
"prepare": "husky src/workflows/husky",
"prettier": "prettier -w \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"",
"prettier-check": "prettier -c \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"",
"prettier": "prettier -w \"**/*.{ts,tsx,scss,yml,yaml}\"",
"prettier-check": "prettier -c \"**/*.{ts,tsx,scss,yml,yaml}\"",
"prevent-pushes-to-main": "tsx src/workflows/prevent-pushes-to-main.ts",
"purge-fastly-edge-cache": "tsx src/workflows/purge-fastly-edge-cache.ts",
"purge-fastly-edge-cache-per-language": "tsx src/languages/scripts/purge-fastly-edge-cache-per-language.ts",
Expand Down Expand Up @@ -105,12 +105,12 @@
"what-docs-early-access-branch": "tsx src/early-access/scripts/what-docs-early-access-branch.ts"
},
"lint-staged": {
"*.{js,mjs,ts,tsx}": "eslint --cache --fix",
"*.{js,mjs,scss,ts,tsx,yml,yaml}": "prettier --write",
"*.{ts,tsx}": "eslint --cache --fix",
"*.{scss,ts,tsx,yml,yaml}": "prettier --write",
"{content,data}/**/*.md": "npm run lint-content -- --precommit --paths"
},
"nodemonConfig": {
"ext": "ts,js,json,yml,md,html,scss",
"ext": "ts,json,yml,md,html,scss",
"exec": "tsx",
"ignore": [
"assets",
Expand Down Expand Up @@ -139,7 +139,7 @@
},
{
"files": [
"**/*.{ts,tsx,js,mjs}"
"**/*.{ts,tsx}"
],
"options": {
"printWidth": 100,
Expand Down
2 changes: 1 addition & 1 deletion src/archives/middleware/archived-enterprise-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default async function archivedEnterpriseVersions(
// `x-host` is a custom header set by Fastly.
// GLB automatically deletes the `x-forwarded-host` header.
const host = req.get('x-host') || req.get('x-forwarded-host') || req.get('host')
let modifiedBody = body
const modifiedBody = body
.replaceAll(
`${OLD_AZURE_BLOB_ENTERPRISE_DIR}/${requestedVersion}/assets/cb-`,
`${ENTERPRISE_GH_PAGES_URL_PREFIX}${requestedVersion}/assets/cb-`,
Expand Down
2 changes: 1 addition & 1 deletion src/assets/scripts/deleted-assets-pr-comment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as github from '@actions/github'
import github from '@actions/github'
import core from '@actions/core'

const { GITHUB_TOKEN } = process.env
Expand Down
8 changes: 6 additions & 2 deletions src/assets/scripts/find-orphaned-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ async function main(opts: MainOptions) {
// Add exceptions
sourceFiles.push('.github/CONTRIBUTING.md')
sourceFiles.push('README.md')
verbose && console.log(`${sourceFiles.length.toLocaleString()} source files found in total.`)
if (verbose) {
console.log(`${sourceFiles.length.toLocaleString()} source files found in total.`)
}

const allImages = new Set(
walk(
Expand All @@ -159,7 +161,9 @@ async function main(opts: MainOptions) {
).filter((filePath) => !filePath.endsWith('.md')),
)

verbose && console.log(`${allImages.size.toLocaleString()} images found in total.`)
if (verbose) {
console.log(`${allImages.size.toLocaleString()} images found in total.`)
}

for (const sourceFile of sourceFiles) {
const content = fs.readFileSync(sourceFile, 'utf-8')
Expand Down
2 changes: 1 addition & 1 deletion src/assets/tests/static-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type MockResponse = {
_json?: string
_send?: string
headers: Record<string, string>
set?: (key: string | Object, value: string) => void
set?: (key: string | object, value: string) => void
removeHeader?: (key: string) => void
hasHeader?: (key: string) => boolean
}
Expand Down
12 changes: 6 additions & 6 deletions src/audit-logs/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function resolveReferenceLinksToTitles(
// docs_reference_links: 'event reference links'
// },
// ]
export function getAuditLogEvents(page: string, version: string) {
export function getAuditLogEvents(page: string, version: string): AuditLogEventT[] {
const openApiVersion = getOpenApiVersion(version)
const auditLogFileName = path.join(AUDIT_LOG_DATA_DIR, openApiVersion, `${page}.json`)

Expand All @@ -115,14 +115,14 @@ export function getAuditLogEvents(page: string, version: string) {
?.set(page, readCompressedJsonFileFallback(auditLogFileName))
}

const auditLogEvents = auditLogEventsCache.get(openApiVersion)?.get(page)!
const auditLogEvents = auditLogEventsCache.get(openApiVersion)?.get(page)
// If an event doesn't yet have a description (value will be empty string or
// "N/A"), then we don't show the event.
const filteredAuditLogEvents = auditLogEvents.filter(
const filteredAuditLogEvents = auditLogEvents?.filter(
(event) => event.description !== 'N/A' && event.description !== '',
)

return filteredAuditLogEvents
return filteredAuditLogEvents || []
}

// get categorized audit log event data for the requested page and version
Expand All @@ -137,7 +137,7 @@ export function getAuditLogEvents(page: string, version: string) {
// repo: [ [Object] ],
// user: [ [Object], [Object] ]
// }
export function getCategorizedAuditLogEvents(page: string, version: string) {
export function getCategorizedAuditLogEvents(page: string, version: string): CategorizedEvents {
const events = getAuditLogEvents(page, version)
const openApiVersion = getOpenApiVersion(version)

Expand All @@ -148,7 +148,7 @@ export function getCategorizedAuditLogEvents(page: string, version: string) {
categorizedAuditLogEventsCache.get(openApiVersion)?.set(page, categorizeEvents(events))
}

return categorizedAuditLogEventsCache.get(openApiVersion)?.get(page)!
return categorizedAuditLogEventsCache.get(openApiVersion)?.get(page) || {}
}

// Filters audit log events based on allowlist values.
Expand Down
4 changes: 3 additions & 1 deletion src/audit-logs/pages/audit-log-events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
Object.keys(auditLogEvents).map((category) => category),
context,
)
auditLogEventsMiniTocs && miniTocItems.push(...auditLogEventsMiniTocs)
if (auditLogEventsMiniTocs) {
miniTocItems.push(...auditLogEventsMiniTocs)
}

return {
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/content-linter/lib/helpers/should-include-result.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as nodePath from 'path'
import nodePath from 'path'
import { reportingConfig } from '@/content-linter/style/github-docs'

interface LintFlaw {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const liquidIfversionVersions = {
// The versions frontmatter object or all versions if the file
// being processed is a data file.
const fm = getFrontmatter(params.lines)
let content = fm ? getFrontmatterLines(params.lines).join('\n') : params.lines.join('\n')
const content = fm ? getFrontmatterLines(params.lines).join('\n') : params.lines.join('\n')

const fileVersionsFm = params.name.startsWith('data')
? { ghec: '*', ghes: '*', fpt: '*' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const noteWarningFormatting = {

// Collect content inside legacy notes
if (inLegacyNote) {
noteContent.push({ text: line, lineNumber: lineNumber })
noteContent.push({ text: line, lineNumber })
continue
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function findOutdatedTerminologyMatches(line: string): MatchInfo[] {
start: match.index,
end: match.index + match[0].length,
text: match[0],
replacement: replacement,
outdatedTerm: outdatedTerm,
replacement,
outdatedTerm,
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/content-linter/tests/lint-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ if (ymlToLint.length === 0) {
describe('lint yaml content', () => {
if (ymlToLint.length < 1) return
describe.each(ymlToLint)('%s', (yamlRelPath, yamlAbsPath) => {
let dictionary, isEarlyAccess, fileContents
let dictionary
let isEarlyAccess
let fileContents
// This variable is used to determine if the file was parsed successfully.
// When `yaml.load()` fails to parse the file, it is overwritten with the error message.
// `false` is intentionally chosen since `null` and `undefined` are valid return values.
Expand Down
2 changes: 1 addition & 1 deletion src/content-render/liquid/ifversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const notRegex = /(?:^|\s)not\s/
// native Liquid `if` block tag. It has special handling for statements like {% ifversion ghes < 3.0 %},
// using semver to evaluate release numbers instead of doing standard number comparisons, which
// don't work the way we want because they evaluate 3.2 > 3.10 = true.
export default class extends Tag {
export default class Ifversion extends Tag {
tagToken: TagToken
branches: Branch[]
elseTemplates: Template[]
Expand Down
2 changes: 1 addition & 1 deletion src/content-render/liquid/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Prompt: LiquidTag = {
},

// Render the inner Markdown, wrap in <code>, then append the SVG
render: function* (scope: any): Generator<any, string, unknown> {
*render(scope: any): Generator<any, string, unknown> {
const content = yield this.liquid.renderer.renderTemplates(this.templates, scope)

// build a URL with the prompt text encoded as query parameter
Expand Down
2 changes: 1 addition & 1 deletion src/content-render/liquid/spotlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const Spotlight = {
stream.start()
},

render: function* (scope: Record<string, unknown>): Generator<unknown, unknown, unknown> {
*render(scope: Record<string, unknown>): Generator<unknown, unknown, unknown> {
const output = yield this.liquid!.renderer.renderTemplates(this.templates, scope)

return yield this.liquid!.parseAndRender(template, {
Expand Down
2 changes: 1 addition & 1 deletion src/content-render/liquid/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const Tool = {
},

// scope is a Liquid scope object, Generator yields/returns Liquid template values - no TypeScript definitions available
render: function* (scope: any): Generator<any, any, any> {
*render(scope: any): Generator<any, any, any> {
const output = yield this.liquid.renderer.renderTemplates(this.templates, scope)
return yield this.liquid.parseAndRender(template, {
tagName: this.tagName,
Expand Down
2 changes: 1 addition & 1 deletion src/data-directory/scripts/deleted-features-pr-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
*/

import * as github from '@actions/github'
import github from '@actions/github'
import core from '@actions/core'
import { program } from 'commander'

Expand Down
2 changes: 1 addition & 1 deletion src/data-directory/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('data-directory', () => {
})

test('option: preprocess function', async () => {
const preprocess = function (content: string) {
function preprocess(content: string) {
return content.replace('markdown', 'MARKDOWN')
}
const data = dataDirectory(fixturesDir, { preprocess })
Expand Down
2 changes: 1 addition & 1 deletion src/events/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const sentValidationErrors = new QuickLRU({
// to prevent sending multiple validation errors that can spam requests to Hydro
const getValidationErrorHash = (validateErrors: ErrorObject[]) => {
// limit to 10 second windows
const window: Number = Math.floor(new Date().getTime() / 10000)
const window: number = Math.floor(new Date().getTime() / 10000)
return `${window}:${(validateErrors || [])
.map((error: ErrorObject) => error.message + error.instancePath + JSON.stringify(error.params))
.join(':')}`
Expand Down
4 changes: 2 additions & 2 deletions src/events/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ export type EventPropsByType = {
link_samepage?: boolean
link_container?: string
}
[EventType.page]: {}
[EventType.page]: { type: string } // no unique properties
[EventType.preference]: {
preference_name: string
preference_value: string
}
[EventType.print]: {}
[EventType.print]: { type: string } // no unique properties
[EventType.search]: {
search_query: string
search_context?: string
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/tests/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('annotations', () => {
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
expect(noteTexts).toEqual([
'Configures this workflow to run every time a change is pushed to the branch called release.',
'This job checks out the repository contents ...\n' + "And here's the second comment line.",
"This job checks out the repository contents ...\nAnd here's the second comment line.",
])
}
})
Expand Down
7 changes: 4 additions & 3 deletions src/fixtures/tests/playwright-rendering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ test('open search, and select a general search article', async ({ page }) => {

await page.getByTestId('overlay-search-input').fill('serve playwright')
// Let new suggestions load
await page.waitForTimeout(1000)
const searchOverlay = page.getByTestId('general-autocomplete-suggestions')
await expect(searchOverlay.getByText('For Playwright')).toBeVisible()
// Navigate to general search item, "For Playwright"
await page.keyboard.press('ArrowDown')
// Select the general search item, "For Playwright"
Expand Down Expand Up @@ -747,7 +748,7 @@ test.describe('survey', () => {
await page.evaluate(() => {
Object.defineProperty(document, 'visibilityState', {
configurable: true,
get: function () {
get() {
return 'hidden'
},
})
Expand Down Expand Up @@ -802,7 +803,7 @@ test.describe('survey', () => {
await page.evaluate(() => {
Object.defineProperty(document, 'visibilityState', {
configurable: true,
get: function () {
get() {
return 'hidden'
},
})
Expand Down
Loading
Loading