!item.unlisted);
+ : MetadataBlog.filter((item) => !item.unlisted);
class BlogSidebar extends React.Component {
render() {
@@ -33,7 +33,7 @@ class BlogSidebar extends React.Component {
{
type: 'CATEGORY',
title: blogSidebarTitle,
- children: MetadataPublicBlog.slice(0, blogSidebarCount).map(item => ({
+ children: MetadataPublicBlog.slice(0, blogSidebarCount).map((item) => ({
type: 'LINK',
item,
})),
diff --git a/packages/docusaurus-1.x/lib/core/Doc.js b/packages/docusaurus-1.x/lib/core/Doc.js
index 91b2458731..94507fddfe 100644
--- a/packages/docusaurus-1.x/lib/core/Doc.js
+++ b/packages/docusaurus-1.x/lib/core/Doc.js
@@ -27,7 +27,7 @@ const splitTabsToTitleAndContent = (lines, indents) => {
let current = {
content: [],
};
- lines.forEach(line => {
+ lines.forEach((line) => {
if (indents) {
line = line.replace(new RegExp(`^((\\t|\\s{4}){${indents}})`, 'g'), '');
}
@@ -135,7 +135,7 @@ const cleanTheCodeTag = (content, indents) => {
};
const contents = content.split(/()(.*?)(<\/pre>)/gms);
let inCodeBlock = false;
- const cleanContents = contents.map(c => {
+ const cleanContents = contents.map((c) => {
if (c === '') {
inCodeBlock = true;
return c;
@@ -159,8 +159,8 @@ class Doc extends React.Component {
let indents = 0;
return content.replace(
/(\t|\s{4})*?(\n)(.*?)((\n|\t|\s{4}))/gms,
- m => {
- const contents = m.split('\n').filter(c => {
+ (m) => {
+ const contents = m.split('\n').filter((c) => {
if (!indents) {
indents = (
c.match(/((\t|\s{4})+)/) || []
diff --git a/packages/docusaurus-1.x/lib/core/Head.js b/packages/docusaurus-1.x/lib/core/Head.js
index e31f694772..605f95787b 100644
--- a/packages/docusaurus-1.x/lib/core/Head.js
+++ b/packages/docusaurus-1.x/lib/core/Head.js
@@ -11,7 +11,7 @@ const React = require('react');
class Head extends React.Component {
render() {
const links = this.props.config.headerLinks;
- const hasBlog = links.some(link => link.blog);
+ const hasBlog = links.some((link) => link.blog);
const highlight = {
version: '9.12.0',
@@ -130,7 +130,7 @@ class Head extends React.Component {
{/* External resources */}
{this.props.config.stylesheets &&
- this.props.config.stylesheets.map(source =>
+ this.props.config.stylesheets.map((source) =>
source.href ? (
) : (
@@ -138,7 +138,7 @@ class Head extends React.Component {
),
)}
{this.props.config.scripts &&
- this.props.config.scripts.map(source =>
+ this.props.config.scripts.map((source) =>
source.src ? (
) : (
diff --git a/packages/docusaurus-1.x/lib/core/Remarkable.js b/packages/docusaurus-1.x/lib/core/Remarkable.js
index d777ecf5aa..ce65f29cec 100644
--- a/packages/docusaurus-1.x/lib/core/Remarkable.js
+++ b/packages/docusaurus-1.x/lib/core/Remarkable.js
@@ -20,7 +20,7 @@ class Remarkable extends React.Component {
);
}
- return React.Children.map(this.props.children, child => {
+ return React.Children.map(this.props.children, (child) => {
if (typeof child === 'string') {
return (
diff --git a/packages/docusaurus-1.x/lib/core/Site.js b/packages/docusaurus-1.x/lib/core/Site.js
index 8bbceaece1..0d1ee85dca 100644
--- a/packages/docusaurus-1.x/lib/core/Site.js
+++ b/packages/docusaurus-1.x/lib/core/Site.js
@@ -26,7 +26,7 @@ class Site extends React.Component {
const hasLanguageDropdown =
env.translation.enabled && env.translation.enabledLanguages().length > 1;
const hasOrdinaryHeaderLinks = headerLinks.some(
- link => !(link.languages || link.search),
+ (link) => !(link.languages || link.search),
);
return !(hasLanguageDropdown || hasOrdinaryHeaderLinks);
}
diff --git a/packages/docusaurus-1.x/lib/core/__tests__/utils.test.js b/packages/docusaurus-1.x/lib/core/__tests__/utils.test.js
index d8d49176fd..c517c0392d 100644
--- a/packages/docusaurus-1.x/lib/core/__tests__/utils.test.js
+++ b/packages/docusaurus-1.x/lib/core/__tests__/utils.test.js
@@ -49,7 +49,7 @@ describe('utils', () => {
expect(utils.getPath(null, false)).toBeNull();
// transform to pretty/clean path
- const cleanPath = pathStr => utils.getPath(pathStr, true);
+ const cleanPath = (pathStr) => utils.getPath(pathStr, true);
expect(cleanPath('/en/users')).toBe('/en/users');
expect(cleanPath('/docs/versioning.html')).toBe('/docs/versioning');
expect(cleanPath('/en/users.html')).toBe('/en/users');
@@ -168,7 +168,7 @@ describe('utils', () => {
});
expect(utils.idx(env, ['translation', 'enabled'])).toEqual(true);
expect(
- utils.idx(env, ['translation', variable]).map(lang => lang.tag),
+ utils.idx(env, ['translation', variable]).map((lang) => lang.tag),
).toEqual(['en', 'ja']);
expect(utils.idx(undefined)).toBeUndefined();
expect(utils.idx(null)).toBeNull();
diff --git a/packages/docusaurus-1.x/lib/core/anchors.js b/packages/docusaurus-1.x/lib/core/anchors.js
index b20094d4c1..138724df8b 100644
--- a/packages/docusaurus-1.x/lib/core/anchors.js
+++ b/packages/docusaurus-1.x/lib/core/anchors.js
@@ -14,7 +14,7 @@ const toSlug = require('./toSlug');
function anchors(md) {
const originalRender = md.renderer.rules.heading_open;
- md.renderer.rules.heading_open = function(tokens, idx, options, env) {
+ md.renderer.rules.heading_open = function (tokens, idx, options, env) {
if (!env.slugger) {
env.slugger = new GithubSlugger();
}
diff --git a/packages/docusaurus-1.x/lib/core/nav/HeaderNav.js b/packages/docusaurus-1.x/lib/core/nav/HeaderNav.js
index 790fea0f03..4075b877fd 100644
--- a/packages/docusaurus-1.x/lib/core/nav/HeaderNav.js
+++ b/packages/docusaurus-1.x/lib/core/nav/HeaderNav.js
@@ -39,8 +39,8 @@ class LanguageDropDown extends React.Component {
// add all enabled languages to dropdown
const enabledLanguages = env.translation
.enabledLanguages()
- .filter(lang => lang.tag !== this.props.language)
- .map(lang => {
+ .filter((lang) => lang.tag !== this.props.language)
+ .map((lang) => {
// build the href so that we try to stay in current url but change the language.
let href = siteConfig.baseUrl + lang.tag;
if (
@@ -71,8 +71,8 @@ class LanguageDropDown extends React.Component {
// Get the current language full name for display in the header nav
const currentLanguage = env.translation
.enabledLanguages()
- .filter(lang => lang.tag === this.props.language)
- .map(lang => lang.name);
+ .filter((lang) => lang.tag === this.props.language)
+ .map((lang) => lang.name);
// add Crowdin project recruiting link
if (siteConfig.translationRecruitingLink) {
@@ -179,10 +179,10 @@ class HeaderNav extends React.Component {
errorStr +=
' It looks like there is no document with that id that exists in your docs directory. Please double check the spelling of your `doc` field and the `id` fields of your docs.';
} else {
- errorStr += `${'. Check the spelling of your `doc` field. If that seems sane, and a document in your docs folder exists with that `id` value, \nthen this is likely a bug in Docusaurus.' +
- ' Docusaurus thinks one or both of translations (currently set to: '}${
- env.translation.enabled
- }) or versioning (currently set to: ${
+ errorStr += `${
+ '. Check the spelling of your `doc` field. If that seems sane, and a document in your docs folder exists with that `id` value, \nthen this is likely a bug in Docusaurus.' +
+ ' Docusaurus thinks one or both of translations (currently set to: '
+ }${env.translation.enabled}) or versioning (currently set to: ${
env.versioning.enabled
}) is enabled when maybe they should not be. \nThus my internal id for this doc is: '${id}'. Please file an issue for this possible bug on GitHub.`;
}
@@ -236,7 +236,7 @@ class HeaderNav extends React.Component {
const headerLinks = this.props.config.headerLinks;
// add language drop down to end if location not specified
let languages = false;
- headerLinks.forEach(link => {
+ headerLinks.forEach((link) => {
if (link.languages) {
languages = true;
}
@@ -245,7 +245,7 @@ class HeaderNav extends React.Component {
headerLinks.push({languages: true});
}
let search = false;
- headerLinks.forEach(link => {
+ headerLinks.forEach((link) => {
if (
link.doc &&
!fs.existsSync(`${CWD}/../${readMetadata.getDocsPath()}/`)
diff --git a/packages/docusaurus-1.x/lib/core/nav/OnPageNav.js b/packages/docusaurus-1.x/lib/core/nav/OnPageNav.js
index 34f85cf8e4..d3562b55a2 100644
--- a/packages/docusaurus-1.x/lib/core/nav/OnPageNav.js
+++ b/packages/docusaurus-1.x/lib/core/nav/OnPageNav.js
@@ -23,7 +23,7 @@ const Headings = ({headings}) => {
if (!headings.length) return null;
return (
- {headings.map(heading => (
+ {headings.map((heading) => (
-
diff --git a/packages/docusaurus-1.x/lib/core/nav/SideNav.js b/packages/docusaurus-1.x/lib/core/nav/SideNav.js
index 24c7132f6e..ac85b37323 100644
--- a/packages/docusaurus-1.x/lib/core/nav/SideNav.js
+++ b/packages/docusaurus-1.x/lib/core/nav/SideNav.js
@@ -61,7 +61,7 @@ class SideNav extends React.Component {
return null;
}
- renderCategory = categoryItem => {
+ renderCategory = (categoryItem) => {
let ulClassName = '';
let categoryClassName = 'navGroupCategoryTitle';
let arrow;
@@ -89,7 +89,7 @@ class SideNav extends React.Component {
{arrow}
- {categoryItem.children.map(item => {
+ {categoryItem.children.map((item) => {
switch (item.type) {
case 'LINK':
return this.renderItemLink(item);
@@ -104,7 +104,7 @@ class SideNav extends React.Component {
);
};
- renderSubcategory = subcategoryItem => (
+ renderSubcategory = (subcategoryItem) => (
{this.getLocalizedCategoryString(subcategoryItem.title)}
@@ -113,7 +113,7 @@ class SideNav extends React.Component {
);
- renderItemLink = linkItem => {
+ renderItemLink = (linkItem) => {
const linkMetadata = linkItem.item;
const itemClasses = classNames('navListItem', {
navListItemActive: linkMetadata.id === this.props.current.id,
diff --git a/packages/docusaurus-1.x/lib/core/renderMarkdown.js b/packages/docusaurus-1.x/lib/core/renderMarkdown.js
index 61ce2d5d95..6727685956 100644
--- a/packages/docusaurus-1.x/lib/core/renderMarkdown.js
+++ b/packages/docusaurus-1.x/lib/core/renderMarkdown.js
@@ -109,7 +109,7 @@ class MarkdownRenderer {
// Allow client sites to register their own plugins
if (siteConfig.markdownPlugins) {
- siteConfig.markdownPlugins.forEach(plugin => {
+ siteConfig.markdownPlugins.forEach((plugin) => {
md.use(plugin);
});
}
@@ -128,4 +128,4 @@ class MarkdownRenderer {
const renderMarkdown = new MarkdownRenderer();
-module.exports = source => renderMarkdown.toHtml(source);
+module.exports = (source) => renderMarkdown.toHtml(source);
diff --git a/packages/docusaurus-1.x/lib/core/toc.js b/packages/docusaurus-1.x/lib/core/toc.js
index bfb6bd239a..9f07cb0ef0 100644
--- a/packages/docusaurus-1.x/lib/core/toc.js
+++ b/packages/docusaurus-1.x/lib/core/toc.js
@@ -20,7 +20,7 @@ const tocRegex = new RegExp('', 'i');
*
*/
function getTOC(content, headingTags = 'h2', subHeadingTags = 'h3') {
- const tagToLevel = tag => Number(tag.slice(1));
+ const tagToLevel = (tag) => Number(tag.slice(1));
const headingLevels = [].concat(headingTags).map(tagToLevel);
const subHeadingLevels = subHeadingTags
? [].concat(subHeadingTags).map(tagToLevel)
@@ -35,7 +35,7 @@ function getTOC(content, headingTags = 'h2', subHeadingTags = 'h3') {
const slugger = new GithubSlugger();
let current;
- headings.forEach(heading => {
+ headings.forEach((heading) => {
const rawContent = heading.content;
const rendered = md.renderInline(rawContent);
@@ -68,8 +68,8 @@ function insertTOC(rawContent) {
const filterRe = /^`[^`]*`/;
const headers = getTOC(rawContent, 'h3', null);
const tableOfContents = headers
- .filter(header => filterRe.test(header.rawContent))
- .map(header => ` - [${header.rawContent}](#${header.hashLink})`)
+ .filter((header) => filterRe.test(header.rawContent))
+ .map((header) => ` - [${header.rawContent}](#${header.hashLink})`)
.join('\n');
return rawContent.replace(tocRegex, tableOfContents);
}
diff --git a/packages/docusaurus-1.x/lib/publish-gh-pages.js b/packages/docusaurus-1.x/lib/publish-gh-pages.js
index b919b30fe8..221f1a9fa6 100755
--- a/packages/docusaurus-1.x/lib/publish-gh-pages.js
+++ b/packages/docusaurus-1.x/lib/publish-gh-pages.js
@@ -154,7 +154,7 @@ const excludePath = `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`;
fs.copy(
fromPath,
toPath,
- src => {
+ (src) => {
if (src.indexOf('.DS_Store') !== -1) {
return false;
}
@@ -164,7 +164,7 @@ fs.copy(
return true;
},
- error => {
+ (error) => {
if (error) {
shell.echo(`Error: Copying build assets failed with error '${error}'`);
shell.exit(1);
diff --git a/packages/docusaurus-1.x/lib/rename-version.js b/packages/docusaurus-1.x/lib/rename-version.js
index cec1f4663e..1ea14c7133 100755
--- a/packages/docusaurus-1.x/lib/rename-version.js
+++ b/packages/docusaurus-1.x/lib/rename-version.js
@@ -21,7 +21,7 @@ const CWD = process.cwd();
// generate a doc header from metadata
function makeHeader(metadata) {
let header = '---\n';
- Object.keys(metadata).forEach(key => {
+ Object.keys(metadata).forEach((key) => {
header += `${key}: ${metadata[key]}\n`;
});
header += '---\n';
@@ -91,7 +91,7 @@ if (fs.existsSync(`${CWD}/versioned_docs/version-${currentVersion}`)) {
);
const files = glob.sync(`${CWD}/versioned_docs/version-${newVersion}/*`);
- files.forEach(file => {
+ files.forEach((file) => {
const extension = path.extname(file);
if (extension !== '.md' && extension !== '.markdown') {
return;
diff --git a/packages/docusaurus-1.x/lib/server/__tests__/docs.test.js b/packages/docusaurus-1.x/lib/server/__tests__/docs.test.js
index bbf8702a11..80d7a51261 100644
--- a/packages/docusaurus-1.x/lib/server/__tests__/docs.test.js
+++ b/packages/docusaurus-1.x/lib/server/__tests__/docs.test.js
@@ -145,7 +145,7 @@ describe('getFile', () => {
'docs/doc1.md': 'Just another document',
};
fs.existsSync = jest.fn().mockReturnValue(true);
- fs.readFileSync = jest.fn().mockImplementation(file => {
+ fs.readFileSync = jest.fn().mockImplementation((file) => {
const fakePath = file.replace(
process.cwd().replace(/website-1.x\/?$/, ''),
'',
diff --git a/packages/docusaurus-1.x/lib/server/config.js b/packages/docusaurus-1.x/lib/server/config.js
index ca0c7ac8b1..26c48d2a2d 100644
--- a/packages/docusaurus-1.x/lib/server/config.js
+++ b/packages/docusaurus-1.x/lib/server/config.js
@@ -21,7 +21,7 @@ module.exports = function loadConfig(configPath, deleteCache = true) {
customDocsPath: 'docs',
docsUrl: 'docs',
};
- Object.keys(defaultConfig).forEach(field => {
+ Object.keys(defaultConfig).forEach((field) => {
if (!(field in config)) {
config[field] = defaultConfig[field];
}
diff --git a/packages/docusaurus-1.x/lib/server/docs.js b/packages/docusaurus-1.x/lib/server/docs.js
index 7ca9a642cc..b7145113f2 100644
--- a/packages/docusaurus-1.x/lib/server/docs.js
+++ b/packages/docusaurus-1.x/lib/server/docs.js
@@ -54,7 +54,7 @@ function mdToHtmlify(oldContent, mdToHtml, metadata, siteConfig) {
let content = oldContent;
/* Replace internal markdown linking (except in fenced blocks) */
let fencedBlock = false;
- const lines = content.split('\n').map(line => {
+ const lines = content.split('\n').map((line) => {
if (line.trim().startsWith('```')) {
fencedBlock = !fencedBlock;
}
diff --git a/packages/docusaurus-1.x/lib/server/env.js b/packages/docusaurus-1.x/lib/server/env.js
index 7e2a684337..0bd32730da 100644
--- a/packages/docusaurus-1.x/lib/server/env.js
+++ b/packages/docusaurus-1.x/lib/server/env.js
@@ -32,7 +32,7 @@ class Translation {
this.load();
}
- enabledLanguages = () => this.languages.filter(lang => lang.enabled);
+ enabledLanguages = () => this.languages.filter((lang) => lang.enabled);
load() {
if (fs.existsSync(languagesFile)) {
diff --git a/packages/docusaurus-1.x/lib/server/feed.js b/packages/docusaurus-1.x/lib/server/feed.js
index 2add6cf352..c3df59dc30 100644
--- a/packages/docusaurus-1.x/lib/server/feed.js
+++ b/packages/docusaurus-1.x/lib/server/feed.js
@@ -21,7 +21,7 @@ const utils = require('../core/utils');
const renderMarkdown = require('../core/renderMarkdown.js');
-module.exports = function(type) {
+module.exports = function (type) {
console.log('feed.js triggered...');
type = type || 'rss';
@@ -31,7 +31,7 @@ module.exports = function(type) {
const MetadataPublicBlog =
process.env.NODE_ENV === 'development'
? MetadataBlog
- : MetadataBlog.filter(item => !item.unlisted);
+ : MetadataBlog.filter((item) => !item.unlisted);
const feed = new Feed({
title: `${siteConfig.title} Blog`,
@@ -43,7 +43,7 @@ module.exports = function(type) {
updated: new Date(MetadataPublicBlog[0].date),
});
- MetadataPublicBlog.forEach(post => {
+ MetadataPublicBlog.forEach((post) => {
const url = `${blogRootURL}/${post.path}`;
const description = utils.blogPostHasTruncateMarker(post.content)
? renderMarkdown(utils.extractBlogPostBeforeTruncate(post.content))
diff --git a/packages/docusaurus-1.x/lib/server/generate.js b/packages/docusaurus-1.x/lib/server/generate.js
index 3ee4a00e4c..873a0c7cb0 100644
--- a/packages/docusaurus-1.x/lib/server/generate.js
+++ b/packages/docusaurus-1.x/lib/server/generate.js
@@ -72,7 +72,7 @@ async function execute() {
// create html files for all docs by going through all doc ids
const mdToHtml = metadataUtils.mdToHtml(Metadata, siteConfig);
- Object.keys(Metadata).forEach(id => {
+ Object.keys(Metadata).forEach((id) => {
const metadata = Metadata[id];
const file = docs.getFile(metadata);
if (!file) {
@@ -118,7 +118,7 @@ async function execute() {
files
.sort()
.reverse()
- .forEach(file => {
+ .forEach((file) => {
// Why normalize? In case we are on Windows.
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
const normalizedFile = path.normalize(file);
@@ -137,7 +137,7 @@ async function execute() {
// create html files for all blog pages (collections of article previews)
const blogPages = blog.getPagesMarkup(MetadataBlog.length, siteConfig);
- Object.keys(blogPages).forEach(pagePath => {
+ Object.keys(blogPages).forEach((pagePath) => {
const targetFile = join(buildDir, 'blog', pagePath);
writeFileAndCreateFolder(targetFile, blogPages[pagePath]);
});
@@ -168,7 +168,7 @@ async function execute() {
// copy all static files from docusaurus
const libStaticDir = join(__dirname, '..', 'static');
files = glob.sync(join(libStaticDir, '**'));
- files.forEach(file => {
+ files.forEach((file) => {
// Why normalize? In case we are on Windows.
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
const targetFile = path.normalize(file).replace(libStaticDir, buildDir);
@@ -188,15 +188,15 @@ async function execute() {
);
}
- Object.keys(siteConfig.colors).forEach(key => {
+ Object.keys(siteConfig.colors).forEach((key) => {
const color = siteConfig.colors[key];
cssContent = cssContent.replace(new RegExp(`\\$${key}`, 'g'), color);
});
if (siteConfig.fonts) {
- Object.keys(siteConfig.fonts).forEach(key => {
+ Object.keys(siteConfig.fonts).forEach((key) => {
const fontString = siteConfig.fonts[key]
- .map(font => `"${font}"`)
+ .map((font) => `"${font}"`)
.join(', ');
cssContent = cssContent.replace(
new RegExp(`\\$${key}`, 'g'),
@@ -216,7 +216,7 @@ async function execute() {
// Copy all static files from user.
const userStaticDir = join(CWD, 'static');
files = glob.sync(join(userStaticDir, '**'), {dot: true});
- files.forEach(file => {
+ files.forEach((file) => {
// Why normalize? In case we are on Windows.
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
const normalizedFile = path.normalize(file);
@@ -229,15 +229,15 @@ async function execute() {
let cssContent = fs.readFileSync(normalizedFile, 'utf8');
cssContent = `${fs.readFileSync(mainCss, 'utf8')}\n${cssContent}`;
- Object.keys(siteConfig.colors).forEach(key => {
+ Object.keys(siteConfig.colors).forEach((key) => {
const color = siteConfig.colors[key];
cssContent = cssContent.replace(new RegExp(`\\$${key}`, 'g'), color);
});
if (siteConfig.fonts) {
- Object.keys(siteConfig.fonts).forEach(key => {
+ Object.keys(siteConfig.fonts).forEach((key) => {
const fontString = siteConfig.fonts[key]
- .map(font => `"${font}"`)
+ .map((font) => `"${font}"`)
.join(', ');
cssContent = cssContent.replace(
new RegExp(`\\$${key}`, 'g'),
@@ -264,7 +264,7 @@ async function execute() {
}),
imageminGifsicle(),
],
- }).catch(error => {
+ }).catch((error) => {
// if image compression fail, just copy it as it is
console.error(error);
fs.copySync(normalizedFile, targetFile);
@@ -287,10 +287,10 @@ async function execute() {
// compile/copy pages from user
const enabledLanguages = env.translation
.enabledLanguages()
- .map(lang => lang.tag);
+ .map((lang) => lang.tag);
const userPagesDir = join(CWD, 'pages');
files = glob.sync(join(userPagesDir, '**'));
- files.forEach(file => {
+ files.forEach((file) => {
// Why normalize? In case we are on Windows.
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
const normalizedFile = path.normalize(file);
diff --git a/packages/docusaurus-1.x/lib/server/liveReloadServer.js b/packages/docusaurus-1.x/lib/server/liveReloadServer.js
index 8ad27a919d..755e3a9199 100644
--- a/packages/docusaurus-1.x/lib/server/liveReloadServer.js
+++ b/packages/docusaurus-1.x/lib/server/liveReloadServer.js
@@ -20,7 +20,7 @@ function start(port) {
gaze(
[`../${readMetadata.getDocsPath()}/**/*`, '**/*', '!node_modules/**/*'],
- function() {
+ function () {
this.on('all', () => {
server.notifyClients(['/']);
});
diff --git a/packages/docusaurus-1.x/lib/server/metadataUtils.js b/packages/docusaurus-1.x/lib/server/metadataUtils.js
index 69d11a551c..f77ad092f0 100644
--- a/packages/docusaurus-1.x/lib/server/metadataUtils.js
+++ b/packages/docusaurus-1.x/lib/server/metadataUtils.js
@@ -49,10 +49,7 @@ function extractMetadata(content) {
for (let i = 0; i < lines.length - 1; ++i) {
const keyvalue = lines[i].split(':');
const key = keyvalue[0].trim();
- let value = keyvalue
- .slice(1)
- .join(':')
- .trim();
+ let value = keyvalue.slice(1).join(':').trim();
try {
value = JSON.parse(value);
} catch (err) {
@@ -68,7 +65,7 @@ function extractMetadata(content) {
function mdToHtml(Metadata, siteConfig) {
const {baseUrl, docsUrl} = siteConfig;
const result = {};
- Object.keys(Metadata).forEach(id => {
+ Object.keys(Metadata).forEach((id) => {
const metadata = Metadata[id];
if (metadata.language !== 'en' || metadata.original_id) {
return;
diff --git a/packages/docusaurus-1.x/lib/server/readCategories.js b/packages/docusaurus-1.x/lib/server/readCategories.js
index dbfe3f949d..142c82e5b4 100644
--- a/packages/docusaurus-1.x/lib/server/readCategories.js
+++ b/packages/docusaurus-1.x/lib/server/readCategories.js
@@ -13,34 +13,34 @@ function readCategories(sidebar, allMetadata, languages) {
// Go through each language that might be defined.
languages
- .filter(lang => lang.enabled)
- .map(lang => lang.tag)
- .forEach(language => {
+ .filter((lang) => lang.enabled)
+ .map((lang) => lang.tag)
+ .forEach((language) => {
// Get all related metadata for the current sidebar and specific to the language.
const metadatas = Object.values(allMetadata)
.filter(
- metadata =>
+ (metadata) =>
metadata.sidebar === sidebar && metadata.language === language,
)
.sort((a, b) => a.order - b.order);
// Define the correct order of categories.
const sortedCategories = _.uniq(
- metadatas.map(metadata => metadata.category),
+ metadatas.map((metadata) => metadata.category),
);
const metadatasGroupedByCategory = _.chain(metadatas)
- .groupBy(metadata => metadata.category)
- .mapValues(categoryItems => {
+ .groupBy((metadata) => metadata.category)
+ .mapValues((categoryItems) => {
// Process subcategories.
const metadatasGroupedBySubcategory = _.groupBy(
categoryItems,
- item => item.subcategory,
+ (item) => item.subcategory,
);
const result = [];
const seenSubcategories = new Set();
// categoryItems can be links or subcategories. Handle separately.
- categoryItems.forEach(item => {
+ categoryItems.forEach((item) => {
// Has no subcategory.
if (item.subcategory == null) {
result.push({
@@ -59,7 +59,7 @@ function readCategories(sidebar, allMetadata, languages) {
seenSubcategories.add(subcategory);
const subcategoryLinks = metadatasGroupedBySubcategory[
subcategory
- ].map(subcategoryItem => ({
+ ].map((subcategoryItem) => ({
type: 'LINK',
item: subcategoryItem,
}));
@@ -74,7 +74,7 @@ function readCategories(sidebar, allMetadata, languages) {
})
.value();
- const categories = sortedCategories.map(category => ({
+ const categories = sortedCategories.map((category) => ({
type: 'CATEGORY',
title: category,
children: metadatasGroupedByCategory[category],
diff --git a/packages/docusaurus-1.x/lib/server/readMetadata.js b/packages/docusaurus-1.x/lib/server/readMetadata.js
index 5d969a66b4..a7c95e28ba 100644
--- a/packages/docusaurus-1.x/lib/server/readMetadata.js
+++ b/packages/docusaurus-1.x/lib/server/readMetadata.js
@@ -66,17 +66,17 @@ function readSidebar(sidebars = {}) {
const items = {};
- Object.keys(sidebars).forEach(sidebar => {
+ Object.keys(sidebars).forEach((sidebar) => {
const categories = sidebars[sidebar];
const sidebarItems = [];
- Object.keys(categories).forEach(category => {
+ Object.keys(categories).forEach((category) => {
const categoryItems = categories[category];
- categoryItems.forEach(categoryItem => {
+ categoryItems.forEach((categoryItem) => {
if (typeof categoryItem === 'object') {
switch (categoryItem.type) {
case 'subcategory':
- categoryItem.ids.forEach(subcategoryItem => {
+ categoryItem.ids.forEach((subcategoryItem) => {
sidebarItems.push({
id: subcategoryItem,
category,
@@ -133,7 +133,7 @@ function processMetadata(file, refDir) {
const language = utils.getLanguage(file, refDir) || 'en';
const metadata = {};
- Object.keys(result.metadata).forEach(fieldName => {
+ Object.keys(result.metadata).forEach((fieldName) => {
if (SupportedHeaderFields.has(fieldName)) {
metadata[fieldName] = result.metadata[fieldName];
} else {
@@ -219,7 +219,7 @@ function generateMetadataDocs() {
const enabledLanguages = env.translation
.enabledLanguages()
- .map(language => language.tag);
+ .map((language) => language.tag);
const metadatas = {};
const defaultMetadatas = {};
@@ -228,7 +228,7 @@ function generateMetadataDocs() {
// metadata for english files
const docsDir = path.join(CWD, '../', getDocsPath());
let files = glob.sync(`${docsDir}/**`);
- files.forEach(file => {
+ files.forEach((file) => {
const extension = path.extname(file);
if (extension === '.md' || extension === '.markdown') {
@@ -243,8 +243,8 @@ function generateMetadataDocs() {
// create a default list of documents for each enabled language based on docs in English
// these will get replaced if/when the localized file is downloaded from crowdin
enabledLanguages
- .filter(currentLanguage => currentLanguage !== 'en')
- .forEach(currentLanguage => {
+ .filter((currentLanguage) => currentLanguage !== 'en')
+ .forEach((currentLanguage) => {
const baseMetadata = Object.assign({}, metadata);
baseMetadata.id = baseMetadata.id
.toString()
@@ -277,7 +277,7 @@ function generateMetadataDocs() {
// metadata for non-english docs
const translatedDir = path.join(CWD, 'translated_docs');
files = glob.sync(`${CWD}/translated_docs/**`);
- files.forEach(file => {
+ files.forEach((file) => {
if (!utils.getLanguage(file, translatedDir)) {
return;
}
@@ -297,7 +297,7 @@ function generateMetadataDocs() {
// metadata for versioned docs
const versionData = versionFallback.docData();
- versionData.forEach(metadata => {
+ versionData.forEach((metadata) => {
const id = metadata.localized_id;
if (order[id]) {
metadata.sidebar = order[id].sidebar;
@@ -329,7 +329,7 @@ function generateMetadataDocs() {
// Get the titles of the previous and next ids so that we can use them in
// navigation buttons in DocsLayout.js
- Object.keys(metadatas).forEach(metadata => {
+ Object.keys(metadatas).forEach((metadata) => {
if (metadatas[metadata].previous) {
if (metadatas[metadatas[metadata].previous]) {
metadatas[metadata].previous_title =
@@ -350,11 +350,13 @@ function generateMetadataDocs() {
fs.writeFileSync(
path.join(__dirname, '/../core/metadata.js'),
- `${'/**\n' +
- ' * @' +
- 'generated\n' + // separate this out for Nuclide treating @generated as readonly
+ `${
+ '/**\n' +
+ ' * @' +
+ 'generated\n' + // separate this out for Nuclide treating @generated as readonly
' */\n' +
- 'module.exports = '}${JSON.stringify(metadatas, null, 2)};\n`,
+ 'module.exports = '
+ }${JSON.stringify(metadatas, null, 2)};\n`,
);
}
@@ -366,7 +368,7 @@ function generateMetadataBlog(config = siteConfig) {
files
.sort()
.reverse()
- .forEach(file => {
+ .forEach((file) => {
const extension = path.extname(file);
if (extension !== '.md' && extension !== '.markdown') {
return;
@@ -389,11 +391,13 @@ function generateMetadataBlog(config = siteConfig) {
fs.writeFileSync(
path.join(__dirname, '/../core/MetadataBlog.js'),
- `${'/**\n' +
- ' * @' +
- 'generated\n' + // separate this out for Nuclide treating @generated as readonly
+ `${
+ '/**\n' +
+ ' * @' +
+ 'generated\n' + // separate this out for Nuclide treating @generated as readonly
' */\n' +
- 'module.exports = '}${JSON.stringify(sortedMetadatas, null, 2)};\n`,
+ 'module.exports = '
+ }${JSON.stringify(sortedMetadatas, null, 2)};\n`,
);
}
diff --git a/packages/docusaurus-1.x/lib/server/routing.js b/packages/docusaurus-1.x/lib/server/routing.js
index ef706716bc..37a2bc76d2 100644
--- a/packages/docusaurus-1.x/lib/server/routing.js
+++ b/packages/docusaurus-1.x/lib/server/routing.js
@@ -26,7 +26,7 @@ function noExtension() {
}
function page(siteConfig) {
- const gr = regex => regex.toString().replace(/(^\/|\/$)/gm, '');
+ const gr = (regex) => regex.toString().replace(/(^\/|\/$)/gm, '');
if (siteConfig.docsUrl === '') {
return new RegExp(
diff --git a/packages/docusaurus-1.x/lib/server/server.js b/packages/docusaurus-1.x/lib/server/server.js
index a8d3b357e1..dd41cb9123 100644
--- a/packages/docusaurus-1.x/lib/server/server.js
+++ b/packages/docusaurus-1.x/lib/server/server.js
@@ -34,7 +34,7 @@ function execute(port, host) {
function removeModulePathFromCache(moduleName) {
/* eslint-disable no-underscore-dangle */
- Object.keys(module.constructor._pathCache).forEach(cacheKey => {
+ Object.keys(module.constructor._pathCache).forEach((cacheKey) => {
if (cacheKey.indexOf(moduleName) > 0) {
delete module.constructor._pathCache[cacheKey];
}
@@ -46,7 +46,7 @@ function execute(port, host) {
function removeModuleAndChildrenFromCache(moduleName) {
let mod = require.resolve(moduleName);
if (mod && (mod = require.cache[mod])) {
- mod.children.forEach(child => {
+ mod.children.forEach((child) => {
delete require.cache[child.id];
removeModulePathFromCache(mod.id);
});
@@ -121,7 +121,7 @@ function execute(port, host) {
app.get(routing.docs(siteConfig), (req, res, next) => {
const url = decodeURI(req.path.toString().replace(siteConfig.baseUrl, ''));
const metakey = Object.keys(Metadata).find(
- id => Metadata[id].permalink === url,
+ (id) => Metadata[id].permalink === url,
);
let metadata = Metadata[metakey];
@@ -137,7 +137,7 @@ function execute(port, host) {
// if any of the followings is changed, reload the metadata
const reloadTriggers = ['sidebar_label', 'hide_title', 'title'];
- if (reloadTriggers.some(key => metadata[key] !== rawMetadata[key])) {
+ if (reloadTriggers.some((key) => metadata[key] !== rawMetadata[key])) {
reloadMetadata();
extractTranslations();
reloadTranslations();
@@ -163,10 +163,7 @@ function execute(port, host) {
app.get(routing.feed(siteConfig), (req, res, next) => {
res.set('Content-Type', 'application/rss+xml');
- const file = req.path
- .toString()
- .split('blog/')[1]
- .toLowerCase();
+ const file = req.path.toString().split('blog/')[1].toLowerCase();
if (file === 'atom.xml') {
res.send(feed('atom'));
} else if (file === 'feed.xml') {
@@ -250,7 +247,7 @@ function execute(port, host) {
const parts = match[1].split('/');
const enabledLangTags = env.translation
.enabledLanguages()
- .map(lang => lang.tag);
+ .map((lang) => lang.tag);
for (let i = 0; i < parts.length; i++) {
if (enabledLangTags.indexOf(parts[i]) !== -1) {
@@ -321,7 +318,7 @@ function execute(port, host) {
const files = glob.sync(join(CWD, 'static', '**', '*.css'));
- files.forEach(file => {
+ files.forEach((file) => {
if (isSeparateCss(file, siteConfig.separateCss)) {
return;
}
@@ -342,15 +339,15 @@ function execute(port, host) {
);
}
- Object.keys(siteConfig.colors).forEach(key => {
+ Object.keys(siteConfig.colors).forEach((key) => {
const color = siteConfig.colors[key];
cssContent = cssContent.replace(new RegExp(`\\$${key}`, 'g'), color);
});
if (siteConfig.fonts) {
- Object.keys(siteConfig.fonts).forEach(key => {
+ Object.keys(siteConfig.fonts).forEach((key) => {
const fontString = siteConfig.fonts[key]
- .map(font => `"${font}"`)
+ .map((font) => `"${font}"`)
.join(', ');
cssContent = cssContent.replace(
new RegExp(`\\$${key}`, 'g'),
diff --git a/packages/docusaurus-1.x/lib/server/sitemap.js b/packages/docusaurus-1.x/lib/server/sitemap.js
index 74466f81d3..e77da5c28e 100644
--- a/packages/docusaurus-1.x/lib/server/sitemap.js
+++ b/packages/docusaurus-1.x/lib/server/sitemap.js
@@ -26,7 +26,7 @@ const Metadata = require('../core/metadata.js');
readMetadata.generateMetadataBlog(siteConfig);
const MetadataBlog = require('../core/MetadataBlog.js');
-module.exports = function(callback) {
+module.exports = function (callback) {
console.log('sitemap.js triggered...');
const files = glob.sync(`${CWD}/pages/en/**/*.js`);
@@ -43,23 +43,23 @@ module.exports = function(callback) {
// If we have a languages.js file, get all the enabled languages in there
if (fs.existsSync(`${CWD}/languages.js`)) {
const languages = require(`${CWD}/languages.js`);
- enabledLanguages = languages.filter(lang => lang.enabled);
+ enabledLanguages = languages.filter((lang) => lang.enabled);
}
// Create a url mapping to all the enabled languages files
- const urls = files.map(file => {
+ const urls = files.map((file) => {
let url = file.split('/pages/en')[1];
url = siteConfig.cleanUrl
? url.replace(/\.js$/, '')
: url.replace(/\.js$/, '.html');
- const links = enabledLanguages.map(lang => {
+ const links = enabledLanguages.map((lang) => {
const langUrl = lang.tag + url;
return {lang: lang.tag, url: langUrl};
});
return {url, changefreq: 'weekly', priority: 0.5, links};
});
- MetadataBlog.forEach(blog => {
+ MetadataBlog.forEach((blog) => {
urls.push({
url: `/blog/${utils.getPath(blog.path, siteConfig.cleanUrl)}`,
changefreq: 'weekly',
@@ -68,12 +68,12 @@ module.exports = function(callback) {
});
Object.keys(Metadata)
- .filter(key => Metadata[key].language === 'en')
- .forEach(key => {
+ .filter((key) => Metadata[key].language === 'en')
+ .forEach((key) => {
const doc = Metadata[key];
const docUrl = utils.getPath(doc.permalink, siteConfig.cleanUrl);
const docsPart = `${siteConfig.docsUrl ? `${siteConfig.docsUrl}/` : ''}`;
- const links = enabledLanguages.map(lang => {
+ const links = enabledLanguages.map((lang) => {
const langUrl = docUrl.replace(
new RegExp(`^${docsPart}en/`),
`${docsPart}${lang.tag}/`,
diff --git a/packages/docusaurus-1.x/lib/server/start.js b/packages/docusaurus-1.x/lib/server/start.js
index 3f25f400f1..e37a0a4838 100644
--- a/packages/docusaurus-1.x/lib/server/start.js
+++ b/packages/docusaurus-1.x/lib/server/start.js
@@ -14,7 +14,7 @@ const server = require('./server.js');
const CWD = process.cwd();
function startLiveReloadServer() {
- const promise = portFinder.getPortPromise({port: 35729}).then(port => {
+ const promise = portFinder.getPortPromise({port: 35729}).then((port) => {
liveReloadServer.start(port);
});
return promise;
@@ -26,7 +26,7 @@ function startServer() {
const host = program.host || 'localhost';
const promise = portFinder
.getPortPromise({port: initialServerPort})
- .then(port => {
+ .then((port) => {
server(port, host);
const {baseUrl} = require(`${CWD}/siteConfig.js`);
const serverAddress = `http://${host}:${port}${baseUrl}`;
@@ -39,7 +39,7 @@ function startServer() {
function startDocusaurus() {
if (program.watch) {
return startLiveReloadServer()
- .catch(ex => console.warn(`Failed to start live reload server: ${ex}`))
+ .catch((ex) => console.warn(`Failed to start live reload server: ${ex}`))
.then(() => startServer());
}
return startServer();
diff --git a/packages/docusaurus-1.x/lib/server/translation.js b/packages/docusaurus-1.x/lib/server/translation.js
index d78e800162..49b202c326 100644
--- a/packages/docusaurus-1.x/lib/server/translation.js
+++ b/packages/docusaurus-1.x/lib/server/translation.js
@@ -25,14 +25,14 @@ if (fs.existsSync(`${CWD}/languages.js`)) {
];
}
-const enabledLanguages = languages.filter(lang => lang.enabled);
+const enabledLanguages = languages.filter((lang) => lang.enabled);
const translation = {languages: enabledLanguages};
const files = glob.sync(`${CWD}/i18n/**`);
const langRegex = /\/i18n\/(.*)\.json$/;
-files.forEach(file => {
+files.forEach((file) => {
const extension = path.extname(file);
if (extension === '.json') {
const match = langRegex.exec(file);
diff --git a/packages/docusaurus-1.x/lib/server/utils.js b/packages/docusaurus-1.x/lib/server/utils.js
index f431cafd84..e48c08b0ec 100644
--- a/packages/docusaurus-1.x/lib/server/utils.js
+++ b/packages/docusaurus-1.x/lib/server/utils.js
@@ -28,7 +28,7 @@ function getLanguage(file, refDir) {
if (match && env.translation.enabled) {
const enabledLanguages = env.translation
.enabledLanguages()
- .map(language => language.tag);
+ .map((language) => language.tag);
if (enabledLanguages.indexOf(match[1]) !== -1) {
return match[1];
}
@@ -55,7 +55,7 @@ function minifyCss(cssContent) {
zindex: false,
from: undefined,
})
- .then(result => result.css);
+ .then((result) => result.css);
}
function autoPrefixCss(cssContent) {
@@ -63,12 +63,12 @@ function autoPrefixCss(cssContent) {
.process(cssContent, {
from: undefined,
})
- .then(result => result.css);
+ .then((result) => result.css);
}
function replaceAssetsLink(oldContent, location) {
let fencedBlock = false;
- const lines = oldContent.split('\n').map(line => {
+ const lines = oldContent.split('\n').map((line) => {
if (line.trim().startsWith('```')) {
fencedBlock = !fencedBlock;
}
diff --git a/packages/docusaurus-1.x/lib/server/versionFallback.js b/packages/docusaurus-1.x/lib/server/versionFallback.js
index cdded80337..cb7c88c6ca 100644
--- a/packages/docusaurus-1.x/lib/server/versionFallback.js
+++ b/packages/docusaurus-1.x/lib/server/versionFallback.js
@@ -49,7 +49,7 @@ const available = {};
// given version/id of a document
const versionFiles = {};
const files = glob.sync(`${versionFolder}**`);
-files.forEach(file => {
+files.forEach((file) => {
const ext = path.extname(file);
if (ext !== '.md' && ext !== '.markdown') {
return;
@@ -210,8 +210,8 @@ function processVersionMetadata(file, version, useVersion, language) {
// return all metadata of versioned documents
function docData() {
const allIds = new Set();
- Object.keys(versionFiles).forEach(version => {
- Object.keys(versionFiles[version]).forEach(id => {
+ Object.keys(versionFiles).forEach((version) => {
+ Object.keys(versionFiles[version]).forEach((id) => {
allIds.add(id);
});
});
@@ -219,10 +219,10 @@ function docData() {
const metadatas = [];
languages
- .filter(language => language.enabled)
- .forEach(language => {
- versions.forEach(version => {
- allIds.forEach(id => {
+ .filter((language) => language.enabled)
+ .forEach((language) => {
+ versions.forEach((version) => {
+ allIds.forEach((id) => {
let useVersion;
try {
useVersion = docVersion(id, version);
diff --git a/packages/docusaurus-1.x/lib/start-server.js b/packages/docusaurus-1.x/lib/start-server.js
index 8f6ed4e72b..c835a86272 100755
--- a/packages/docusaurus-1.x/lib/start-server.js
+++ b/packages/docusaurus-1.x/lib/start-server.js
@@ -48,7 +48,7 @@ program
.option('--host ', 'use specified host (default: localhost)')
.parse(process.argv);
-startDocusaurus().catch(ex => {
+startDocusaurus().catch((ex) => {
console.error(chalk.red(`Failed to start Docusaurus server: ${ex}`));
process.exit(1);
});
diff --git a/packages/docusaurus-1.x/lib/static/js/codetabs.js b/packages/docusaurus-1.x/lib/static/js/codetabs.js
index 08a4735f54..4fcdc46131 100644
--- a/packages/docusaurus-1.x/lib/static/js/codetabs.js
+++ b/packages/docusaurus-1.x/lib/static/js/codetabs.js
@@ -7,19 +7,19 @@
// Turn off ESLint for this file because it's sent down to users as-is.
/* eslint-disable */
-window.addEventListener('load', function() {
+window.addEventListener('load', function () {
// add event listener for all tab
- document.querySelectorAll('.nav-link').forEach(function(el) {
- el.addEventListener('click', function(e) {
+ document.querySelectorAll('.nav-link').forEach(function (el) {
+ el.addEventListener('click', function (e) {
var groupId = e.target.getAttribute('data-group');
document
.querySelectorAll('.nav-link[data-group='.concat(groupId, ']'))
- .forEach(function(el) {
+ .forEach(function (el) {
el.classList.remove('active');
});
document
.querySelectorAll('.tab-pane[data-group='.concat(groupId, ']'))
- .forEach(function(el) {
+ .forEach(function (el) {
el.classList.remove('active');
});
e.target.classList.add('active');
diff --git a/packages/docusaurus-1.x/lib/static/js/scrollSpy.js b/packages/docusaurus-1.x/lib/static/js/scrollSpy.js
index 877721cf77..1f278b26cf 100644
--- a/packages/docusaurus-1.x/lib/static/js/scrollSpy.js
+++ b/packages/docusaurus-1.x/lib/static/js/scrollSpy.js
@@ -21,7 +21,7 @@
return;
}
- timer = setTimeout(function() {
+ timer = setTimeout(function () {
timer = null;
var activeNavFound = false;
var headings = findHeadings(); // toc nav anchors
@@ -75,7 +75,7 @@
document.addEventListener('scroll', onScroll);
document.addEventListener('resize', onScroll);
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener('DOMContentLoaded', function () {
// Cache the headings once the page has fully loaded.
headingsCache = findHeadings();
onScroll();
diff --git a/packages/docusaurus-1.x/lib/version.js b/packages/docusaurus-1.x/lib/version.js
index 4f999c2238..741c0de58d 100755
--- a/packages/docusaurus-1.x/lib/version.js
+++ b/packages/docusaurus-1.x/lib/version.js
@@ -46,7 +46,7 @@ let version;
program
.arguments('')
- .action(ver => {
+ .action((ver) => {
version = ver;
})
.parse(process.argv);
@@ -85,7 +85,7 @@ if (versions.includes(version)) {
function makeHeader(metadata) {
let header = '---\n';
- Object.keys(metadata).forEach(key => {
+ Object.keys(metadata).forEach((key) => {
header += `${key}: ${metadata[key]}\n`;
});
header += '---\n';
@@ -104,7 +104,7 @@ mkdirp.sync(versionFolder);
// copy necessary files to new version, changing some of its metadata to reflect the versioning
const files = glob.sync(`${CWD}/../${readMetadata.getDocsPath()}/**`);
-files.forEach(file => {
+files.forEach((file) => {
const ext = path.extname(file);
if (ext !== '.md' && ext !== '.markdown') {
return;
@@ -153,21 +153,21 @@ if (versionFallback.diffLatestSidebar()) {
const sidebar = JSON.parse(fs.readFileSync(`${CWD}/sidebars.json`, 'utf8'));
const versioned = {};
- Object.keys(sidebar).forEach(sb => {
+ Object.keys(sidebar).forEach((sb) => {
const versionSidebar = `version-${version}-${sb}`;
versioned[versionSidebar] = {};
const categories = sidebar[sb];
- Object.keys(categories).forEach(category => {
+ Object.keys(categories).forEach((category) => {
versioned[versionSidebar][category] = [];
const categoryItems = categories[category];
- categoryItems.forEach(categoryItem => {
+ categoryItems.forEach((categoryItem) => {
let versionedCategoryItem = categoryItem;
if (typeof categoryItem === 'object') {
if (categoryItem.ids && categoryItem.ids.length > 0) {
versionedCategoryItem.ids = categoryItem.ids.map(
- id => `version-${version}-${id}`,
+ (id) => `version-${version}-${id}`,
);
}
} else if (typeof categoryItem === 'string') {
diff --git a/packages/docusaurus-1.x/lib/write-translations.js b/packages/docusaurus-1.x/lib/write-translations.js
index d996ce2ba8..0238a0a49d 100755
--- a/packages/docusaurus-1.x/lib/write-translations.js
+++ b/packages/docusaurus-1.x/lib/write-translations.js
@@ -102,27 +102,27 @@ function execute() {
}
}
};
- glob.sync(`${docsDir}/**`).forEach(file => translateDoc(file, docsDir));
+ glob.sync(`${docsDir}/**`).forEach((file) => translateDoc(file, docsDir));
glob
.sync(`${versionedDocsDir}/**`)
- .forEach(file => translateDoc(file, versionedDocsDir));
+ .forEach((file) => translateDoc(file, versionedDocsDir));
// look through header links for text to translate
- siteConfig.headerLinks.forEach(link => {
+ siteConfig.headerLinks.forEach((link) => {
if (link.label) {
translations['localized-strings'].links[link.label] = link.label;
}
});
// find sidebar category titles to translate
- Object.keys(sidebars).forEach(sb => {
+ Object.keys(sidebars).forEach((sb) => {
const categories = sidebars[sb];
- Object.keys(categories).forEach(category => {
+ Object.keys(categories).forEach((category) => {
translations['localized-strings'].categories[category] = category;
});
});
- glob.sync(`${CWD}/versioned_sidebars/*`).forEach(file => {
+ glob.sync(`${CWD}/versioned_sidebars/*`).forEach((file) => {
if (!file.endsWith('-sidebars.json')) {
if (file.endsWith('-sidebar.json')) {
console.warn(
@@ -139,16 +139,16 @@ function execute() {
process.exit(1);
}
- Object.keys(sidebarContent).forEach(sb => {
+ Object.keys(sidebarContent).forEach((sb) => {
const categories = sidebarContent[sb];
- Object.keys(categories).forEach(category => {
+ Object.keys(categories).forEach((category) => {
translations['localized-strings'].categories[category] = category;
});
});
});
// go through pages to look for text inside translate tags
- glob.sync(`${CWD}/pages/en/**`).forEach(file => {
+ glob.sync(`${CWD}/pages/en/**`).forEach((file) => {
const extension = nodePath.extname(file);
if (extension === '.js') {
const ast = babylon.parse(fs.readFileSync(file, 'utf8'), {
diff --git a/packages/docusaurus-init/bin/index.js b/packages/docusaurus-init/bin/index.js
index 84c6d5be22..25066fafb0 100755
--- a/packages/docusaurus-init/bin/index.js
+++ b/packages/docusaurus-init/bin/index.js
@@ -26,7 +26,7 @@ if (!semver.satisfies(process.version, requiredVersion)) {
function wrapCommand(fn) {
return (...args) =>
- fn(...args).catch(err => {
+ fn(...args).catch((err) => {
console.error(chalk.red(err.stack));
process.exitCode = 1;
});
@@ -43,7 +43,7 @@ program
wrapCommand(init)(path.resolve(rootDir), siteName, template);
});
-program.arguments('').action(cmd => {
+program.arguments('').action((cmd) => {
program.outputHelp();
console.log(` ${chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)}`);
console.log();
diff --git a/packages/docusaurus-init/src/index.ts b/packages/docusaurus-init/src/index.ts
index d1800792a3..6604cb2f11 100644
--- a/packages/docusaurus-init/src/index.ts
+++ b/packages/docusaurus-init/src/index.ts
@@ -23,7 +23,7 @@ function hasYarn(): boolean {
}
function isValidGitRepoUrl(gitRepoUrl: string): boolean {
- return ['https://', 'git@'].some(item => gitRepoUrl.startsWith(item));
+ return ['https://', 'git@'].some((item) => gitRepoUrl.startsWith(item));
}
async function updatePkg(pkgPath: string, obj: any): Promise {
@@ -43,7 +43,7 @@ export async function init(
const templatesDir = path.resolve(__dirname, '../templates');
const templates = fs
.readdirSync(templatesDir)
- .filter(d => !d.startsWith('.') && !d.startsWith('README'));
+ .filter((d) => !d.startsWith('.') && !d.startsWith('README'));
const gitChoice = 'Git repository';
const templateChoices = [...templates, gitChoice];
diff --git a/packages/docusaurus-mdx-loader/src/index.js b/packages/docusaurus-mdx-loader/src/index.js
index 55a78a2ba4..d17854083f 100644
--- a/packages/docusaurus-mdx-loader/src/index.js
+++ b/packages/docusaurus-mdx-loader/src/index.js
@@ -19,7 +19,7 @@ const DEFAULT_OPTIONS = {
remarkPlugins: [emoji, slug, rightToc],
};
-module.exports = async function(fileString) {
+module.exports = async function (fileString) {
const callback = this.async();
const {data, content} = matter(fileString);
diff --git a/packages/docusaurus-mdx-loader/src/remark/rightToc/index.js b/packages/docusaurus-mdx-loader/src/remark/rightToc/index.js
index b73fc97bea..a45f941e79 100644
--- a/packages/docusaurus-mdx-loader/src/remark/rightToc/index.js
+++ b/packages/docusaurus-mdx-loader/src/remark/rightToc/index.js
@@ -14,15 +14,15 @@ const parseOptions = {
plugins: ['jsx'],
sourceType: 'module',
};
-const isImport = child => child.type === 'import';
-const hasImports = index => index > -1;
-const isExport = child => child.type === 'export';
+const isImport = (child) => child.type === 'import';
+const hasImports = (index) => index > -1;
+const isExport = (child) => child.type === 'export';
const isTarget = (child, name) => {
let found = false;
const ast = parse(child.value, parseOptions);
traverse(ast, {
- VariableDeclarator: path => {
+ VariableDeclarator: (path) => {
if (path.node.id.name === name) {
found = true;
}
@@ -61,7 +61,7 @@ const getOrCreateExistingTargetIndex = (children, name) => {
const plugin = (options = {}) => {
const name = options.name || 'rightToc';
- const transformer = node => {
+ const transformer = (node) => {
const headings = search(node);
const {children} = node;
const targetIndex = getOrCreateExistingTargetIndex(children, name);
diff --git a/packages/docusaurus-mdx-loader/src/remark/slug/__tests__/index.test.js b/packages/docusaurus-mdx-loader/src/remark/slug/__tests__/index.test.js
index 5070253260..887f897d70 100644
--- a/packages/docusaurus-mdx-loader/src/remark/slug/__tests__/index.test.js
+++ b/packages/docusaurus-mdx-loader/src/remark/slug/__tests__/index.test.js
@@ -57,7 +57,7 @@ describe('slug plugin', () => {
test('should not overwrite `data` on headings', () => {
const result = process('# Normal\n', [
- function() {
+ function () {
function transform(tree) {
tree.children[0].data = {foo: 'bar'};
}
@@ -80,7 +80,7 @@ describe('slug plugin', () => {
test('should not overwrite `data.hProperties` on headings', () => {
const result = process('# Normal\n', [
- function() {
+ function () {
function transform(tree) {
tree.children[0].data = {hProperties: {className: ['foo']}};
}
@@ -110,7 +110,7 @@ describe('slug plugin', () => {
'## Something also',
].join('\n\n'),
[
- function() {
+ function () {
function transform(tree) {
tree.children[1].data = {hProperties: {id: 'here'}};
tree.children[3].data = {hProperties: {id: 'something'}};
diff --git a/packages/docusaurus-mdx-loader/src/remark/slug/index.js b/packages/docusaurus-mdx-loader/src/remark/slug/index.js
index 3ce73f9f26..ad8cb51f88 100644
--- a/packages/docusaurus-mdx-loader/src/remark/slug/index.js
+++ b/packages/docusaurus-mdx-loader/src/remark/slug/index.js
@@ -12,7 +12,7 @@ const toString = require('mdast-util-to-string');
const slugs = require('github-slugger')();
function slug() {
- const transformer = ast => {
+ const transformer = (ast) => {
slugs.reset();
function visitor(headingNode) {
diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/generateBlogFeed.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/generateBlogFeed.test.ts
index 16bc818f44..98a87b3f73 100644
--- a/packages/docusaurus-plugin-content-blog/src/__tests__/generateBlogFeed.test.ts
+++ b/packages/docusaurus-plugin-content-blog/src/__tests__/generateBlogFeed.test.ts
@@ -11,7 +11,7 @@ import {LoadContext} from '@docusaurus/types';
import {PluginOptions} from '../types';
describe('blogFeed', () => {
- ['atom', 'rss'].forEach(feedType => {
+ ['atom', 'rss'].forEach((feedType) => {
describe(`${feedType}`, () => {
test('can show feed without posts', async () => {
const siteConfig = {
diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts
index fc663e557a..44a361660b 100644
--- a/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts
+++ b/packages/docusaurus-plugin-content-blog/src/__tests__/index.test.ts
@@ -49,7 +49,7 @@ describe('loadBlog', () => {
.replace(/-/g, '/')}/no date`;
expect({
- ...blogPosts.find(v => v.metadata.title === 'date-matter').metadata,
+ ...blogPosts.find((v) => v.metadata.title === 'date-matter').metadata,
...{prevItem: undefined},
}).toEqual({
editUrl:
@@ -70,7 +70,7 @@ describe('loadBlog', () => {
});
expect(
- blogPosts.find(v => v.metadata.title === 'Happy 1st Birthday Slash!')
+ blogPosts.find((v) => v.metadata.title === 'Happy 1st Birthday Slash!')
.metadata,
).toEqual({
editUrl:
@@ -94,7 +94,7 @@ describe('loadBlog', () => {
});
expect({
- ...blogPosts.find(v => v.metadata.title === 'no date').metadata,
+ ...blogPosts.find((v) => v.metadata.title === 'no date').metadata,
...{prevItem: undefined},
}).toEqual({
editUrl:
@@ -119,6 +119,6 @@ describe('loadBlog', () => {
process.env.NODE_ENV = 'production';
const blogPosts = await getBlogPosts();
- expect(blogPosts.find(v => v.metadata.title === 'draft')).toBeUndefined();
+ expect(blogPosts.find((v) => v.metadata.title === 'draft')).toBeUndefined();
});
});
diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/linkify.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/linkify.test.ts
index af6535f81d..8edcfa222b 100644
--- a/packages/docusaurus-plugin-content-blog/src/__tests__/linkify.test.ts
+++ b/packages/docusaurus-plugin-content-blog/src/__tests__/linkify.test.ts
@@ -36,7 +36,7 @@ const blogPosts: BlogPost[] = [
},
];
-const transform = filepath => {
+const transform = (filepath) => {
const content = fs.readFileSync(filepath, 'utf-8');
const transformedContent = linkify(content, sitePath, blogPath, blogPosts);
return [content, transformedContent];
diff --git a/packages/docusaurus-plugin-content-blog/src/blogUtils.ts b/packages/docusaurus-plugin-content-blog/src/blogUtils.ts
index aa876e49f0..cb012d143e 100644
--- a/packages/docusaurus-plugin-content-blog/src/blogUtils.ts
+++ b/packages/docusaurus-plugin-content-blog/src/blogUtils.ts
@@ -69,7 +69,7 @@ export async function generateBlogFeed(
copyright: feedOptions.copyright,
});
- blogPosts.forEach(post => {
+ blogPosts.forEach((post) => {
const {
id,
metadata: {title, permalink, date, description},
@@ -184,7 +184,7 @@ export function linkify(
blogPosts: BlogPost[],
) {
let fencedBlock = false;
- const lines = fileContent.split('\n').map(line => {
+ const lines = fileContent.split('\n').map((line) => {
if (line.trim().startsWith('```')) {
fencedBlock = !fencedBlock;
}
@@ -203,7 +203,7 @@ export function linkify(
)}`;
let blogPostPermalink = null;
- blogPosts.forEach(blogPost => {
+ blogPosts.forEach((blogPost) => {
if (blogPost.metadata.source === aliasedPostSource) {
blogPostPermalink = blogPost.metadata.permalink;
}
diff --git a/packages/docusaurus-plugin-content-blog/src/index.ts b/packages/docusaurus-plugin-content-blog/src/index.ts
index fe833e4834..15405200d3 100644
--- a/packages/docusaurus-plugin-content-blog/src/index.ts
+++ b/packages/docusaurus-plugin-content-blog/src/index.ts
@@ -85,7 +85,7 @@ export default function pluginContentBlog(
getPathsToWatch() {
const {include = []} = options;
- const globPattern = include.map(pattern => `${contentPath}/${pattern}`);
+ const globPattern = include.map((pattern) => `${contentPath}/${pattern}`);
return [...globPattern];
},
@@ -151,13 +151,13 @@ export default function pluginContentBlog(
},
items: blogPosts
.slice(page * postsPerPage, (page + 1) * postsPerPage)
- .map(item => item.id),
+ .map((item) => item.id),
});
}
const blogTags: BlogTags = {};
const tagsPath = normalizeUrl([basePageUrl, 'tags']);
- blogPosts.forEach(blogPost => {
+ blogPosts.forEach((blogPost) => {
const {tags} = blogPost.metadata;
if (!tags || tags.length === 0) {
// TODO: Extract tags out into a separate plugin.
@@ -167,7 +167,7 @@ export default function pluginContentBlog(
}
// eslint-disable-next-line no-param-reassign
- blogPost.metadata.tags = tags.map(tag => {
+ blogPost.metadata.tags = tags.map((tag) => {
if (typeof tag === 'string') {
const normalizedTag = kebabCase(tag);
const permalink = normalizeUrl([tagsPath, normalizedTag]);
@@ -235,7 +235,7 @@ export default function pluginContentBlog(
// Create routes for blog entries.
await Promise.all(
- blogPosts.map(async blogPost => {
+ blogPosts.map(async (blogPost) => {
const {id, metadata} = blogPost;
await createData(
// Note that this created data path must be in sync with
@@ -259,7 +259,7 @@ export default function pluginContentBlog(
// Create routes for blog's paginated list entries.
await Promise.all(
- blogListPaginated.map(async listPage => {
+ blogListPaginated.map(async (listPage) => {
const {metadata, items} = listPage;
const {permalink} = metadata;
const pageMetadataPath = await createData(
@@ -272,7 +272,7 @@ export default function pluginContentBlog(
component: blogListComponent,
exact: true,
modules: {
- items: items.map(postID => {
+ items: items.map((postID) => {
const metadata = blogItemsToMetadata[postID];
// To tell routes.js this is an import and not a nested object to recurse.
return {
@@ -299,7 +299,7 @@ export default function pluginContentBlog(
const tagsModule: TagsModule = {};
await Promise.all(
- Object.keys(blogTags).map(async tag => {
+ Object.keys(blogTags).map(async (tag) => {
const {name, items, permalink} = blogTags[tag];
tagsModule[tag] = {
@@ -320,7 +320,7 @@ export default function pluginContentBlog(
component: blogTagsPostsComponent,
exact: true,
modules: {
- items: items.map(postID => {
+ items: items.map((postID) => {
const metadata = blogItemsToMetadata[postID];
return {
content: {
@@ -422,14 +422,14 @@ export default function pluginContentBlog(
const feedTypes = getFeedTypes(options.feedOptions?.type);
await Promise.all(
- feedTypes.map(feedType => {
+ feedTypes.map((feedType) => {
const feedPath = path.join(
outDir,
options.routeBasePath,
`${feedType}.xml`,
);
const feedContent = feedType === 'rss' ? feed.rss2() : feed.atom1();
- return fs.writeFile(feedPath, feedContent, err => {
+ return fs.writeFile(feedPath, feedContent, (err) => {
if (err) {
throw new Error(`Generating ${feedType} feed failed: ${err}`);
}
@@ -462,7 +462,7 @@ export default function pluginContentBlog(
};
const headTags: HtmlTags = [];
- feedTypes.map(feedType => {
+ feedTypes.map((feedType) => {
const feedConfig = feedsConfig[feedType] || {};
if (!feedsConfig) {
diff --git a/packages/docusaurus-plugin-content-blog/src/markdownLoader.ts b/packages/docusaurus-plugin-content-blog/src/markdownLoader.ts
index baf1521475..997204d9e0 100644
--- a/packages/docusaurus-plugin-content-blog/src/markdownLoader.ts
+++ b/packages/docusaurus-plugin-content-blog/src/markdownLoader.ts
@@ -9,7 +9,7 @@ import {loader} from 'webpack';
import {truncate, linkify} from './blogUtils';
const {parseQuery, getOptions} = require('loader-utils');
-export = function(fileString: string) {
+export = function (fileString: string) {
const callback = this.async();
const {truncateMarker, siteDir, contentPath, blogPosts} = getOptions(this);
// Linkify posts
diff --git a/packages/docusaurus-plugin-content-docs/global.d.ts b/packages/docusaurus-plugin-content-docs/global.d.ts
deleted file mode 100644
index dbbe9431d5..0000000000
--- a/packages/docusaurus-plugin-content-docs/global.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-///
-
-// @mdx-js/mdx currently doesn't have any @types
-declare module '@mdx-js/mdx' {
- export default function mdx(content: string, options: any): JSX.Element;
-}
diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts
index 222ae9394f..d727bf6a29 100644
--- a/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts
+++ b/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts
@@ -47,7 +47,7 @@ test('site with wrong sidebar file', async () => {
});
return plugin
.loadContent()
- .catch(e =>
+ .catch((e) =>
expect(e).toMatchInlineSnapshot(
`[Error: Improper sidebars file, document with id 'goku' not found.]`,
),
@@ -110,7 +110,7 @@ describe('simple website', () => {
test('getPathToWatch', () => {
const pathToWatch = plugin.getPathsToWatch();
- const matchPattern = pathToWatch.map(filepath =>
+ const matchPattern = pathToWatch.map((filepath) =>
posixPath(path.relative(siteDir, filepath)),
);
expect(matchPattern).not.toEqual([]);
@@ -235,7 +235,7 @@ describe('versioned website', () => {
test('getPathToWatch', () => {
const pathToWatch = plugin.getPathsToWatch();
- const matchPattern = pathToWatch.map(filepath =>
+ const matchPattern = pathToWatch.map((filepath) =>
posixPath(path.relative(siteDir, filepath)),
);
expect(matchPattern).not.toEqual([]);
diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.ts
index d624e5a288..06ebb93c79 100644
--- a/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.ts
+++ b/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.ts
@@ -183,7 +183,7 @@ describe('simple site', () => {
context,
options,
env,
- }).catch(e =>
+ }).catch((e) =>
expect(e).toMatchInlineSnapshot(
`[Error: Document id cannot include "/".]`,
),
diff --git a/packages/docusaurus-plugin-content-docs/src/env.ts b/packages/docusaurus-plugin-content-docs/src/env.ts
index eb8feb18df..6bd00e769a 100644
--- a/packages/docusaurus-plugin-content-docs/src/env.ts
+++ b/packages/docusaurus-plugin-content-docs/src/env.ts
@@ -26,7 +26,7 @@ export function getVersionsJSONFile(siteDir: string) {
return path.join(siteDir, VERSIONS_JSON_FILE);
}
-export default function(siteDir: string): Env {
+export default function (siteDir: string): Env {
const versioning: VersioningEnv = {
enabled: false,
versions: [],
diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts
index 964e965d66..9ce59a939c 100644
--- a/packages/docusaurus-plugin-content-docs/src/index.ts
+++ b/packages/docusaurus-plugin-content-docs/src/index.ts
@@ -81,7 +81,7 @@ export default function pluginContentDocs(
docsDir: versionedDir,
sidebarsDir: versionedSidebarsDir,
} = versioning;
- const versionsNames = versions.map(version => `version-${version}`);
+ const versionsNames = versions.map((version) => `version-${version}`);
return {
name: 'docusaurus-plugin-content-docs',
@@ -91,7 +91,7 @@ export default function pluginContentDocs(
.command('docs:version')
.arguments('')
.description('Tag a new version for docs')
- .action(version => {
+ .action((version) => {
docsVersion(version, siteDir, {
path: options.path,
sidebarPath: options.sidebarPath,
@@ -101,17 +101,18 @@ export default function pluginContentDocs(
getPathsToWatch() {
const {include} = options;
- let globPattern = include.map(pattern => `${docsDir}/${pattern}`);
+ let globPattern = include.map((pattern) => `${docsDir}/${pattern}`);
if (versioning.enabled) {
const docsGlob = include
- .map(pattern =>
+ .map((pattern) =>
versionsNames.map(
- versionName => `${versionedDir}/${versionName}/${pattern}`,
+ (versionName) => `${versionedDir}/${versionName}/${pattern}`,
),
)
.reduce((a, b) => a.concat(b), []);
const sidebarsGlob = versionsNames.map(
- versionName => `${versionedSidebarsDir}/${versionName}-sidebars.json`,
+ (versionName) =>
+ `${versionedSidebarsDir}/${versionName}-sidebars.json`,
);
globPattern = [...globPattern, ...sidebarsGlob, ...docsGlob];
}
@@ -136,7 +137,7 @@ export default function pluginContentDocs(
});
docsPromises.push(
Promise.all(
- docsFiles.map(async source => {
+ docsFiles.map(async (source) => {
const metadata: MetadataRaw = await processMetadata({
source,
refDir: docsDir,
@@ -152,8 +153,8 @@ export default function pluginContentDocs(
// Metadata for versioned docs.
if (versioning.enabled) {
const versionedGlob = include
- .map(pattern =>
- versionsNames.map(versionName => `${versionName}/${pattern}`),
+ .map((pattern) =>
+ versionsNames.map((versionName) => `${versionName}/${pattern}`),
)
.reduce((a, b) => a.concat(b), []);
const versionedFiles = await globby(versionedGlob, {
@@ -161,7 +162,7 @@ export default function pluginContentDocs(
});
docsPromises.push(
Promise.all(
- versionedFiles.map(async source => {
+ versionedFiles.map(async (source) => {
const metadata = await processMetadata({
source,
refDir: versionedDir,
@@ -179,7 +180,8 @@ export default function pluginContentDocs(
const sidebarPaths = [
sidebarPath,
...versionsNames.map(
- versionName => `${versionedSidebarsDir}/${versionName}-sidebars.json`,
+ (versionName) =>
+ `${versionedSidebarsDir}/${versionName}-sidebars.json`,
),
];
const loadedSidebars: Sidebar = loadSidebars(sidebarPaths);
@@ -191,7 +193,7 @@ export default function pluginContentDocs(
const docsMetadata: DocsMetadata = {};
const permalinkToSidebar: PermalinkToSidebar = {};
const versionToSidebars: VersionToSidebars = {};
- Object.keys(docsMetadataRaw).forEach(currentID => {
+ Object.keys(docsMetadataRaw).forEach((currentID) => {
const {next: nextID, previous: previousID, sidebar} =
order[currentID] || {};
const previous = previousID
@@ -291,7 +293,7 @@ export default function pluginContentDocs(
metadataItems: Metadata[],
): Promise => {
const routes = await Promise.all(
- metadataItems.map(async metadataItem => {
+ metadataItems.map(async (metadataItem) => {
await createData(
// Note that this created data path must be in sync with
// metadataPath provided to mdx-loader.
@@ -345,7 +347,7 @@ export default function pluginContentDocs(
'version',
);
await Promise.all(
- Object.keys(docsMetadataByVersion).map(async version => {
+ Object.keys(docsMetadataByVersion).map(async (version) => {
const routes: RouteConfig[] = await genRoutes(
docsMetadataByVersion[version],
);
@@ -364,8 +366,9 @@ export default function pluginContentDocs(
content.docsSidebars,
Array.from(neededSidebars),
),
- permalinkToSidebar: pickBy(content.permalinkToSidebar, sidebar =>
- neededSidebars.has(sidebar),
+ permalinkToSidebar: pickBy(
+ content.permalinkToSidebar,
+ (sidebar) => neededSidebars.has(sidebar),
),
version,
};
diff --git a/packages/docusaurus-plugin-content-docs/src/markdown/__tests__/linkify.test.ts b/packages/docusaurus-plugin-content-docs/src/markdown/__tests__/linkify.test.ts
index 8200a03426..9147a683c5 100644
--- a/packages/docusaurus-plugin-content-docs/src/markdown/__tests__/linkify.test.ts
+++ b/packages/docusaurus-plugin-content-docs/src/markdown/__tests__/linkify.test.ts
@@ -24,7 +24,7 @@ const sourceToPermalink: SourceToPermalink = {
'/docs/1.0.0/subdir/doc1',
};
-const transform = filepath => {
+const transform = (filepath) => {
const content = fs.readFileSync(filepath, 'utf-8');
const transformedContent = linkify(
content,
diff --git a/packages/docusaurus-plugin-content-docs/src/markdown/index.ts b/packages/docusaurus-plugin-content-docs/src/markdown/index.ts
index f71a41f727..2df83f4ad4 100644
--- a/packages/docusaurus-plugin-content-docs/src/markdown/index.ts
+++ b/packages/docusaurus-plugin-content-docs/src/markdown/index.ts
@@ -9,7 +9,7 @@ import {getOptions} from 'loader-utils';
import {loader} from 'webpack';
import linkify from './linkify';
-export = function(fileString: string) {
+export = function (fileString: string) {
const callback = this.async();
const {docsDir, siteDir, versionedDir, sourceToPermalink} = getOptions(this);
return (
diff --git a/packages/docusaurus-plugin-content-docs/src/markdown/linkify.ts b/packages/docusaurus-plugin-content-docs/src/markdown/linkify.ts
index 12bb47368e..16292b9122 100644
--- a/packages/docusaurus-plugin-content-docs/src/markdown/linkify.ts
+++ b/packages/docusaurus-plugin-content-docs/src/markdown/linkify.ts
@@ -10,7 +10,7 @@ import {resolve} from 'url';
import {getSubFolder} from '@docusaurus/utils';
import {SourceToPermalink} from '../types';
-export default function(
+export default function (
fileString: string,
filePath: string,
docsDir: string,
@@ -36,7 +36,7 @@ export default function(
// Replace internal markdown linking (except in fenced blocks).
if (sourceDir) {
let fencedBlock = false;
- const lines = content.split('\n').map(line => {
+ const lines = content.split('\n').map((line) => {
if (line.trim().startsWith('```')) {
fencedBlock = !fencedBlock;
}
diff --git a/packages/docusaurus-plugin-content-docs/src/order.ts b/packages/docusaurus-plugin-content-docs/src/order.ts
index d36b3796da..eeb99e71a5 100644
--- a/packages/docusaurus-plugin-content-docs/src/order.ts
+++ b/packages/docusaurus-plugin-content-docs/src/order.ts
@@ -11,12 +11,12 @@ import {Sidebar, SidebarItem, Order} from './types';
export default function createOrder(allSidebars: Sidebar = {}): Order {
const order: Order = {};
- Object.keys(allSidebars).forEach(sidebarId => {
+ Object.keys(allSidebars).forEach((sidebarId) => {
const sidebar = allSidebars[sidebarId];
const ids: string[] = [];
const indexItems = ({items}: {items: SidebarItem[]}) => {
- items.forEach(item => {
+ items.forEach((item) => {
switch (item.type) {
case 'category':
indexItems({
diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars.ts b/packages/docusaurus-plugin-content-docs/src/sidebars.ts
index e3b3a6ee4c..cfe1b36254 100644
--- a/packages/docusaurus-plugin-content-docs/src/sidebars.ts
+++ b/packages/docusaurus-plugin-content-docs/src/sidebars.ts
@@ -43,7 +43,7 @@ function normalizeCategoryShorthand(
*/
function assertItem(item: Object, keys: string[]): void {
const unknownKeys = Object.keys(item).filter(
- key => !keys.includes(key) && key !== 'type',
+ (key) => !keys.includes(key) && key !== 'type',
);
if (unknownKeys.length) {
@@ -150,7 +150,7 @@ export default function loadSidebars(sidebarPaths?: string[]): Sidebar {
return {} as Sidebar;
}
- sidebarPaths.map(sidebarPath => {
+ sidebarPaths.map((sidebarPath) => {
if (sidebarPath && fs.existsSync(sidebarPath)) {
const sidebar = importFresh(sidebarPath) as SidebarRaw;
Object.assign(allSidebars, sidebar);
diff --git a/packages/docusaurus-plugin-content-pages/src/index.ts b/packages/docusaurus-plugin-content-pages/src/index.ts
index c398cf92c9..bf9f974221 100644
--- a/packages/docusaurus-plugin-content-pages/src/index.ts
+++ b/packages/docusaurus-plugin-content-pages/src/index.ts
@@ -31,7 +31,7 @@ export default function pluginContentPages(
getPathsToWatch() {
const {include = []} = options;
- const globPattern = include.map(pattern => `${contentPath}/${pattern}`);
+ const globPattern = include.map((pattern) => `${contentPath}/${pattern}`);
return [...globPattern];
},
@@ -49,7 +49,7 @@ export default function pluginContentPages(
cwd: pagesDir,
});
- return pagesFiles.map(relativeSource => {
+ return pagesFiles.map((relativeSource) => {
const source = path.join(pagesDir, relativeSource);
const aliasedSource = aliasedSitePath(source, siteDir);
const pathName = encodePath(fileToPath(relativeSource));
@@ -69,7 +69,7 @@ export default function pluginContentPages(
const {addRoute} = actions;
await Promise.all(
- content.map(async metadataItem => {
+ content.map(async (metadataItem) => {
const {permalink, source} = metadataItem;
addRoute({
path: permalink,
diff --git a/packages/docusaurus-plugin-google-analytics/src/analytics.js b/packages/docusaurus-plugin-google-analytics/src/analytics.js
index e8c613ab07..7370f1f9e7 100644
--- a/packages/docusaurus-plugin-google-analytics/src/analytics.js
+++ b/packages/docusaurus-plugin-google-analytics/src/analytics.js
@@ -7,7 +7,7 @@
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
-export default (function() {
+export default (function () {
if (!ExecutionEnvironment.canUseDOM) {
return null;
}
diff --git a/packages/docusaurus-plugin-google-analytics/src/index.js b/packages/docusaurus-plugin-google-analytics/src/index.js
index a19b53b1f2..77117faaba 100644
--- a/packages/docusaurus-plugin-google-analytics/src/index.js
+++ b/packages/docusaurus-plugin-google-analytics/src/index.js
@@ -7,7 +7,7 @@
const path = require('path');
-module.exports = function(context) {
+module.exports = function (context) {
const {siteConfig} = context;
const {themeConfig} = siteConfig;
const {googleAnalytics} = themeConfig || {};
diff --git a/packages/docusaurus-plugin-google-gtag/src/gtag.js b/packages/docusaurus-plugin-google-gtag/src/gtag.js
index 9937a5b131..cc34f0b86e 100644
--- a/packages/docusaurus-plugin-google-gtag/src/gtag.js
+++ b/packages/docusaurus-plugin-google-gtag/src/gtag.js
@@ -8,7 +8,7 @@
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import siteConfig from '@generated/docusaurus.config';
-export default (function() {
+export default (function () {
if (!ExecutionEnvironment.canUseDOM) {
return null;
}
diff --git a/packages/docusaurus-plugin-google-gtag/src/index.js b/packages/docusaurus-plugin-google-gtag/src/index.js
index 4916a16e37..0d6d8d29ca 100644
--- a/packages/docusaurus-plugin-google-gtag/src/index.js
+++ b/packages/docusaurus-plugin-google-gtag/src/index.js
@@ -7,7 +7,7 @@
const path = require('path');
-module.exports = function(context) {
+module.exports = function (context) {
const {siteConfig} = context;
const {themeConfig} = siteConfig;
const {gtag} = themeConfig || {};
diff --git a/packages/docusaurus-plugin-ideal-image/src/index.ts b/packages/docusaurus-plugin-ideal-image/src/index.ts
index b9afbef040..3d67eb66f0 100644
--- a/packages/docusaurus-plugin-ideal-image/src/index.ts
+++ b/packages/docusaurus-plugin-ideal-image/src/index.ts
@@ -10,7 +10,7 @@ import {Configuration} from 'webpack';
import path from 'path';
-export default function(_context: LoadContext, options: PluginOptions) {
+export default function (_context: LoadContext, options: PluginOptions) {
const isProd = process.env.NODE_ENV === 'production';
return {
diff --git a/packages/docusaurus-plugin-ideal-image/src/theme/IdealImage.js b/packages/docusaurus-plugin-ideal-image/src/theme/IdealImage.js
index 06cf81c8dd..0046177cd9 100644
--- a/packages/docusaurus-plugin-ideal-image/src/theme/IdealImage.js
+++ b/packages/docusaurus-plugin-ideal-image/src/theme/IdealImage.js
@@ -18,7 +18,7 @@ function Image(props) {
width={img.src.width || 100}
placeholder={{lqip: img.preSrc}}
src={img.src.src}
- srcSet={img.src.images.map(image => ({
+ srcSet={img.src.images.map((image) => ({
...image,
src: image.path,
}))}
diff --git a/packages/docusaurus-plugin-sitemap/src/createSitemap.ts b/packages/docusaurus-plugin-sitemap/src/createSitemap.ts
index f200d86cdb..4f817dbf9c 100644
--- a/packages/docusaurus-plugin-sitemap/src/createSitemap.ts
+++ b/packages/docusaurus-plugin-sitemap/src/createSitemap.ts
@@ -20,7 +20,7 @@ export default function createSitemap(
}
const urls = routesPaths.map(
- routesPath =>
+ (routesPath) =>
({
url: routesPath,
changefreq: options.changefreq,
diff --git a/packages/docusaurus-preset-classic/src/index.js b/packages/docusaurus-preset-classic/src/index.js
index d2dd08f839..4bab018111 100644
--- a/packages/docusaurus-preset-classic/src/index.js
+++ b/packages/docusaurus-preset-classic/src/index.js
@@ -6,7 +6,7 @@
*/
const admonitions = require('remark-admonitions');
-const addAdmonitions = pluginOptions => {
+const addAdmonitions = (pluginOptions) => {
if (pluginOptions == null) {
return {
remarkPlugins: [admonitions],
diff --git a/packages/docusaurus-theme-classic/src/index.js b/packages/docusaurus-theme-classic/src/index.js
index eec98a959c..47b2c2d274 100644
--- a/packages/docusaurus-theme-classic/src/index.js
+++ b/packages/docusaurus-theme-classic/src/index.js
@@ -35,7 +35,7 @@ const noFlash = `(function() {
}
})();`;
-module.exports = function(context, options) {
+module.exports = function (context, options) {
const {
siteConfig: {themeConfig},
} = context;
@@ -61,7 +61,7 @@ module.exports = function(context, options) {
configureWebpack() {
const prismLanguages = additionalLanguages
- .map(lang => `prism-${lang}`)
+ .map((lang) => `prism-${lang}`)
.join('|');
return {
diff --git a/packages/docusaurus-theme-classic/src/prism-include-languages.js b/packages/docusaurus-theme-classic/src/prism-include-languages.js
index 87c2f249a0..76026ad35c 100644
--- a/packages/docusaurus-theme-classic/src/prism-include-languages.js
+++ b/packages/docusaurus-theme-classic/src/prism-include-languages.js
@@ -17,7 +17,7 @@ import siteConfig from '@generated/docusaurus.config';
window.Prism = Prism;
- additionalLanguages.forEach(lang => {
+ additionalLanguages.forEach((lang) => {
require(`prismjs/components/prism-${lang}`); // eslint-disable-line
});
diff --git a/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.js b/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.js
index 34618a7301..0e2529ccda 100644
--- a/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.js
@@ -19,7 +19,7 @@ function BlogTagsListPage(props) {
const {tags} = props;
const tagCategories = {};
- Object.keys(tags).forEach(tag => {
+ Object.keys(tags).forEach((tag) => {
const category = getCategoryOfTag(tag);
tagCategories[category] = tagCategories[category] || [];
tagCategories[category].push(tag);
@@ -34,7 +34,7 @@ function BlogTagsListPage(props) {
.map(([category, tagsForCategory]) => (
{category}
- {tagsForCategory.map(tag => (
+ {tagsForCategory.map((tag) => (
))
- .filter(item => item != null);
+ .filter((item) => item != null);
return (
diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js
index a8a003875c..c65e9ea333 100644
--- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js
@@ -54,7 +54,7 @@ const getHighlightDirectiveRegex = (
// to be more reliable, the opening and closing comment must match
const commentPattern = languages
.map(
- lang =>
+ (lang) =>
`(?:${comments[lang].start}\\s*(${directives})\\s*${comments[lang].end})`,
)
.join('|');
@@ -62,7 +62,7 @@ const getHighlightDirectiveRegex = (
return new RegExp(`^\\s*(?:${commentPattern})\\s*$`);
};
// select comment styles based on language
-const highlightDirectiveRegex = lang => {
+const highlightDirectiveRegex = (lang) => {
switch (lang) {
case 'js':
case 'javascript':
@@ -120,7 +120,9 @@ export default ({children, className: languageClassName, metastring}) => {
if (metastring && highlightLinesRangeRegex.test(metastring)) {
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1];
- highlightLines = rangeParser.parse(highlightLinesRange).filter(n => n > 0);
+ highlightLines = rangeParser
+ .parse(highlightLinesRange)
+ .filter((n) => n > 0);
}
if (metastring && codeBlockTitleRegex.test(metastring)) {
diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/index.js b/packages/docusaurus-theme-classic/src/theme/DocItem/index.js
index c96619e1cf..9f7516a4e6 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocItem/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/DocItem/index.js
@@ -39,7 +39,7 @@ function Headings({headings, isChild}) {
}
return (
- {headings.map(heading => (
+ {headings.map((heading) => (
-
{
+ baseRoute.routes.find((route) => {
return matchPath(location.pathname, route);
}) || {};
const {permalinkToSidebar, docsSidebars, version} = docsMetadata;
diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
index 219c7b8cfe..dbd3d4fe5d 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
@@ -30,9 +30,9 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
setCollapsed(item.collapsed);
}
- const handleItemClick = useCallback(e => {
+ const handleItemClick = useCallback((e) => {
e.preventDefault();
- setCollapsed(state => !state);
+ setCollapsed((state) => !state);
});
switch (type) {
@@ -54,7 +54,7 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
{label}
- {items.map(childItem => (
+ {items.map((childItem) => (
mutateSidebarCollapsingState(childItem, path))
- .filter(val => val).length > 0;
+ .map((childItem) => mutateSidebarCollapsingState(childItem, path))
+ .filter((val) => val).length > 0;
// eslint-disable-next-line no-param-reassign
item.collapsed = !anyChildItemsActive;
return anyChildItemsActive;
@@ -144,7 +144,7 @@ function DocSidebar(props) {
}
if (sidebarCollapsible) {
- sidebarData.forEach(sidebarItem =>
+ sidebarData.forEach((sidebarItem) =>
mutateSidebarCollapsingState(sidebarItem, path),
);
}
@@ -201,7 +201,7 @@ function DocSidebar(props) {
)}
- {sidebarData.map(item => (
+ {sidebarData.map((item) => (
+const Heading = (Tag) =>
function TargetComponent({id, ...props}) {
const {
siteConfig: {
diff --git a/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.js b/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.js
index 062d61071e..919e22dc03 100644
--- a/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.js
@@ -13,21 +13,21 @@ import Heading from '@theme/Heading';
import styles from './styles.module.css';
export default {
- code: props => {
+ code: (props) => {
const {children} = props;
if (typeof children === 'string') {
return ;
}
return children;
},
- a: props => {
+ a: (props) => {
if (/\.[^./]+$/.test(props.href)) {
// eslint-disable-next-line jsx-a11y/anchor-has-content
return ;
}
return ;
},
- pre: props => ,
+ pre: (props) => ,
h1: Heading('h1'),
h2: Heading('h2'),
h3: Heading('h3'),
diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js
index 4cba85a45b..6d36b28a68 100644
--- a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js
@@ -125,7 +125,7 @@ function Navbar() {
}, [setSidebarShown]);
const onToggleChange = useCallback(
- e => (e.target.checked ? setDarkTheme() : setLightTheme()),
+ (e) => (e.target.checked ? setDarkTheme() : setLightTheme()),
[setLightTheme, setDarkTheme],
);
@@ -182,14 +182,14 @@ function Navbar() {
)}
{links
- .filter(linkItem => linkItem.position === 'left')
+ .filter((linkItem) => linkItem.position === 'left')
.map((linkItem, i) => (
))}
{links
- .filter(linkItem => linkItem.position === 'right')
+ .filter((linkItem) => linkItem.position === 'right')
.map((linkItem, i) => (
))}
diff --git a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js
index 9cd3a76038..53311cf877 100644
--- a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js
@@ -32,7 +32,7 @@ function Tabs(props) {
}
}
- const changeSelectedValue = newValue => {
+ const changeSelectedValue = (newValue) => {
setSelectedValue(newValue);
if (groupId != null) {
setTabGroupChoices(groupId, newValue);
@@ -91,8 +91,8 @@ function Tabs(props) {
'tab-item--active': selectedValue === value,
})}
key={value}
- ref={tabControl => tabRefs.push(tabControl)}
- onKeyDown={event => handleKeydown(tabRefs, event.target, event)}
+ ref={(tabControl) => tabRefs.push(tabControl)}
+ onKeyDown={(event) => handleKeydown(tabRefs, event.target, event)}
onFocus={() => changeSelectedValue(value)}
onClick={() => changeSelectedValue(value)}>
{label}
@@ -102,7 +102,7 @@ function Tabs(props) {
{
Children.toArray(children).filter(
- child => child.props.value === selectedValue,
+ (child) => child.props.value === selectedValue,
)[0]
}
diff --git a/packages/docusaurus-theme-classic/src/theme/Toggle/index.js b/packages/docusaurus-theme-classic/src/theme/Toggle/index.js
index 621bed9c12..6803998577 100644
--- a/packages/docusaurus-theme-classic/src/theme/Toggle/index.js
+++ b/packages/docusaurus-theme-classic/src/theme/Toggle/index.js
@@ -16,7 +16,7 @@ import styles from './styles.module.css';
const Moon = () =>
;
const Sun = () =>
;
-export default function(props) {
+export default function (props) {
const {isClient} = useDocusaurusContext();
return (
{
+const useHideableNavbar = (hideOnScroll) => {
const [isNavbarVisible, setIsNavbarVisible] = useState(true);
const [isFocusedAnchor, setIsFocusedAnchor] = useState(false);
const [lastScrollTop, setLastScrollTop] = useState(0);
const [navbarHeight, setNavbarHeight] = useState(0);
- const navbarRef = useCallback(node => {
+ const navbarRef = useCallback((node) => {
if (node !== null) {
setNavbarHeight(node.getBoundingClientRect().height);
}
diff --git a/packages/docusaurus-theme-classic/src/theme/hooks/useTabGroupChoice.js b/packages/docusaurus-theme-classic/src/theme/hooks/useTabGroupChoice.js
index 74b8141e8b..2a2a98e8bf 100644
--- a/packages/docusaurus-theme-classic/src/theme/hooks/useTabGroupChoice.js
+++ b/packages/docusaurus-theme-classic/src/theme/hooks/useTabGroupChoice.js
@@ -38,7 +38,7 @@ const useTabGroupChoice = () => {
return {
tabGroupChoices,
setTabGroupChoices: (groupId, newChoice) => {
- setChoices(oldChoices => ({...oldChoices, [groupId]: newChoice}));
+ setChoices((oldChoices) => ({...oldChoices, [groupId]: newChoice}));
setChoiceSyncWithLocalStorage(groupId, newChoice);
},
};
diff --git a/packages/docusaurus-theme-classic/src/theme/hooks/useTheme.js b/packages/docusaurus-theme-classic/src/theme/hooks/useTheme.js
index dcbb24e2d2..a0bd4e6d04 100644
--- a/packages/docusaurus-theme-classic/src/theme/hooks/useTheme.js
+++ b/packages/docusaurus-theme-classic/src/theme/hooks/useTheme.js
@@ -24,7 +24,7 @@ const useTheme = () => {
: themes.light,
);
const setThemeSyncWithLocalStorage = useCallback(
- newTheme => {
+ (newTheme) => {
try {
localStorage.setItem('theme', newTheme);
} catch (err) {
diff --git a/packages/docusaurus-theme-live-codeblock/src/index.js b/packages/docusaurus-theme-live-codeblock/src/index.js
index 69050ad510..fb41c91241 100644
--- a/packages/docusaurus-theme-live-codeblock/src/index.js
+++ b/packages/docusaurus-theme-live-codeblock/src/index.js
@@ -7,7 +7,7 @@
const path = require('path');
-module.exports = function() {
+module.exports = function () {
return {
name: 'docusaurus-theme-live-codeblock',
diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js
index beaff00d5e..4c6e9004e8 100644
--- a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js
+++ b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js
@@ -55,7 +55,7 @@ const getHighlightDirectiveRegex = (
// to be more reliable, the opening and closing comment must match
const commentPattern = languages
.map(
- lang =>
+ (lang) =>
`(?:${comments[lang].start}\\s*(${directives})\\s*${comments[lang].end})`,
)
.join('|');
@@ -63,7 +63,7 @@ const getHighlightDirectiveRegex = (
return new RegExp(`^\\s*(?:${commentPattern})\\s*$`);
};
// select comment styles based on language
-const highlightDirectiveRegex = lang => {
+const highlightDirectiveRegex = (lang) => {
switch (lang) {
case 'js':
case 'javascript':
@@ -127,7 +127,9 @@ export default ({
if (metastring && highlightLinesRangeRegex.test(metastring)) {
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1];
- highlightLines = rangeParser.parse(highlightLinesRange).filter(n => n > 0);
+ highlightLines = rangeParser
+ .parse(highlightLinesRange)
+ .filter((n) => n > 0);
}
if (metastring && codeBlockTitleRegex.test(metastring)) {
diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js b/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js
index 7ad4f2dcff..9a556103f3 100644
--- a/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js
+++ b/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js
@@ -15,7 +15,7 @@ function Playground({children, theme, transformCode, ...props}) {
return (
`${code};`)}
+ transformCode={transformCode || ((code) => `${code};`)}
theme={theme}
{...props}>
{
+const Search = (props) => {
const [algoliaLoaded, setAlgoliaLoaded] = useState(false);
const searchBarRef = useRef(null);
const {siteConfig = {}} = useDocusaurusContext();
@@ -81,7 +81,7 @@ const Search = props => {
props.handleSearchBarToggle(!props.isSearchBarExpanded);
}, [props.isSearchBarExpanded]);
- const handleSearchInput = useCallback(e => {
+ const handleSearchInput = useCallback((e) => {
const needFocus = e.type !== 'mouseover';
loadAlgolia(needFocus);
diff --git a/packages/docusaurus-utils/src/__tests__/index.test.ts b/packages/docusaurus-utils/src/__tests__/index.test.ts
index 546ce167cc..5e22171c91 100644
--- a/packages/docusaurus-utils/src/__tests__/index.test.ts
+++ b/packages/docusaurus-utils/src/__tests__/index.test.ts
@@ -27,7 +27,7 @@ describe('load utils', () => {
'@site/versioned_docs/foo/bar.md',
'user/docs/test.md': '@site/../docs/test.md',
};
- Object.keys(asserts).forEach(file => {
+ Object.keys(asserts).forEach((file) => {
expect(aliasedSitePath(file, 'user/website')).toBe(asserts[file]);
});
});
@@ -42,7 +42,7 @@ describe('load utils', () => {
'foo\\bar/lol': 'foo/bar/lol',
'website\\docs/**/*.{md,mdx}': 'website/docs/**/*.{md,mdx}',
};
- Object.keys(asserts).forEach(file => {
+ Object.keys(asserts).forEach((file) => {
expect(posixPath(file)).toBe(asserts[file]);
});
});
@@ -59,7 +59,7 @@ describe('load utils', () => {
'/blog/201712/14-introducing-docusaurus':
'Blog20171214IntroducingDocusaurusA93',
};
- Object.keys(asserts).forEach(file => {
+ Object.keys(asserts).forEach((file) => {
expect(genComponentName(file)).toBe(asserts[file]);
});
});
@@ -75,7 +75,7 @@ describe('load utils', () => {
'/yangshun/tay': 'yangshun-tay-48d',
'/yangshun-tay': 'yangshun-tay-f3b',
};
- Object.keys(asserts).forEach(file => {
+ Object.keys(asserts).forEach((file) => {
expect(docuHash(file)).toBe(asserts[file]);
});
});
@@ -91,7 +91,7 @@ describe('load utils', () => {
'foo.js': '/foo',
'foo/bar.js': '/foo/bar',
};
- Object.keys(asserts).forEach(file => {
+ Object.keys(asserts).forEach((file) => {
expect(fileToPath(file)).toBe(asserts[file]);
});
});
@@ -142,7 +142,7 @@ describe('load utils', () => {
'/users/en/': 'users-en-f7a',
'/blog': 'blog-c06',
};
- Object.keys(firstAssert).forEach(str => {
+ Object.keys(firstAssert).forEach((str) => {
expect(genChunkName(str)).toBe(firstAssert[str]);
});
@@ -156,7 +156,7 @@ describe('load utils', () => {
'/blog/1': 'blog-85-f-089',
'/blog/2': 'blog-353-489',
};
- Object.keys(secondAssert).forEach(str => {
+ Object.keys(secondAssert).forEach((str) => {
expect(genChunkName(str, undefined, 'blog')).toBe(secondAssert[str]);
});
@@ -167,7 +167,7 @@ describe('load utils', () => {
c: '4a8a08f0',
d: '8277e091',
};
- Object.keys(thirdAssert).forEach(str => {
+ Object.keys(thirdAssert).forEach((str) => {
expect(genChunkName(str, undefined, undefined, true)).toBe(
thirdAssert[str],
);
@@ -210,10 +210,9 @@ describe('load utils', () => {
versions: [],
});
expect(idx(obj, ['translation', 'enabled'])).toEqual(true);
- expect(idx(obj, ['translation', variable]).map(lang => lang.tag)).toEqual([
- 'en',
- 'ja',
- ]);
+ expect(
+ idx(obj, ['translation', variable]).map((lang) => lang.tag),
+ ).toEqual(['en', 'ja']);
expect(idx(test, ['arr', 0])).toEqual(1);
expect(idx(undefined)).toBeUndefined();
expect(idx(null)).toBeNull();
@@ -283,7 +282,7 @@ describe('load utils', () => {
output: 'http://foobar.com/test/',
},
];
- asserts.forEach(testCase => {
+ asserts.forEach((testCase) => {
expect(normalizeUrl(testCase.input)).toBe(testCase.output);
});
diff --git a/packages/docusaurus-utils/src/index.ts b/packages/docusaurus-utils/src/index.ts
index 3537d51f9e..80bddc33e2 100644
--- a/packages/docusaurus-utils/src/index.ts
+++ b/packages/docusaurus-utils/src/index.ts
@@ -35,15 +35,11 @@ export async function generate(
// This is to avoid unnecessary overwriting and we can reuse old file.
if (!lastHash && fs.existsSync(filepath)) {
const lastContent = await fs.readFile(filepath, 'utf8');
- lastHash = createHash('md5')
- .update(lastContent)
- .digest('hex');
+ lastHash = createHash('md5').update(lastContent).digest('hex');
fileHash.set(filepath, lastHash);
}
- const currentHash = createHash('md5')
- .update(content)
- .digest('hex');
+ const currentHash = createHash('md5').update(content).digest('hex');
if (lastHash !== currentHash) {
await fs.ensureDir(path.dirname(filepath));
@@ -79,7 +75,7 @@ export function fileToPath(file: string): string {
export function encodePath(userpath: string): string {
return userpath
.split('/')
- .map(item => encodeURIComponent(item))
+ .map((item) => encodeURIComponent(item))
.join('/');
}
@@ -91,10 +87,7 @@ export function docuHash(str: string): string {
if (str === '/') {
return 'index';
}
- const shortHash = createHash('md5')
- .update(str)
- .digest('hex')
- .substr(0, 3);
+ const shortHash = createHash('md5').update(str).digest('hex').substr(0, 3);
return `${kebabCase(str)}-${shortHash}`;
}
@@ -200,10 +193,7 @@ export function parse(
} {
const options: {} = {
excerpt: (file: matter.GrayMatterFile
): void => {
- file.excerpt = file.content
- .trim()
- .split('\n', 1)
- .shift();
+ file.excerpt = file.content.trim().split('\n', 1).shift();
},
};
diff --git a/packages/docusaurus/bin/docusaurus.js b/packages/docusaurus/bin/docusaurus.js
index 6d3cec424e..d5a0373a26 100755
--- a/packages/docusaurus/bin/docusaurus.js
+++ b/packages/docusaurus/bin/docusaurus.js
@@ -26,7 +26,7 @@ if (!semver.satisfies(process.version, requiredVersion)) {
function wrapCommand(fn) {
return (...args) =>
- fn(...args).catch(err => {
+ fn(...args).catch((err) => {
console.error(chalk.red(err.stack));
process.exitCode = 1;
});
@@ -94,7 +94,7 @@ cli
});
});
-cli.arguments('').action(cmd => {
+cli.arguments('').action((cmd) => {
cli.outputHelp();
console.log(` ${chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)}`);
console.log();
diff --git a/packages/docusaurus/src/client/PendingNavigation.js b/packages/docusaurus/src/client/PendingNavigation.js
index ae6a22d29e..f5316d8b64 100644
--- a/packages/docusaurus/src/client/PendingNavigation.js
+++ b/packages/docusaurus/src/client/PendingNavigation.js
@@ -72,7 +72,7 @@ class PendingNavigation extends React.Component {
}
}
})
- .catch(e => console.warn(e));
+ .catch((e) => console.warn(e));
return false;
}
diff --git a/packages/docusaurus/src/client/__tests__/flat.test.js b/packages/docusaurus/src/client/__tests__/flat.test.js
index 73dc6453a5..4d176c0086 100644
--- a/packages/docusaurus/src/client/__tests__/flat.test.js
+++ b/packages/docusaurus/src/client/__tests__/flat.test.js
@@ -41,7 +41,7 @@ describe('flat', () => {
null: null,
undefined,
};
- Object.keys(primitives).forEach(key => {
+ Object.keys(primitives).forEach((key) => {
const value = primitives[key];
expect(
flat({
diff --git a/packages/docusaurus/src/client/client-lifecycles-dispatcher.js b/packages/docusaurus/src/client/client-lifecycles-dispatcher.js
index 1170ef117f..942dd3c2af 100644
--- a/packages/docusaurus/src/client/client-lifecycles-dispatcher.js
+++ b/packages/docusaurus/src/client/client-lifecycles-dispatcher.js
@@ -8,7 +8,7 @@
import clientModules from '@generated/client-modules';
function dispatchLifecycleAction(lifecycleAction, ...args) {
- clientModules.forEach(clientModule => {
+ clientModules.forEach((clientModule) => {
const mod = clientModule.__esModule ? clientModule.default : clientModule;
if (mod && mod[lifecycleAction]) {
mod[lifecycleAction](...args);
@@ -24,7 +24,7 @@ function createLifecyclesDispatcher() {
return ['onRouteUpdate', 'onRouteUpdateDelayed'].reduce(
(lifecycles, lifecycleAction) => {
// eslint-disable-next-line no-param-reassign
- lifecycles[lifecycleAction] = function(...args) {
+ lifecycles[lifecycleAction] = function (...args) {
dispatchLifecycleAction(lifecycleAction, ...args);
};
return lifecycles;
diff --git a/packages/docusaurus/src/client/docusaurus.js b/packages/docusaurus/src/client/docusaurus.js
index 36a5d50a31..17ca22ae77 100644
--- a/packages/docusaurus/src/client/docusaurus.js
+++ b/packages/docusaurus/src/client/docusaurus.js
@@ -27,13 +27,13 @@ const isSlowConnection = () => {
return false;
};
-const canPrefetch = routePath =>
+const canPrefetch = (routePath) =>
!isSlowConnection() && !loaded[routePath] && !fetched[routePath];
-const canPreload = routePath => !isSlowConnection() && !loaded[routePath];
+const canPreload = (routePath) => !isSlowConnection() && !loaded[routePath];
const docusaurus = {
- prefetch: routePath => {
+ prefetch: (routePath) => {
if (!canPrefetch(routePath)) {
return false;
}
@@ -53,7 +53,7 @@ const docusaurus = {
}, []);
// Prefetch all webpack chunk assets file needed.
- chunkNamesNeeded.forEach(chunkName => {
+ chunkNamesNeeded.forEach((chunkName) => {
// "__webpack_require__.gca" is a custom function provided by ChunkAssetPlugin.
// Pass it the chunkName or chunkId you want to load and it will return the URL for that chunk.
// eslint-disable-next-line no-undef
@@ -69,7 +69,7 @@ const docusaurus = {
return true;
},
- preload: routePath => {
+ preload: (routePath) => {
if (!canPreload(routePath)) {
return false;
}
diff --git a/packages/docusaurus/src/client/exports/ComponentCreator.js b/packages/docusaurus/src/client/exports/ComponentCreator.js
index f67bff8e32..485c86651f 100644
--- a/packages/docusaurus/src/client/exports/ComponentCreator.js
+++ b/packages/docusaurus/src/client/exports/ComponentCreator.js
@@ -38,7 +38,7 @@ function ComponentCreator(path) {
- optsWebpack: [require.resolveWeak('./Pages.js'), require.resolveWeak('./doc1.md')]
*/
const flatChunkNames = flat(chunkNames);
- Object.keys(flatChunkNames).forEach(key => {
+ Object.keys(flatChunkNames).forEach((key) => {
const chunkRegistry = registry[flatChunkNames[key]];
if (chunkRegistry) {
/* eslint-disable prefer-destructuring */
@@ -57,7 +57,7 @@ function ComponentCreator(path) {
render: (loaded, props) => {
// Clone the original object since we don't want to alter the original.
const loadedModules = JSON.parse(JSON.stringify(chunkNames));
- Object.keys(loaded).forEach(key => {
+ Object.keys(loaded).forEach((key) => {
let val = loadedModules;
const keyPath = key.split('.');
for (let i = 0; i < keyPath.length - 1; i += 1) {
@@ -65,10 +65,10 @@ function ComponentCreator(path) {
}
val[keyPath[keyPath.length - 1]] = loaded[key].default;
const nonDefaultKeys = Object.keys(loaded[key]).filter(
- k => k !== 'default',
+ (k) => k !== 'default',
);
if (nonDefaultKeys && nonDefaultKeys.length) {
- nonDefaultKeys.forEach(nonDefaultKey => {
+ nonDefaultKeys.forEach((nonDefaultKey) => {
val[keyPath[keyPath.length - 1]][nonDefaultKey] =
loaded[key][nonDefaultKey];
});
diff --git a/packages/docusaurus/src/client/exports/Link.js b/packages/docusaurus/src/client/exports/Link.js
index 66f093927a..832b6afda6 100644
--- a/packages/docusaurus/src/client/exports/Link.js
+++ b/packages/docusaurus/src/client/exports/Link.js
@@ -20,8 +20,8 @@ function Link(props) {
let io;
const handleIntersection = (el, cb) => {
- io = new window.IntersectionObserver(entries => {
- entries.forEach(entry => {
+ io = new window.IntersectionObserver((entries) => {
+ entries.forEach((entry) => {
if (el === entry.target) {
// If element is in viewport, stop listening/observing and run callback.
// https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
@@ -38,7 +38,7 @@ function Link(props) {
io.observe(el);
};
- const handleRef = ref => {
+ const handleRef = (ref) => {
if (IOSupported && ref && isInternal) {
// If IO supported and element reference found, setup Observer functionality.
handleIntersection(ref, () => {
diff --git a/packages/docusaurus/src/client/flat.js b/packages/docusaurus/src/client/flat.js
index b9cd71d675..04173df589 100644
--- a/packages/docusaurus/src/client/flat.js
+++ b/packages/docusaurus/src/client/flat.js
@@ -10,7 +10,7 @@ function flat(target) {
const output = {};
function step(object, prev) {
- Object.keys(object).forEach(key => {
+ Object.keys(object).forEach((key) => {
const value = object[key];
const type = typeof value;
const isObject = type === 'object' && !!value;
diff --git a/packages/docusaurus/src/client/prefetch.js b/packages/docusaurus/src/client/prefetch.js
index 9a555f3a06..fe6cc5ea67 100644
--- a/packages/docusaurus/src/client/prefetch.js
+++ b/packages/docusaurus/src/client/prefetch.js
@@ -68,7 +68,7 @@ const supportedPrefetchStrategy = support('prefetch')
const preFetched = {};
function prefetch(url) {
- return new Promise(resolve => {
+ return new Promise((resolve) => {
if (preFetched[url]) {
resolve();
return;
diff --git a/packages/docusaurus/src/client/preload.js b/packages/docusaurus/src/client/preload.js
index f293835155..fad0b85cbe 100644
--- a/packages/docusaurus/src/client/preload.js
+++ b/packages/docusaurus/src/client/preload.js
@@ -19,7 +19,7 @@ export default function preload(routes, pathname) {
const matches = matchRoutes(routes, pathname);
return Promise.all(
- matches.map(match => {
+ matches.map((match) => {
const {component} = match.route;
if (component && component.preload) {
diff --git a/packages/docusaurus/src/client/serverEntry.js b/packages/docusaurus/src/client/serverEntry.js
index 268992830e..5cb7be8d57 100644
--- a/packages/docusaurus/src/client/serverEntry.js
+++ b/packages/docusaurus/src/client/serverEntry.js
@@ -30,7 +30,7 @@ export default async function render(locals) {
const modules = new Set();
const context = {};
const appHtml = ReactDOMServer.renderToString(
- modules.add(moduleName)}>
+ modules.add(moduleName)}>
@@ -55,8 +55,8 @@ export default async function render(locals) {
// manifest information.
const modulesToBeLoaded = [...manifest.entrypoints, ...Array.from(modules)];
const bundles = getBundles(manifest, modulesToBeLoaded);
- const stylesheets = (bundles.css || []).map(b => b.file);
- const scripts = (bundles.js || []).map(b => b.file);
+ const stylesheets = (bundles.css || []).map((b) => b.file);
+ const scripts = (bundles.js || []).map((b) => b.file);
const {baseUrl} = locals;
const renderedHtml = ejs.render(
diff --git a/packages/docusaurus/src/commands/build.ts b/packages/docusaurus/src/commands/build.ts
index a440f5eec1..ddcd2ddcda 100644
--- a/packages/docusaurus/src/commands/build.ts
+++ b/packages/docusaurus/src/commands/build.ts
@@ -29,13 +29,13 @@ function compile(config: Configuration[]): Promise {
reject(err);
}
if (stats.hasErrors()) {
- stats.toJson('errors-only').errors.forEach(e => {
+ stats.toJson('errors-only').errors.forEach((e) => {
console.error(e);
});
reject(new Error('Failed to compile with errors.'));
}
if (stats.hasWarnings()) {
- stats.toJson('errors-warnings').warnings.forEach(warning => {
+ stats.toJson('errors-warnings').warnings.forEach((warning) => {
console.warn(warning);
});
}
@@ -95,7 +95,7 @@ export async function build(
}
// Plugin Lifecycle - configureWebpack.
- plugins.forEach(plugin => {
+ plugins.forEach((plugin) => {
const {configureWebpack} = plugin;
if (!configureWebpack) {
return;
@@ -130,14 +130,14 @@ export async function build(
typeof serverConfig.output.filename === 'string'
) {
const serverBundle = path.join(outDir, serverConfig.output.filename);
- fs.pathExists(serverBundle).then(exist => {
+ fs.pathExists(serverBundle).then((exist) => {
exist && fs.unlink(serverBundle);
});
}
// Plugin Lifecycle - postBuild.
await Promise.all(
- plugins.map(async plugin => {
+ plugins.map(async (plugin) => {
if (!plugin.postBuild) {
return;
}
diff --git a/packages/docusaurus/src/commands/deploy.ts b/packages/docusaurus/src/commands/deploy.ts
index b2632c9bfa..411f077c7d 100644
--- a/packages/docusaurus/src/commands/deploy.ts
+++ b/packages/docusaurus/src/commands/deploy.ts
@@ -99,7 +99,7 @@ export async function deploy(
// Build static html files, then push to deploymentBranch branch of specified repo.
build(siteDir, cliOptions, false)
- .then(outDir => {
+ .then((outDir) => {
shell.cd(tempDir);
if (
@@ -146,7 +146,7 @@ export async function deploy(
`${projectName}-${deploymentBranch}`,
);
- fs.copy(fromPath, toPath, error => {
+ fs.copy(fromPath, toPath, (error) => {
if (error) {
throw new Error(
`Error: Copying build assets failed with error '${error}'`,
@@ -177,7 +177,7 @@ export async function deploy(
}
});
})
- .catch(buildError => {
+ .catch((buildError) => {
console.error(buildError);
process.exit(1);
});
diff --git a/packages/docusaurus/src/commands/external.ts b/packages/docusaurus/src/commands/external.ts
index 4575a057ba..97fc90bdd0 100644
--- a/packages/docusaurus/src/commands/external.ts
+++ b/packages/docusaurus/src/commands/external.ts
@@ -15,7 +15,7 @@ export function externalCommand(cli: CommanderStatic, siteDir: string): void {
const plugins = initPlugins({pluginConfigs, context});
// Plugin Lifecycle - extendCli.
- plugins.forEach(plugin => {
+ plugins.forEach((plugin) => {
const {extendCli} = plugin;
if (!extendCli) {
diff --git a/packages/docusaurus/src/commands/start.ts b/packages/docusaurus/src/commands/start.ts
index f0ca17b05c..25d5f89df2 100644
--- a/packages/docusaurus/src/commands/start.ts
+++ b/packages/docusaurus/src/commands/start.ts
@@ -50,13 +50,13 @@ export async function start(
// Reload files processing.
const reload = () => {
- load(siteDir).catch(err => {
+ load(siteDir).catch((err) => {
console.error(chalk.red(err.stack));
});
};
const {siteConfig, plugins = []} = props;
- const normalizeToSiteDir = filepath => {
+ const normalizeToSiteDir = (filepath) => {
if (filepath && path.isAbsolute(filepath)) {
return posixPath(path.relative(siteDir, filepath));
}
@@ -66,7 +66,9 @@ export async function start(
const pluginPaths: string[] = ([] as string[])
.concat(
...plugins
- .map(plugin => plugin.getPathsToWatch && plugin.getPathsToWatch())
+ .map(
+ (plugin) => plugin.getPathsToWatch && plugin.getPathsToWatch(),
+ )
.filter(Boolean),
)
.map(normalizeToSiteDir);
@@ -74,7 +76,7 @@ export async function start(
cwd: siteDir,
ignoreInitial: true,
});
- ['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(event =>
+ ['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) =>
fsWatcher.on(event, reload),
);
@@ -107,7 +109,7 @@ export async function start(
});
// Plugin Lifecycle - configureWebpack.
- plugins.forEach(plugin => {
+ plugins.forEach((plugin) => {
const {configureWebpack} = plugin;
if (!configureWebpack) {
return;
@@ -160,13 +162,13 @@ export async function start(
};
const compiler = webpack(config);
const devServer = new WebpackDevServer(compiler, devServerConfig);
- devServer.listen(port, host, err => {
+ devServer.listen(port, host, (err) => {
if (err) {
console.log(err);
}
cliOptions.open && openBrowser(openUrl);
});
- ['SIGINT', 'SIGTERM'].forEach(sig => {
+ ['SIGINT', 'SIGTERM'].forEach((sig) => {
process.on(sig as NodeJS.Signals, () => {
devServer.close();
process.exit();
diff --git a/packages/docusaurus/src/server/client-modules/index.ts b/packages/docusaurus/src/server/client-modules/index.ts
index 1c7dba2ca9..e04dba7fd5 100644
--- a/packages/docusaurus/src/server/client-modules/index.ts
+++ b/packages/docusaurus/src/server/client-modules/index.ts
@@ -10,7 +10,9 @@ import {Plugin} from '@docusaurus/types';
export function loadClientModules(plugins: Plugin[]): string[] {
return ([] as string[]).concat(
...plugins
- .map(plugin => plugin.getClientModules && plugin.getClientModules())
+ .map(
+ (plugin) => plugin.getClientModules && plugin.getClientModules(),
+ )
.filter(Boolean),
);
}
diff --git a/packages/docusaurus/src/server/config.ts b/packages/docusaurus/src/server/config.ts
index 309f0b9c93..5d2909df94 100644
--- a/packages/docusaurus/src/server/config.ts
+++ b/packages/docusaurus/src/server/config.ts
@@ -45,7 +45,7 @@ const DEFAULT_CONFIG: {
};
function formatFields(fields: string[]): string {
- return fields.map(field => `'${field}'`).join(', ');
+ return fields.map((field) => `'${field}'`).join(', ');
}
export function loadConfig(siteDir: string): DocusaurusConfig {
@@ -57,7 +57,7 @@ export function loadConfig(siteDir: string): DocusaurusConfig {
const loadedConfig = importFresh(configPath) as Partial;
const missingFields = REQUIRED_FIELDS.filter(
- field => !has(loadedConfig, field),
+ (field) => !has(loadedConfig, field),
);
if (missingFields.length > 0) {
@@ -77,7 +77,7 @@ export function loadConfig(siteDir: string): DocusaurusConfig {
// Don't allow unrecognized fields.
const allowedFields = [...REQUIRED_FIELDS, ...OPTIONAL_FIELDS];
const unrecognizedFields = Object.keys(config).filter(
- field => !allowedFields.includes(field),
+ (field) => !allowedFields.includes(field),
);
if (unrecognizedFields && unrecognizedFields.length > 0) {
diff --git a/packages/docusaurus/src/server/html-tags/htmlTags.ts b/packages/docusaurus/src/server/html-tags/htmlTags.ts
index fc0b335711..2a51e441c9 100644
--- a/packages/docusaurus/src/server/html-tags/htmlTags.ts
+++ b/packages/docusaurus/src/server/html-tags/htmlTags.ts
@@ -35,8 +35,8 @@ export function htmlTagObjectToString(tagDefinition: any): string {
const isVoidTag = voidHtmlTags.indexOf(tagDefinition.tagName) !== -1;
const tagAttributes = tagDefinition.attributes || {};
const attributes = Object.keys(tagAttributes)
- .filter(attributeName => tagAttributes[attributeName] !== false)
- .map(attributeName => {
+ .filter((attributeName) => tagAttributes[attributeName] !== false)
+ .map((attributeName) => {
if (tagAttributes[attributeName] === true) {
return attributeName;
}
diff --git a/packages/docusaurus/src/server/index.ts b/packages/docusaurus/src/server/index.ts
index 266737a3e6..956648e67c 100644
--- a/packages/docusaurus/src/server/index.ts
+++ b/packages/docusaurus/src/server/index.ts
@@ -86,7 +86,7 @@ export async function load(
const fallbackTheme = path.resolve(__dirname, '../client/theme-fallback');
const pluginThemes = ([] as string[]).concat(
...plugins
- .map(plugin => plugin.getThemePath && plugin.getThemePath())
+ .map((plugin) => plugin.getThemePath && plugin.getThemePath())
.filter(Boolean),
);
const userTheme = path.resolve(siteDir, THEME_PATH);
@@ -104,7 +104,7 @@ export async function load(
},
}),
injectHtmlTags: () => {
- const stylesheetsTags = stylesheets.map(source =>
+ const stylesheetsTags = stylesheets.map((source) =>
typeof source === 'string'
? ``
: {
@@ -115,7 +115,7 @@ export async function load(
},
},
);
- const scriptsTags = scripts.map(source =>
+ const scriptsTags = scripts.map((source) =>
typeof source === 'string'
? ``
: {
@@ -141,7 +141,7 @@ export async function load(
// import() is async so we use require() because client modules can have
// CSS and the order matters for loading CSS.
// We need to JSON.stringify so that if its on windows, backslash are escaped.
- .map(module => ` require(${JSON.stringify(module)}),`)
+ .map((module) => ` require(${JSON.stringify(module)}),`)
.join('\n')}\n];\n`,
);
@@ -163,7 +163,7 @@ export async function load(
${Object.keys(registry)
.sort()
.map(
- key =>
+ (key) =>
// We need to JSON.stringify so that if its on windows, backslash are escaped.
` '${key}': [${registry[key].loader}, ${JSON.stringify(
registry[key].modulePath,
diff --git a/packages/docusaurus/src/server/plugins/index.ts b/packages/docusaurus/src/server/plugins/index.ts
index 90c587244d..2341ab6b3d 100644
--- a/packages/docusaurus/src/server/plugins/index.ts
+++ b/packages/docusaurus/src/server/plugins/index.ts
@@ -60,7 +60,7 @@ export async function loadPlugins({
// We could change this in future if there are plugins which need to
// run in certain order or depend on others for data.
const pluginsLoadedContent = await Promise.all(
- plugins.map(async plugin => {
+ plugins.map(async (plugin) => {
if (!plugin.loadContent) {
return null;
}
@@ -84,7 +84,7 @@ export async function loadPlugins({
);
const actions: PluginContentLoadedActions = {
- addRoute: config => pluginsRouteConfigs.push(config),
+ addRoute: (config) => pluginsRouteConfigs.push(config),
createData: async (name, content) => {
const modulePath = path.join(pluginContentDir, name);
await fs.ensureDir(path.dirname(modulePath));
diff --git a/packages/docusaurus/src/server/plugins/init.ts b/packages/docusaurus/src/server/plugins/init.ts
index 5898d2cdeb..244483467e 100644
--- a/packages/docusaurus/src/server/plugins/init.ts
+++ b/packages/docusaurus/src/server/plugins/init.ts
@@ -16,7 +16,7 @@ export function initPlugins({
context: LoadContext;
}): Plugin[] {
const plugins: Plugin[] = pluginConfigs
- .map(pluginItem => {
+ .map((pluginItem) => {
let pluginModuleImport;
let pluginOptions = {};
diff --git a/packages/docusaurus/src/server/presets/index.ts b/packages/docusaurus/src/server/presets/index.ts
index cd09f1fede..9f45f0efe2 100644
--- a/packages/docusaurus/src/server/presets/index.ts
+++ b/packages/docusaurus/src/server/presets/index.ts
@@ -23,7 +23,7 @@ export function loadPresets(
const unflatPlugins: PluginConfig[][] = [];
const unflatThemes: PluginConfig[][] = [];
- presets.forEach(presetItem => {
+ presets.forEach((presetItem) => {
let presetModuleImport;
let presetOptions = {};
if (typeof presetItem === 'string') {
diff --git a/packages/docusaurus/src/server/routes.ts b/packages/docusaurus/src/server/routes.ts
index 46497b9053..11cb325a79 100644
--- a/packages/docusaurus/src/server/routes.ts
+++ b/packages/docusaurus/src/server/routes.ts
@@ -105,7 +105,7 @@ export async function loadRoutes(
}
const newValue: ChunkNames = {};
- Object.keys(value).forEach(key => {
+ Object.keys(value).forEach((key) => {
newValue[key] = genRouteChunkNames(value[key], key, name);
});
return newValue;
diff --git a/packages/docusaurus/src/server/themes/alias.ts b/packages/docusaurus/src/server/themes/alias.ts
index 936c7d407f..ebee107536 100644
--- a/packages/docusaurus/src/server/themes/alias.ts
+++ b/packages/docusaurus/src/server/themes/alias.ts
@@ -25,7 +25,7 @@ export function themeAlias(
const aliases: ThemeAlias = {};
- themeComponentFiles.forEach(relativeSource => {
+ themeComponentFiles.forEach((relativeSource) => {
const filePath = path.join(themePath, relativeSource);
const fileName = fileToPath(relativeSource);
diff --git a/packages/docusaurus/src/server/themes/index.ts b/packages/docusaurus/src/server/themes/index.ts
index fb2da680e0..20bb2c1a07 100644
--- a/packages/docusaurus/src/server/themes/index.ts
+++ b/packages/docusaurus/src/server/themes/index.ts
@@ -14,16 +14,16 @@ export function loadThemeAlias(
): ThemeAlias {
const aliases = {};
- themePaths.forEach(themePath => {
+ themePaths.forEach((themePath) => {
const themeAliases = themeAlias(themePath);
- Object.keys(themeAliases).forEach(aliasKey => {
+ Object.keys(themeAliases).forEach((aliasKey) => {
aliases[aliasKey] = themeAliases[aliasKey];
});
});
- userThemePaths.forEach(themePath => {
+ userThemePaths.forEach((themePath) => {
const userThemeAliases = themeAlias(themePath, false);
- Object.keys(userThemeAliases).forEach(aliasKey => {
+ Object.keys(userThemeAliases).forEach((aliasKey) => {
aliases[aliasKey] = userThemeAliases[aliasKey];
});
});
diff --git a/packages/docusaurus/src/webpack/__tests__/base.test.ts b/packages/docusaurus/src/webpack/__tests__/base.test.ts
index 08cb0f2bc8..07ce4ead6d 100644
--- a/packages/docusaurus/src/webpack/__tests__/base.test.ts
+++ b/packages/docusaurus/src/webpack/__tests__/base.test.ts
@@ -17,7 +17,7 @@ describe('babel transpilation exclude logic', () => {
'serverEntry.js',
path.join('exports', 'Link.js'),
];
- clientFiles.forEach(file => {
+ clientFiles.forEach((file) => {
expect(excludeJS(path.join(clientDir, file))).toEqual(false);
});
});
@@ -28,7 +28,7 @@ describe('babel transpilation exclude logic', () => {
'/website/src/components/foo.js',
'/src/theme/SearchBar/index.js',
];
- moduleFiles.forEach(file => {
+ moduleFiles.forEach((file) => {
expect(excludeJS(file)).toEqual(false);
});
});
@@ -39,7 +39,7 @@ describe('babel transpilation exclude logic', () => {
'node_modules/@docusaurus/theme-classic/theme/Layout.js',
'/docusaurus/website/node_modules/@docusaurus/theme-search-algolia/theme/SearchBar.js',
];
- moduleFiles.forEach(file => {
+ moduleFiles.forEach((file) => {
expect(excludeJS(file)).toEqual(false);
});
});
@@ -52,7 +52,7 @@ describe('babel transpilation exclude logic', () => {
'/docusaurus/website/node_modules/@docusaurus/core/node_modules/core-js/modules/_descriptors.js',
'node_modules/docusaurus-theme-classic/node_modules/react-daypicker/index.js',
];
- moduleFiles.forEach(file => {
+ moduleFiles.forEach((file) => {
expect(excludeJS(file)).toEqual(true);
});
});
diff --git a/packages/docusaurus/src/webpack/client.ts b/packages/docusaurus/src/webpack/client.ts
index ea87dc837f..896550bb68 100644
--- a/packages/docusaurus/src/webpack/client.ts
+++ b/packages/docusaurus/src/webpack/client.ts
@@ -47,8 +47,8 @@ export function createClientConfig(
// When building include the plugin to force terminate building if errors happened in the client bundle.
if (isBuilding) {
clientConfig.plugins!.push({
- apply: compiler => {
- compiler.hooks.done.tap('client:done', stats => {
+ apply: (compiler) => {
+ compiler.hooks.done.tap('client:done', (stats) => {
if (stats.hasErrors()) {
console.log(
chalk.red(
@@ -56,7 +56,7 @@ export function createClientConfig(
),
);
- stats.toJson('errors-only').errors.forEach(e => {
+ stats.toJson('errors-only').errors.forEach((e) => {
console.error(e);
});
diff --git a/packages/docusaurus/src/webpack/plugins/CleanWebpackPlugin.ts b/packages/docusaurus/src/webpack/plugins/CleanWebpackPlugin.ts
index 65bf23a77a..d5c397c718 100644
--- a/packages/docusaurus/src/webpack/plugins/CleanWebpackPlugin.ts
+++ b/packages/docusaurus/src/webpack/plugins/CleanWebpackPlugin.ts
@@ -212,11 +212,11 @@ class CleanWebpackPlugin {
}
if (hooks) {
- hooks.done.tap('clean-webpack-plugin', stats => {
+ hooks.done.tap('clean-webpack-plugin', (stats) => {
this.handleDone(stats);
});
} else {
- compiler.plugin('done', stats => {
+ compiler.plugin('done', (stats) => {
this.handleDone(stats);
});
}
@@ -272,7 +272,7 @@ class CleanWebpackPlugin {
*
* (relies on del's cwd: outputPath option)
*/
- const staleFiles = this.currentAssets.filter(previousAsset => {
+ const staleFiles = this.currentAssets.filter((previousAsset) => {
const assetCurrent = assets.includes(previousAsset) === false;
return assetCurrent;
@@ -319,7 +319,7 @@ class CleanWebpackPlugin {
* Log if verbose is enabled
*/
if (this.verbose) {
- deleted.forEach(file => {
+ deleted.forEach((file) => {
const filename = path.relative(process.cwd(), file);
const message = this.dry ? 'dry' : 'removed';
diff --git a/packages/docusaurus/src/webpack/plugins/LogPlugin.js b/packages/docusaurus/src/webpack/plugins/LogPlugin.js
index 575b243de7..d9ee7fdb8a 100644
--- a/packages/docusaurus/src/webpack/plugins/LogPlugin.js
+++ b/packages/docusaurus/src/webpack/plugins/LogPlugin.js
@@ -15,7 +15,7 @@ class LogPlugin extends WebpackBar {
apply(compiler) {
super.apply(compiler);
- compiler.hooks.done.tap('WebpackNiceLog', stats => {
+ compiler.hooks.done.tap('WebpackNiceLog', (stats) => {
if (stats.hasErrors()) {
const messages = formatWebpackMessages(
stats.toJson('errors-only', true),
diff --git a/packages/docusaurus/src/webpack/plugins/WaitPlugin.js b/packages/docusaurus/src/webpack/plugins/WaitPlugin.js
index 2e0c1e80b7..9b97513524 100644
--- a/packages/docusaurus/src/webpack/plugins/WaitPlugin.js
+++ b/packages/docusaurus/src/webpack/plugins/WaitPlugin.js
@@ -27,7 +27,7 @@ class WaitPlugin {
.then(() => {
callback();
})
- .catch(error => {
+ .catch((error) => {
console.warn(`WaitPlugin error: ${error}`);
});
});
diff --git a/packages/docusaurus/src/webpack/server.ts b/packages/docusaurus/src/webpack/server.ts
index a649b41560..bddd557a57 100644
--- a/packages/docusaurus/src/webpack/server.ts
+++ b/packages/docusaurus/src/webpack/server.ts
@@ -31,7 +31,7 @@ export function createServerConfig(
const routesLocation = {};
// Array of paths to be rendered. Relative to output directory
- const ssgPaths = routesPaths.map(str => {
+ const ssgPaths = routesPaths.map((str) => {
const ssgPath =
baseUrl === '/' ? str : str.replace(new RegExp(`^${baseUrl}`), '/');
routesLocation[ssgPath] = str;
diff --git a/packages/stylelint-copyright/index.js b/packages/stylelint-copyright/index.js
index b8b4dacc7b..6bfc74acd5 100644
--- a/packages/stylelint-copyright/index.js
+++ b/packages/stylelint-copyright/index.js
@@ -12,7 +12,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
rejected: 'Missing copyright in the header comment',
});
-module.exports = stylelint.createPlugin(ruleName, actual => {
+module.exports = stylelint.createPlugin(ruleName, (actual) => {
return (root, result) => {
const validOptions = stylelint.utils.validateOptions(result, ruleName, {
actual,
@@ -22,7 +22,7 @@ module.exports = stylelint.createPlugin(ruleName, actual => {
return;
}
- root.walkComments(comment => {
+ root.walkComments((comment) => {
// Ignore root comments with copyright text.
if (
comment === comment.parent.first &&
diff --git a/website-1.x/core/Showcase.js b/website-1.x/core/Showcase.js
index 5916a10377..d14fe22577 100644
--- a/website-1.x/core/Showcase.js
+++ b/website-1.x/core/Showcase.js
@@ -23,7 +23,7 @@ UserLink.propTypes = {
const Showcase = ({users}) => (
- {users.map(user => (
+ {users.map((user) => (
))}
diff --git a/website-1.x/pages/en/index.js b/website-1.x/pages/en/index.js
index 3e5e0d489b..d867b974be 100644
--- a/website-1.x/pages/en/index.js
+++ b/website-1.x/pages/en/index.js
@@ -55,7 +55,9 @@ function HomeSplash(props) {
class Index extends React.Component {
render() {
const {config: siteConfig, language = 'en'} = this.props;
- const pinnedUsersToShowcase = siteConfig.users.filter(user => user.pinned);
+ const pinnedUsersToShowcase = siteConfig.users.filter(
+ (user) => user.pinned,
+ );
return (
diff --git a/website-1.x/pages/en/users.js b/website-1.x/pages/en/users.js
index b8e4766ae4..79b1fd0d98 100644
--- a/website-1.x/pages/en/users.js
+++ b/website-1.x/pages/en/users.js
@@ -16,9 +16,11 @@ class Users extends React.Component {
render() {
const {config: siteConfig} = this.props;
const fbUsersToShowcase = siteConfig.users.filter(
- user => user.fbOpenSource,
+ (user) => user.fbOpenSource,
+ );
+ const restToShowcase = siteConfig.users.filter(
+ (user) => !user.fbOpenSource,
);
- const restToShowcase = siteConfig.users.filter(user => !user.fbOpenSource);
return (
diff --git a/website-1.x/pages/en/versions.js b/website-1.x/pages/en/versions.js
index e9fad9c74e..ca5bc8b8b6 100644
--- a/website-1.x/pages/en/versions.js
+++ b/website-1.x/pages/en/versions.js
@@ -71,7 +71,7 @@ function Versions(props) {
{versions.map(
- version =>
+ (version) =>
version !== latestVersion && (
diff --git a/website-1.x/static/js/code-blocks-buttons.js b/website-1.x/static/js/code-blocks-buttons.js
index 18878d9782..95e5d8848c 100644
--- a/website-1.x/static/js/code-blocks-buttons.js
+++ b/website-1.x/static/js/code-blocks-buttons.js
@@ -7,7 +7,7 @@
// Turn off ESLint for this file because it's sent down to users as-is.
/* eslint-disable */
-window.addEventListener('load', function() {
+window.addEventListener('load', function () {
function button(label, ariaLabel, icon, className) {
const btn = document.createElement('button');
btn.classList.add('btnIcon', className);
@@ -24,7 +24,7 @@ window.addEventListener('load', function() {
}
function addButtons(codeBlockSelector, btn) {
- document.querySelectorAll(codeBlockSelector).forEach(function(code) {
+ document.querySelectorAll(codeBlockSelector).forEach(function (code) {
code.parentNode.appendChild(btn.cloneNode(true));
});
}
@@ -38,16 +38,16 @@ window.addEventListener('load', function() {
);
const clipboard = new ClipboardJS('.btnClipboard', {
- target: function(trigger) {
+ target: function (trigger) {
return trigger.parentNode.querySelector('code');
},
});
- clipboard.on('success', function(event) {
+ clipboard.on('success', function (event) {
event.clearSelection();
const textEl = event.trigger.querySelector('.btnIcon__label');
textEl.textContent = 'Copied';
- setTimeout(function() {
+ setTimeout(function () {
textEl.textContent = 'Copy';
}, 2000);
});
diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js
index 31a8a5e51c..7e96fa74e5 100644
--- a/website/docusaurus.config.js
+++ b/website/docusaurus.config.js
@@ -100,7 +100,7 @@ module.exports = {
label: versions[0],
to: 'docs/introduction',
},
- ...versions.slice(1).map(version => ({
+ ...versions.slice(1).map((version) => ({
label: version,
to: `docs/${version}/introduction`,
})),
diff --git a/website/src/components/ColorGenerator/index.js b/website/src/components/ColorGenerator/index.js
index b21164bf53..6e46206152 100644
--- a/website/src/components/ColorGenerator/index.js
+++ b/website/src/components/ColorGenerator/index.js
@@ -65,11 +65,11 @@ function ColorGenerator({children, minHeight, url}) {
const [shades, setShades] = useState(COLOR_SHADES);
const color = Color('#' + baseColor);
const adjustedColors = Object.keys(shades)
- .map(shade => ({
+ .map((shade) => ({
...shades[shade],
variableName: shade,
}))
- .map(value => ({
+ .map((value) => ({
...value,
hex: color.darken(value.adjustment).hex(),
}));
@@ -84,7 +84,7 @@ function ColorGenerator({children, minHeight, url}) {
id="primary_color"
className={styles.input}
defaultValue={baseColor}
- onChange={event => {
+ onChange={(event) => {
const colorValue = event.target.value;
try {
Color('#' + colorValue);
@@ -107,7 +107,7 @@ function ColorGenerator({children, minHeight, url}) {
|
{adjustedColors
.sort((a, b) => a.displayOrder - b.displayOrder)
- .map(value => {
+ .map((value) => {
const {variableName, adjustment, adjustmentInput, hex} = value;
return (
@@ -134,7 +134,7 @@ function ColorGenerator({children, minHeight, url}) {
className={styles.input}
type="number"
value={adjustmentInput}
- onChange={event => {
+ onChange={(event) => {
const newValue = parseFloat(event.target.value);
setShades({
...shades,
@@ -163,7 +163,7 @@ function ColorGenerator({children, minHeight, url}) {
{adjustedColors
.sort((a, b) => a.codeOrder - b.codeOrder)
- .map(value => `${value.variableName}: ${value.hex.toLowerCase()};`)
+ .map((value) => `${value.variableName}: ${value.hex.toLowerCase()};`)
.join('\n')}
diff --git a/website/src/pages/index.js b/website/src/pages/index.js
index 7d367aa678..02221df65e 100644
--- a/website/src/pages/index.js
+++ b/website/src/pages/index.js
@@ -201,7 +201,7 @@ function Home() {
- {QUOTES.map(quote => (
+ {QUOTES.map((quote) => (
{DESCRIPTION}
- {users.map(user => (
+ {users.map((user) => (
diff --git a/website/src/pages/versions.js b/website/src/pages/versions.js
index c3f91a98e3..4773189a98 100644
--- a/website/src/pages/versions.js
+++ b/website/src/pages/versions.js
@@ -19,7 +19,7 @@ function Version() {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
const latestVersion = versions[0];
- const pastVersions = versions.filter(version => version !== latestVersion);
+ const pastVersions = versions.filter((version) => version !== latestVersion);
const repoUrl = `https://github.com/${siteConfig.organizationName}/${siteConfig.projectName}`;
return (
- {pastVersions.map(version => (
+ {pastVersions.map((version) => (
{version} |
diff --git a/website/src/plugins/remark-npm2yarn.js b/website/src/plugins/remark-npm2yarn.js
index 6092da7b71..3fb7dc6627 100644
--- a/website/src/plugins/remark-npm2yarn.js
+++ b/website/src/plugins/remark-npm2yarn.js
@@ -8,9 +8,9 @@
const npmToYarn = require('npm-to-yarn');
// E.g. global install: 'npm i' -> 'yarn'
-const convertNpmToYarn = npmCode => npmToYarn(npmCode, 'yarn');
+const convertNpmToYarn = (npmCode) => npmToYarn(npmCode, 'yarn');
-const transformNode = node => {
+const transformNode = (node) => {
const npmCode = node.value;
const yarnCode = convertNpmToYarn(node.value);
return [
@@ -46,7 +46,7 @@ const transformNode = node => {
];
};
-const matchNode = node => node.type === 'code' && node.meta === 'npm2yarn';
+const matchNode = (node) => node.type === 'code' && node.meta === 'npm2yarn';
const nodeForImport = {
type: 'import',
value:
@@ -55,7 +55,7 @@ const nodeForImport = {
module.exports = () => {
let transformed = false;
- const transformer = node => {
+ const transformer = (node) => {
if (matchNode(node)) {
transformed = true;
return transformNode(node);
diff --git a/website/src/scripts/canny.js b/website/src/scripts/canny.js
index 62a9319aed..97d995bc26 100644
--- a/website/src/scripts/canny.js
+++ b/website/src/scripts/canny.js
@@ -8,7 +8,7 @@
// Provided by Canny.
function canny() {
- !(function(w, d, i, s) {
+ !(function (w, d, i, s) {
function l() {
if (!d.getElementById(i)) {
let f = d.getElementsByTagName(s)[0],
@@ -20,7 +20,7 @@ function canny() {
}
}
if (typeof w.Canny !== 'function') {
- var c = function() {
+ var c = function () {
c.q.push(arguments);
};
(c.q = []),
|