Skip to content

Commit b29e373

Browse files
authored
Remove import x statements (github#20594)
* Clear out most import x * Update rimraf use * Move up readme blocks in scripts
1 parent 1ed18e1 commit b29e373

84 files changed

Lines changed: 551 additions & 524 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/create-tree.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { fileURLToPath } from 'url'
22
import path from 'path'
3-
import xFs from 'fs'
3+
import fs from 'fs/promises'
44
import Page from './page.js'
55
const __dirname = path.dirname(fileURLToPath(import.meta.url))
6-
const fs = xFs.promises
76

87
export default async function createTree(originalPath, langObj) {
98
// This basePath definition is needed both here and in lib/page-data.js because this

lib/render-content/create-processor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import slug from 'rehype-slug'
99
import autolinkHeadings from 'rehype-autolink-headings'
1010
import highlight from 'rehype-highlight'
1111
import html from 'rehype-stringify'
12-
import xHighlightjsGraphql from 'highlightjs-graphql'
12+
import HighlightjsGraphql from 'highlightjs-graphql'
1313
import remarkCodeExtra from 'remark-code-extra'
1414
import codeHeader from './plugins/code-header.js'
1515
import rewriteLocalLinks from './plugins/rewrite-local-links.js'
1616
import useEnglishHeadings from './plugins/use-english-headings.js'
1717
import rewriteLegacyAssetPaths from './plugins/rewrite-legacy-asset-paths.js'
1818
import wrapInElement from './plugins/wrap-in-element.js'
19-
const graphql = xHighlightjsGraphql.definer
19+
const graphql = HighlightjsGraphql.definer
2020

2121
export default function createProcessor(context) {
2222
return unified()

lib/render-content/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import GithubSlugger from 'github-slugger'
22
import renderContent from './renderContent.js'
33
import { ExtendedMarkdown, tags } from '../liquid-tags/extended-markdown.js'
4-
import xLink from '../liquid-tags/link.js'
5-
import xLinkWithIntro from '../liquid-tags/link-with-intro.js'
6-
import xLinkInList from '../liquid-tags/link-in-list.js'
7-
import xTopicLinkInList from '../liquid-tags/topic-link-in-list.js'
8-
import xIndentedDataReference from '../liquid-tags/indented-data-reference.js'
9-
import xData from '../liquid-tags/data.js'
10-
import xOcticon from '../liquid-tags/octicon.js'
11-
import xLinkAsArticleCard from '../liquid-tags/link-as-article-card.js'
12-
import xIfversion from '../liquid-tags/ifversion.js'
4+
import Link from '../liquid-tags/link.js'
5+
import LinkWithIntro from '../liquid-tags/link-with-intro.js'
6+
import LinkInList from '../liquid-tags/link-in-list.js'
7+
import TopicLinkInList from '../liquid-tags/topic-link-in-list.js'
8+
import IndentedDataReference from '../liquid-tags/indented-data-reference.js'
9+
import Data from '../liquid-tags/data.js'
10+
import Octicon from '../liquid-tags/octicon.js'
11+
import LinkAsArticleCard from '../liquid-tags/link-as-article-card.js'
12+
import Ifversion from '../liquid-tags/ifversion.js'
1313

1414
// Include custom tags like {% link_with_intro /article/foo %}
15-
renderContent.liquid.registerTag('link', xLink('link'))
16-
renderContent.liquid.registerTag('link_with_intro', xLinkWithIntro)
17-
renderContent.liquid.registerTag('link_in_list', xLinkInList)
18-
renderContent.liquid.registerTag('topic_link_in_list', xTopicLinkInList)
19-
renderContent.liquid.registerTag('indented_data_reference', xIndentedDataReference)
20-
renderContent.liquid.registerTag('data', xData)
21-
renderContent.liquid.registerTag('octicon', xOcticon)
22-
renderContent.liquid.registerTag('link_as_article_card', xLinkAsArticleCard)
23-
renderContent.liquid.registerTag('ifversion', xIfversion)
15+
renderContent.liquid.registerTag('link', Link('link'))
16+
renderContent.liquid.registerTag('link_with_intro', LinkWithIntro)
17+
renderContent.liquid.registerTag('link_in_list', LinkInList)
18+
renderContent.liquid.registerTag('topic_link_in_list', TopicLinkInList)
19+
renderContent.liquid.registerTag('indented_data_reference', IndentedDataReference)
20+
renderContent.liquid.registerTag('data', Data)
21+
renderContent.liquid.registerTag('octicon', Octicon)
22+
renderContent.liquid.registerTag('link_as_article_card', LinkAsArticleCard)
23+
renderContent.liquid.registerTag('ifversion', Ifversion)
2424

2525
for (const tag in tags) {
2626
// Register all the extended markdown tags, like {% note %} and {% warning %}

lib/render-content/plugins/use-english-headings.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import GithubSlugger from 'github-slugger'
2-
import xHtmlEntities from 'html-entities'
2+
import HtmlEntities from 'html-entities'
33
import toString from 'hast-util-to-string'
44
import { visit } from 'unist-util-visit'
5-
const Entities = xHtmlEntities.XmlEntities
65
const slugger = new GithubSlugger()
7-
const entities = new Entities()
6+
const entities = new HtmlEntities.XmlEntities()
87

98
const matcher = (node) => node.type === 'element' && ['h2', 'h3', 'h4'].includes(node.tagName)
109

lib/render-content/renderContent.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import liquid from './liquid.js'
22
import cheerio from 'cheerio'
3-
import xHtmlEntities from 'html-entities'
3+
import HtmlEntities from 'html-entities'
44
import stripHtmlComments from 'strip-html-comments'
55
import createProcessor from './create-processor.js'
6-
const Entities = xHtmlEntities.XmlEntities
7-
const entities = new Entities()
6+
const entities = new HtmlEntities.XmlEntities()
87

98
// used below to remove extra newlines in TOC lists
109
const endLine = '</a>\r?\n'

lib/search/lunr-search.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { fileURLToPath } from 'url'
22
import path from 'path'
33
import lunr from 'lunr'
4-
import xLunrStemmerSupport from 'lunr-languages/lunr.stemmer.support.js'
5-
import xTinyseg from 'lunr-languages/tinyseg.js'
6-
import xLunrJa from 'lunr-languages/lunr.ja.js'
7-
import xLunrEs from 'lunr-languages/lunr.es.js'
8-
import xLunrPt from 'lunr-languages/lunr.pt.js'
9-
import xLunrDe from 'lunr-languages/lunr.de.js'
4+
import lunrStemmerSupport from 'lunr-languages/lunr.stemmer.support.js'
5+
import tinyseg from 'lunr-languages/tinyseg.js'
6+
import lunrJa from 'lunr-languages/lunr.ja.js'
7+
import lunrEs from 'lunr-languages/lunr.es.js'
8+
import lunrPt from 'lunr-languages/lunr.pt.js'
9+
import lunrDe from 'lunr-languages/lunr.de.js'
1010
import { get } from 'lodash-es'
1111
import readFileAsync from '../readfile-async.js'
1212
import { namePrefix } from './config.js'
1313
import { decompress } from './compress.js'
1414
const __dirname = path.dirname(fileURLToPath(import.meta.url))
15-
xLunrStemmerSupport(lunr)
16-
xTinyseg(lunr)
17-
xLunrJa(lunr)
18-
xLunrEs(lunr)
19-
xLunrPt(lunr)
20-
xLunrDe(lunr)
15+
lunrStemmerSupport(lunr)
16+
tinyseg(lunr)
17+
lunrJa(lunr)
18+
lunrEs(lunr)
19+
lunrPt(lunr)
20+
lunrDe(lunr)
2121

2222
const LUNR_DIR = './indexes'
2323
const lunrIndexes = new Map()

lib/use-english-headings.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import GithubSlugger from 'github-slugger'
2-
import xHtmlEntities from 'html-entities'
2+
import HtmlEntities from 'html-entities'
33
const slugger = new GithubSlugger()
4-
const Entities = xHtmlEntities.XmlEntities
5-
const entities = new Entities()
4+
const entities = new HtmlEntities.XmlEntities()
65

76
// replace translated IDs and links in headings with English
87
export default function useEnglishHeadings($, englishHeadings) {

middleware/context.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import languages from '../lib/languages.js'
22
import enterpriseServerReleases from '../lib/enterprise-server-releases.js'
33
import { allVersions } from '../lib/all-versions.js'
44
import { productMap } from '../lib/all-products.js'
5-
import xPathUtils from '../lib/path-utils.js'
5+
import pathUtils from '../lib/path-utils.js'
66
import productNames from '../lib/product-names.js'
77
import warmServer from '../lib/warm-server.js'
88
import readJsonFile from '../lib/read-json-file.js'
@@ -16,7 +16,7 @@ const {
1616
getProductStringFromPath,
1717
getCategoryStringFromPath,
1818
getPathWithoutLanguage,
19-
} = xPathUtils
19+
} = pathUtils
2020
const featureFlags = Object.keys(readJsonFile('./feature-flags.json'))
2121

2222
// Supply all route handlers with a baseline `req.context` object

middleware/cookie-parser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import xCookieParser from 'cookie-parser'
2-
import xCookieSettings from '../lib/cookie-settings.js'
3-
export default xCookieParser(process.env.COOKIE_SECRET, xCookieSettings)
1+
import cookieParser from 'cookie-parser'
2+
import cookieSettings from '../lib/cookie-settings.js'
3+
export default cookieParser(process.env.COOKIE_SECRET, cookieSettings)

middleware/cors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import xCors from 'cors'
2-
export default xCors({
1+
import cors from 'cors'
2+
export default cors({
33
origin: '*',
44
methods: ['GET', 'HEAD'],
55
})

0 commit comments

Comments
 (0)