Skip to content

Commit

Permalink
Prep for ts-node (github#30587)
Browse files Browse the repository at this point in the history
  • Loading branch information
heiskr authored Sep 8, 2022
1 parent 37412ea commit 7523a7c
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions lib/get-applicable-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ function getApplicableVersions(frontmatterVersions, filepath) {
const foundFrontmatterVersions = evaluateVersions(frontmatterVersions)

// Combine them!
const applicableVersions = [
...new Set(foundFrontmatterVersions.versions.concat(foundFeatureVersions.versions)),
]
const applicableVersions = Array.from(
new Set(foundFrontmatterVersions.versions.concat(foundFeatureVersions.versions))
)

if (
!applicableVersions.length &&
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid-tags/octicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
}
},

async render(scope) {
async render() {
// Throw an error if the requested octicon does not exist.
if (!Object.prototype.hasOwnProperty.call(octicons, this.icon)) {
throw new Error(`Octicon ${this.icon} does not exist`)
Expand Down
2 changes: 1 addition & 1 deletion lib/old-versions-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function getNewVersionFromOldVersion(oldVersion) {

// Given an old path like /enterprise/2.21/user/github/category/article,
// return an old version like 2.21.
export function getOldVersionFromOldPath(oldPath, languageCode) {
export function getOldVersionFromOldPath(oldPath) {
// We should never be calling this function on a path that starts with a new version,
// so we can assume the path either uses the old /enterprise format or it's dotcom.
if (!patterns.enterprise.test(oldPath)) return 'dotcom'
Expand Down
2 changes: 1 addition & 1 deletion middleware/anchor-redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const clientSideRestAPIRedirects = readCompressedJsonFileFallbackLazily(
const router = express.Router()

// Returns a client side redirect if one exists for the given path.
router.get('/', function redirects(req, res, next) {
router.get('/', function redirects(req, res) {
if (!req.query.path) {
return res.status(400).send("Missing 'path' query string")
}
Expand Down
8 changes: 4 additions & 4 deletions middleware/api/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const legacyEnterpriseServerVersions = Object.fromEntries(
.filter(([fullName]) => {
return fullName.startsWith('enterprise-server@')
})
.map(([_, shortName]) => {
.map(([, shortName]) => {
return [shortName, `ghes-${shortName}`]
})
)
Expand Down Expand Up @@ -86,7 +86,7 @@ function notConfiguredMiddleware(req, res, next) {
router.get(
'/legacy',
notConfiguredMiddleware,
catchMiddlewareError(async function legacySearch(req, res, next) {
catchMiddlewareError(async function legacySearch(req, res) {
const { query, version, language, filters, limit: limit_ } = req.query
if (filters) {
throw new Error('not implemented yet')
Expand Down Expand Up @@ -233,7 +233,7 @@ router.get(
'/v1',
validationMiddleware,
notConfiguredMiddleware,
catchMiddlewareError(async function search(req, res, next) {
catchMiddlewareError(async function search(req, res) {
const { indexName, query, page, size, debug, sort } = req.search
try {
const { meta, hits } = await getSearchResults({ indexName, query, page, size, debug, sort })
Expand Down Expand Up @@ -277,7 +277,7 @@ router.get(
)

// Alias for the latest version
router.get('/', (req, res, next) => {
router.get('/', (req, res) => {
// At the time of writing, the latest version is v1. (July 2022)
// Use `req.originalUrl` because this router is "self contained"
// which means that `req.url` will be `/` in this context.
Expand Down
2 changes: 1 addition & 1 deletion middleware/build-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cacheControlFactory } from './cache-control.js'
const BUILD_SHA = process.env.BUILD_SHA
const noCacheControl = cacheControlFactory(0)

export default function buildInfo(req, res, next) {
export default function buildInfo(req, res) {
res.type('text/plain')
noCacheControl(res)
if (!BUILD_SHA) {
Expand Down
2 changes: 1 addition & 1 deletion middleware/categories-for-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let globalAllCategoriesCache = null

// This middleware exposes a list of all categories and child articles at /categories.json.
// GitHub Support uses this for internal ZenDesk search functionality.
export default async function categoriesForSupport(req, res, next) {
export default async function categoriesForSupport(req, res) {
const englishSiteTree = req.context.siteTree.en

const allCategories = globalAllCategoriesCache || []
Expand Down
2 changes: 1 addition & 1 deletion middleware/healthz.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const noCacheControl = cacheControlFactory(0)
* instance remains in the pool to handle requests
* For example: if we have a failing database connection we may return a 500 status here.
*/
router.get('/', function healthz(req, res, next) {
router.get('/', function healthz(req, res) {
noCacheControl(res)

res.sendStatus(200)
Expand Down
2 changes: 1 addition & 1 deletion middleware/remote-ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cacheControlFactory } from './cache-control.js'

const noCacheControl = cacheControlFactory(0)

export default function remoteIp(req, res, next) {
export default function remoteIp(req, res) {
noCacheControl(res)
res.json({
ip: req.ip,
Expand Down
2 changes: 1 addition & 1 deletion middleware/render-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function buildMiniTocItems(req) {
return getMiniTocItems(context.renderedPage, page.miniTocMaxHeadingLevel, '')
}

export default async function renderPage(req, res, next) {
export default async function renderPage(req, res) {
const { context } = req

// This is a contextualizing the request so that when this `req` is
Expand Down
2 changes: 1 addition & 1 deletion middleware/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const noCacheControl = cacheControlFactory(0)

router.get(
'/',
catchMiddlewareError(async function getSearch(req, res, next) {
catchMiddlewareError(async function getSearch(req, res) {
const { query, version, language, filters, limit: limit_ } = req.query
const limit = Math.min(parseInt(limit_, 10) || 10, 100)
if (!versions.has(version)) {
Expand Down
2 changes: 1 addition & 1 deletion script/helpers/git-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function getTreeSha(owner, repo, commitSha) {
}

// https://docs.github.com/rest/reference/git#get-a-tree
export async function getTree(owner, repo, ref, allowedPaths = []) {
export async function getTree(owner, repo, ref) {
const commitSha = await getCommitSha(owner, repo, ref)
const treeSha = await getTreeSha(owner, repo, commitSha)
try {
Expand Down
2 changes: 1 addition & 1 deletion script/rendered-content-link-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ function getRetryAfterSleep(headerValue) {
return ms
}

function checkImageSrc(src, $) {
function checkImageSrc(src) {
const pathname = new URL(src, 'http://example.com').pathname
if (!pathname.startsWith('/')) {
return { WARNING: "External images can't not be checked" }
Expand Down
4 changes: 2 additions & 2 deletions tests/routing/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('redirects', () => {

test('are absent from all destination URLs', async () => {
const values = Object.entries(redirects)
.filter(([from_, to]) => !to.includes('://'))
.filter(([, to]) => !to.includes('://'))
.map(([from_]) => from_)
expect(values.length).toBeGreaterThan(100)
expect(values.every((value) => !value.endsWith('/'))).toBe(true)
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('redirects', () => {
describe('external redirects', () => {
test('no external redirect starts with a language prefix', () => {
const values = Object.entries(redirects)
.filter(([from_, to]) => to.includes('://'))
.filter(([, to]) => to.includes('://'))
.map(([from_]) => from_)
.filter((from_) => from_.startsWith('/en/'))
expect(values.length).toBe(0)
Expand Down

0 comments on commit 7523a7c

Please sign in to comment.