Skip to content

Commit ad51577

Browse files
authored
Remove remaining .js in package.json scripts (#57114)
1 parent bb58717 commit ad51577

File tree

9 files changed

+42
-35
lines changed

9 files changed

+42
-35
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"clone-translations": "./src/languages/scripts/clone-translations.sh",
2828
"cmp-files": "tsx src/workflows/cmp-files.ts",
2929
"content-changes-table-comment": "tsx src/workflows/content-changes-table-comment.ts",
30-
"copy-fixture-data": "tsx src/tests/scripts/copy-fixture-data.js",
30+
"copy-fixture-data": "tsx src/tests/scripts/copy-fixture-data.ts",
3131
"count-translation-corruptions": "tsx src/languages/scripts/count-translation-corruptions.ts",
3232
"create-enterprise-issue": "tsx src/ghes-releases/scripts/create-enterprise-issue.ts",
3333
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect src/frame/server.ts",
@@ -58,40 +58,40 @@
5858
"index-test-fixtures": "./src/search/scripts/index-test-fixtures.sh",
5959
"labeler": "tsx .github/actions/labeler/labeler.ts",
6060
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
61-
"lint-content": "tsx src/content-linter/scripts/lint-content.js",
62-
"lint-translation": "vitest src/content-linter/tests/lint-files.js",
61+
"lint-content": "tsx src/content-linter/scripts/lint-content.ts",
62+
"lint-translation": "vitest src/content-linter/tests/lint-files.ts",
6363
"liquid-markdown-tables": "tsx src/tools/scripts/liquid-markdown-tables/index.ts",
6464
"generate-article-api-docs": "tsx src/article-api/scripts/generate-api-docs.ts",
6565
"generate-code-scanning-query-list": "tsx src/code-scanning/scripts/generate-code-scanning-query-list.ts",
6666
"generate-content-linter-docs": "tsx src/content-linter/scripts/generate-docs.ts",
67-
"move-content": "tsx src/content-render/scripts/move-content.js",
68-
"openapi-docs": "tsx src/rest/docs.js",
67+
"move-content": "tsx src/content-render/scripts/move-content.ts",
68+
"openapi-docs": "tsx src/rest/docs.ts",
6969
"playwright-test": "playwright test --config src/fixtures/playwright.config.ts --project=\"Google Chrome\"",
70-
"lint-report": "tsx src/content-linter/scripts/lint-report.js",
70+
"lint-report": "tsx src/content-linter/scripts/lint-report.ts",
7171
"postinstall": "cp package-lock.json .installed.package-lock.json && echo \"Updated .installed.package-lock.json\" # see husky/post-checkout and husky/post-merge",
7272
"precompute-pageinfo": "tsx src/article-api/scripts/precompute-pageinfo.ts",
7373
"prepare": "husky src/workflows/husky",
7474
"prettier": "prettier -w \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"",
7575
"prettier-check": "prettier -c \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"",
7676
"prevent-pushes-to-main": "tsx src/workflows/prevent-pushes-to-main.ts",
7777
"purge-fastly-edge-cache": "tsx src/workflows/purge-fastly-edge-cache.ts",
78-
"purge-fastly-edge-cache-per-language": "tsx src/languages/scripts/purge-fastly-edge-cache-per-language.js",
78+
"purge-fastly-edge-cache-per-language": "tsx src/languages/scripts/purge-fastly-edge-cache-per-language.ts",
7979
"readability-report": "tsx src/workflows/experimental/readability-report.ts",
8080
"ready-for-docs-review": "tsx src/workflows/ready-for-docs-review.ts",
8181
"release-banner": "tsx src/ghes-releases/scripts/release-banner.ts",
8282
"repo-sync": "./src/workflows/local-repo-sync.sh",
8383
"reusables": "tsx src/content-render/scripts/reusables-cli.ts",
8484
"rendered-content-link-checker": "tsx src/links/scripts/rendered-content-link-checker.ts",
8585
"rendered-content-link-checker-cli": "tsx src/links/scripts/rendered-content-link-checker-cli.ts",
86-
"rest-dev": "tsx src/rest/scripts/update-files.js",
86+
"rest-dev": "tsx src/rest/scripts/update-files.ts",
8787
"show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-",
8888
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon src/frame/server.ts",
8989
"start-all-languages": "cross-env NODE_ENV=development tsx src/frame/server.ts",
9090
"start-for-playwright": "cross-env ROOT=src/fixtures/fixtures TRANSLATIONS_FIXTURE_ROOT=src/fixtures/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test tsx src/frame/server.ts",
9191
"symlink-from-local-repo": "tsx src/early-access/scripts/symlink-from-local-repo.ts",
9292
"sync-audit-log": "tsx src/audit-logs/scripts/sync.ts",
93-
"sync-codeql-cli": "tsx src/codeql-cli/scripts/sync.js",
94-
"sync-graphql": "tsx src/graphql/scripts/sync.js",
93+
"sync-codeql-cli": "tsx src/codeql-cli/scripts/sync.ts",
94+
"sync-graphql": "tsx src/graphql/scripts/sync.ts",
9595
"sync-rest": "tsx src/rest/scripts/update-files.ts",
9696
"sync-secret-scanning": "tsx src/secret-scanning/scripts/sync.ts",
9797
"sync-webhooks": "npx tsx src/rest/scripts/update-files.ts -o webhooks",
Lines changed: 2 additions & 2 deletions
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 = {}
32+
const cliMarkdownContents: Record<string, { data: any; content: string }> = {}
3333

3434
for (const file of markdownFiles) {
3535
const sourceContent = await readFile(file, 'utf8')
@@ -83,7 +83,7 @@ async function setupEnvironment() {
8383

8484
// copy the raw rst files to the temp directory and convert them
8585
// to Markdownusing pandoc
86-
async function rstToMarkdown(sourceDirectory) {
86+
async function rstToMarkdown(sourceDirectory: string) {
8787
const sourceFiles = walk(sourceDirectory, {
8888
includeBasePath: true,
8989
globs: ['**/*.rst'],

src/content-linter/scripts/lint-content.js renamed to src/content-linter/scripts/lint-content.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import fs from 'fs'
23
import path from 'path'
34
import { execSync } from 'child_process'
@@ -258,7 +259,7 @@ async function main() {
258259
}
259260

260261
const fixableFiles = Object.entries(formattedResults)
261-
.filter(([_, results]) => results.some((result) => result.fixable))
262+
.filter(([, results]) => results.some((result) => result.fixable))
262263
.map(([file]) => file)
263264
if (fixableFiles.length) {
264265
console.log('') // Just for some whitespace before the next message
@@ -692,7 +693,7 @@ function isOptionsValid() {
692693
for (const path of paths) {
693694
try {
694695
fs.statSync(path)
695-
} catch (err) {
696+
} catch {
696697
if ('paths'.includes(path)) {
697698
console.log('error: did you mean --paths')
698699
} else {
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import { reportingConfig } from '@/content-linter/style/github-docs'
1010
// GitHub issue body size limit is ~65k characters, so we'll use 60k as a safe limit
1111
const MAX_ISSUE_BODY_SIZE = 60000
1212

13+
interface LintFlaw {
14+
severity: string
15+
ruleNames: string[]
16+
}
17+
1318
/**
1419
* Determines if a lint result should be included in the automated report
15-
* @param {Object} flaw - The lint result object
16-
* @param {string} flaw.severity - 'error' or 'warning'
17-
* @param {string[]} flaw.ruleNames - Array of rule names for this flaw
18-
* @returns {boolean} - True if this flaw should be included in the report
1920
*/
20-
function shouldIncludeInReport(flaw) {
21+
function shouldIncludeInReport(flaw: LintFlaw): boolean {
2122
if (!flaw.ruleNames || !Array.isArray(flaw.ruleNames)) {
2223
return false
2324
}
2425

2526
// Check if any rule name is in the exclude list
26-
const hasExcludedRule = flaw.ruleNames.some((ruleName) =>
27+
const hasExcludedRule = flaw.ruleNames.some((ruleName: string) =>
2728
reportingConfig.excludeRules.includes(ruleName),
2829
)
2930
if (hasExcludedRule) {
@@ -36,7 +37,7 @@ function shouldIncludeInReport(flaw) {
3637
}
3738

3839
// Check if any rule name is in the include list
39-
const hasIncludedRule = flaw.ruleNames.some((ruleName) =>
40+
const hasIncludedRule = flaw.ruleNames.some((ruleName: string) =>
4041
reportingConfig.includeRules.includes(ruleName),
4142
)
4243
if (hasIncludedRule) {
@@ -88,9 +89,9 @@ async function main() {
8889
const parsedResults = JSON.parse(lintResults)
8990

9091
// Filter results based on reporting configuration
91-
const filteredResults = {}
92+
const filteredResults: Record<string, LintFlaw[]> = {}
9293
for (const [file, flaws] of Object.entries(parsedResults)) {
93-
const filteredFlaws = flaws.filter(shouldIncludeInReport)
94+
const filteredFlaws = (flaws as LintFlaw[]).filter(shouldIncludeInReport)
9495

9596
// Only include files that have remaining flaws after filtering
9697
if (filteredFlaws.length > 0) {
@@ -127,8 +128,8 @@ async function main() {
127128
octokit,
128129
reportTitle: `Content linting issues requiring attention`,
129130
reportBody,
130-
reportRepository: REPORT_REPOSITORY,
131-
reportLabel: REPORT_LABEL,
131+
reportRepository: REPORT_REPOSITORY!,
132+
reportLabel: REPORT_LABEL!,
132133
}
133134

134135
await createReportIssue(reportProps)
@@ -137,9 +138,9 @@ async function main() {
137138
core,
138139
octokit,
139140
newReport: await createReportIssue(reportProps),
140-
reportRepository: REPORT_REPOSITORY,
141-
reportAuthor: REPORT_AUTHOR,
142-
reportLabel: REPORT_LABEL,
141+
reportRepository: REPORT_REPOSITORY!,
142+
reportAuthor: REPORT_AUTHOR!,
143+
reportLabel: REPORT_LABEL!,
143144
}
144145

145146
await linkReports(linkProps)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import { fileURLToPath } from 'url'
23
import path from 'path'
34
import yaml from 'js-yaml'

src/content-render/scripts/move-content.js renamed to src/content-render/scripts/move-content.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
// [start-readme]
23
//
34
// Use this script to help you move or rename a single file or a folder. The script will move or rename the file or folder for you, update relevant `children` in the index.md file(s), and add a `redirect_from` to frontmatter in the renamed file(s). Note: You will still need to manually update the `title` if necessary.
@@ -507,7 +508,7 @@ function editFiles(files, updateParent, opts) {
507508

508509
// Add contentType frontmatter to moved files
509510
if (files.length > 0) {
510-
const filePaths = files.map(([oldPath, newPath, oldHref, newHref]) => newPath)
511+
const filePaths = files.map(([, newPath]) => newPath)
511512
try {
512513
const cmd = ['run', 'add-content-type', '--', '--paths', ...filePaths]
513514
const result = execFileSync('npm', cmd, { cwd: process.cwd(), encoding: 'utf8' })
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import fs from 'fs/promises'
23
import { appendFileSync } from 'fs'
34
import path from 'path'

src/rest/docs.js renamed to src/rest/docs.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { readFile } from 'fs/promises'
33
import { allVersions } from '@/versions/lib/all-versions'
44

55
// Translate the docs versioning nomenclature back to the OpenAPI names
6-
const invertedVersionMapping = JSON.parse(await readFile('src/rest/lib/config.json')).versionMapping
7-
const versionMapping = {}
6+
const invertedVersionMapping = JSON.parse(
7+
await readFile('src/rest/lib/config.json', 'utf8'),
8+
).versionMapping
9+
const versionMapping: Record<string, string> = {}
810
Object.assign(
911
versionMapping,
10-
...Object.entries(invertedVersionMapping).map(([a, b]) => ({ [b]: a })),
12+
...Object.entries(invertedVersionMapping).map(([a, b]) => ({ [b as string]: a })),
1113
)
1214
const openApiVersions = Object.values(allVersions)
1315
.map((version) => version.openApiVersionName)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ program
3737

3838
main(program.opts())
3939

40-
async function main(opts) {
40+
async function main(opts: { check?: boolean; dryRun?: boolean; verbose?: boolean }) {
4141
let errors = 0
4242
for (const file of MANDATORY_FILES) {
4343
const source = fs.readFileSync(file, 'utf-8')
@@ -54,7 +54,7 @@ async function main(opts) {
5454
} else if (opts.verbose) {
5555
console.log(`The file ${chalk.green(destination)} is up-to-date 🥰`)
5656
}
57-
} catch (error) {
57+
} catch (error: any) {
5858
if (error.code === 'ENOENT') {
5959
console.warn(`The file ${chalk.red(destination)} does not exist`)
6060
errors++
@@ -71,7 +71,7 @@ async function main(opts) {
7171
}
7272
continue
7373
}
74-
} catch (error) {
74+
} catch (error: any) {
7575
if (error.code !== 'ENOENT') throw error
7676
}
7777
if (!opts.dryRun) {

0 commit comments

Comments
 (0)