diff --git a/.prettierignore b/.prettierignore
deleted file mode 100644
index 8494ac270647..000000000000
--- a/.prettierignore
+++ /dev/null
@@ -1 +0,0 @@
-v2
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
index a9f52d15309e..3eff994f47a6 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -5,5 +5,5 @@
"printWidth": 80,
"proseWrap": "never",
"singleQuote": true,
- "trailingComma": "es5"
+ "trailingComma": "all"
}
diff --git a/docusaurus-init/initialize.js b/docusaurus-init/initialize.js
index 942d469405a8..7b6c10d35f2d 100644
--- a/docusaurus-init/initialize.js
+++ b/docusaurus-init/initialize.js
@@ -7,53 +7,53 @@
* LICENSE file in the root directory of this source tree.
*/
-const shell = require("shelljs");
-const chalk = require("chalk");
-const fs = require("fs");
+const shell = require('shelljs');
+const chalk = require('chalk');
+const fs = require('fs');
const CWD = process.cwd();
let useYarn = false;
-if (shell.which("yarn")) {
+if (shell.which('yarn')) {
useYarn = true;
}
-if (fs.existsSync(CWD + "/website")) {
- console.error(chalk.yellow("Website folder already exists.\n"));
+if (fs.existsSync(CWD + '/website')) {
+ console.error(chalk.yellow('Website folder already exists.\n'));
console.log(
- "In order for Docusaurus to get set up as your static site generator, you will need to remove any existing 'website' folder from your root directory. If you are migrating from another static site generator, you may want to move your old website folder to a different location."
+ "In order for Docusaurus to get set up as your static site generator, you will need to remove any existing 'website' folder from your root directory. If you are migrating from another static site generator, you may want to move your old website folder to a different location.",
);
process.exit(1);
}
shell.cd(CWD);
-shell.mkdir("website");
+shell.mkdir('website');
-console.log(chalk.green("Website folder created!\n"));
+console.log(chalk.green('Website folder created!\n'));
-shell.cd("website");
+shell.cd('website');
console.log(
- chalk.yellow("Installing latest version of Docusaurus in website.\n")
+ chalk.yellow('Installing latest version of Docusaurus in website.\n'),
);
-const packageContent = { scripts: { examples: "docusaurus-examples" } };
+const packageContent = {scripts: {examples: 'docusaurus-examples'}};
fs.writeFileSync(
- CWD + "/website/package.json",
- JSON.stringify(packageContent, null, 2) + "\n"
+ CWD + '/website/package.json',
+ JSON.stringify(packageContent, null, 2) + '\n',
);
if (useYarn) {
- shell.exec("yarn add docusaurus --dev");
+ shell.exec('yarn add docusaurus --dev');
} else {
- shell.exec("npm install docusaurus --save-dev");
+ shell.exec('npm install docusaurus --save-dev');
}
-console.log(chalk.green("Docusaurus installed in website folder!\n"));
+console.log(chalk.green('Docusaurus installed in website folder!\n'));
if (useYarn) {
- shell.exec("yarn run examples");
+ shell.exec('yarn run examples');
} else {
- shell.exec("npm run examples");
+ shell.exec('npm run examples');
}
diff --git a/examples/basics/pages/en/help.js b/examples/basics/pages/en/help.js
index f50dbbb94c83..512e335a99cb 100755
--- a/examples/basics/pages/en/help.js
+++ b/examples/basics/pages/en/help.js
@@ -25,7 +25,7 @@ class Help extends React.Component {
{
content: `Learn more using the [documentation on this site.](${docUrl(
'doc1.html',
- language
+ language,
)})`,
title: 'Browse Docs',
},
diff --git a/examples/versions/pages/en/versions.js b/examples/versions/pages/en/versions.js
index d0895688fa67..286464fc177c 100644
--- a/examples/versions/pages/en/versions.js
+++ b/examples/versions/pages/en/versions.js
@@ -77,7 +77,7 @@ function Versions() {
Release Notes
- )
+ ),
)}
diff --git a/lib/__tests__/build-files.test.js b/lib/__tests__/build-files.test.js
index e2b5b7ed0c59..0260e582490f 100644
--- a/lib/__tests__/build-files.test.js
+++ b/lib/__tests__/build-files.test.js
@@ -68,7 +68,7 @@ describe('Build files', () => {
test('Generated HTML for each Markdown resource', () => {
const metadata = outputHTMLFiles.map(file =>
- filepath.create(file).basename()
+ filepath.create(file).basename(),
);
inputMarkdownFiles.forEach(file => {
const data = fs.readFileSync(file, 'utf8');
@@ -90,12 +90,12 @@ describe('Build files', () => {
siteConfig.projectName
}/css/main.css`;
const fileContents = await Promise.all(
- [combinedCSSFile, ...inputFiles].map(file => fs.readFile(file, 'utf8'))
+ [combinedCSSFile, ...inputFiles].map(file => fs.readFile(file, 'utf8')),
);
const [outputFileContent, ...inputFileContents] = fileContents;
const minifiedCssFiles = await Promise.all(
- inputFileContents.map(utils.minifyCss)
+ inputFileContents.map(utils.minifyCss),
);
minifiedCssFiles.forEach(fileContent => {
@@ -105,7 +105,7 @@ describe('Build files', () => {
test('Copied assets from /docs/assets', () => {
const metadata = outputAssetsFiles.map(file =>
- filepath.create(file).basename()
+ filepath.create(file).basename(),
);
inputAssetsFiles.forEach(file => {
const path = filepath.create(file);
diff --git a/lib/build-files.js b/lib/build-files.js
index 83ed4ceaa9ed..cd003b49aeaf 100755
--- a/lib/build-files.js
+++ b/lib/build-files.js
@@ -27,7 +27,7 @@ const CWD = process.cwd();
if (!fs.existsSync(`${CWD}/siteConfig.js`)) {
console.error(
- chalk.red('Error: No siteConfig.js file found in website folder!')
+ chalk.red('Error: No siteConfig.js file found in website folder!'),
);
process.exit(1);
}
diff --git a/lib/copy-examples.js b/lib/copy-examples.js
index c766676b7910..3fbc67b8b823 100755
--- a/lib/copy-examples.js
+++ b/lib/copy-examples.js
@@ -27,7 +27,7 @@ commander
// add scripts to package.json file
if (fs.existsSync(`${CWD}/package.json`)) {
const packageContent = JSON.parse(
- fs.readFileSync(`${CWD}/package.json`, 'utf8')
+ fs.readFileSync(`${CWD}/package.json`, 'utf8'),
);
if (!packageContent.scripts) {
packageContent.scripts = {};
@@ -42,10 +42,10 @@ if (fs.existsSync(`${CWD}/package.json`)) {
packageContent.scripts['rename-version'] = 'docusaurus-rename-version';
fs.writeFileSync(
`${CWD}/package.json`,
- `${JSON.stringify(packageContent, null, 2)}\n`
+ `${JSON.stringify(packageContent, null, 2)}\n`,
);
console.log(
- `${chalk.green('Wrote docusaurus scripts to package.json file.')}\n`
+ `${chalk.green('Wrote docusaurus scripts to package.json file.')}\n`,
);
}
@@ -62,8 +62,8 @@ if (feature === 'translations') {
if (fs.existsSync(`${CWD}/../crowdin.yaml`)) {
console.log(
`${chalk.yellow('crowdin.yaml already exists')} in ${chalk.yellow(
- `${outerFolder}/`
- )}. Rename or remove the file to regenerate an example version.\n`
+ `${outerFolder}/`,
+ )}. Rename or remove the file to regenerate an example version.\n`,
);
} else {
fs.copySync(`${folder}/crowdin.yaml`, `${CWD}/../crowdin.yaml`);
@@ -87,10 +87,10 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
- `${path.basename(filePath)} already exists`
+ `${path.basename(filePath)} already exists`,
)} in ${chalk.yellow(
- `website${filePath.split(path.basename(filePath))[0]}`
- )}. Rename or remove the file to regenerate an example version.\n`
+ `website${filePath.split(path.basename(filePath))[0]}`,
+ )}. Rename or remove the file to regenerate an example version.\n`,
);
}
});
@@ -112,10 +112,10 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
- `${path.basename(filePath)} already exists`
+ `${path.basename(filePath)} already exists`,
)} in ${chalk.yellow(
- `website${filePath.split(path.basename(filePath))[0]}`
- )}. Rename or remove the file to regenerate an example version.\n`
+ `website${filePath.split(path.basename(filePath))[0]}`,
+ )}. Rename or remove the file to regenerate an example version.\n`,
);
}
});
@@ -125,13 +125,13 @@ if (feature === 'translations') {
if (fs.existsSync(`${CWD}/../docs-examples-from-docusaurus`)) {
console.log(
`- ${chalk.green(
- 'docs-examples-from-docusaurus'
- )} already exists in ${chalk.blue(outerFolder)}.`
+ 'docs-examples-from-docusaurus',
+ )} already exists in ${chalk.blue(outerFolder)}.`,
);
} else {
fs.copySync(
`${folder}/docs-examples-from-docusaurus`,
- `${CWD}/../docs-examples-from-docusaurus`
+ `${CWD}/../docs-examples-from-docusaurus`,
);
exampleSiteCreated = true;
docsCreated = true;
@@ -140,13 +140,13 @@ if (feature === 'translations') {
if (fs.existsSync(`${CWD}/blog-examples-from-docusaurus`)) {
console.log(
`- ${chalk.green(
- 'blog-examples-from-docusaurus'
- )} already exists in ${chalk.blue(`${outerFolder}/website`)}.`
+ 'blog-examples-from-docusaurus',
+ )} already exists in ${chalk.blue(`${outerFolder}/website`)}.`,
);
} else {
fs.copySync(
path.join(folder, 'blog-examples-from-docusaurus'),
- path.join(CWD, 'blog-examples-from-docusaurus')
+ path.join(CWD, 'blog-examples-from-docusaurus'),
);
exampleSiteCreated = true;
blogCreated = true;
@@ -159,8 +159,8 @@ if (feature === 'translations') {
if (fs.existsSync(dest)) {
console.log(
`- ${chalk.green(copiedFileName)} already exists in ${chalk.blue(
- outerFolder
- )}.`
+ outerFolder,
+ )}.`,
);
} else {
fs.copySync(src, dest);
@@ -206,10 +206,10 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`- ${chalk.green(
- `${path.basename(filePath)}`
+ `${path.basename(filePath)}`,
)} already exists in ${chalk.blue(
- `${outerFolder}/website${filePath.split(path.basename(filePath))[0]}`
- )}.`
+ `${outerFolder}/website${filePath.split(path.basename(filePath))[0]}`,
+ )}.`,
);
}
});
@@ -233,19 +233,19 @@ if (feature === 'translations') {
if (docsCreated) {
console.log(
`Rename ${chalk.yellow(
- `${outerFolder}/docs-examples-from-docusaurus`
+ `${outerFolder}/docs-examples-from-docusaurus`,
)} to ${chalk.yellow(
- `${outerFolder}/docs`
- )} to see the example docs on your site.\n`
+ `${outerFolder}/docs`,
+ )} to see the example docs on your site.\n`,
);
}
if (blogCreated) {
console.log(
`Rename ${chalk.yellow(
- `${outerFolder}/website/blog-examples-from-docusaurus`
+ `${outerFolder}/website/blog-examples-from-docusaurus`,
)} to ${chalk.yellow(
- `${outerFolder}/website/blog`
- )} to see the example blog posts on your site.\n`
+ `${outerFolder}/website/blog`,
+ )} to see the example blog posts on your site.\n`,
);
}
diff --git a/lib/core/BlogPageLayout.js b/lib/core/BlogPageLayout.js
index 25098e6eec73..a63d4c3d4054 100644
--- a/lib/core/BlogPageLayout.js
+++ b/lib/core/BlogPageLayout.js
@@ -52,7 +52,7 @@ class BlogPageLayout extends React.Component {
}
config={this.props.config}
/>
- )
+ ),
)}
{page > 0 && (
diff --git a/lib/core/BlogPost.js b/lib/core/BlogPost.js
index da61433d71a5..bad8435d9dc0 100644
--- a/lib/core/BlogPost.js
+++ b/lib/core/BlogPost.js
@@ -25,7 +25,7 @@ class BlogPost extends React.Component {
className="button"
href={`${this.props.config.baseUrl}blog/${utils.getPath(
this.props.post.path,
- this.props.config.cleanUrl
+ this.props.config.cleanUrl,
)}`}>
Read More
@@ -66,7 +66,7 @@ class BlogPost extends React.Component {
{post.title}
diff --git a/lib/core/Doc.js b/lib/core/Doc.js
index 9c15e9542b6c..b3d3e1e3030e 100644
--- a/lib/core/Doc.js
+++ b/lib/core/Doc.js
@@ -11,10 +11,10 @@ const MarkdownBlock = require('./MarkdownBlock.js');
const translate = require('../server/translate.js').translate;
const editThisDoc = translate(
- 'Edit this Doc|recruitment message asking to edit the doc source'
+ 'Edit this Doc|recruitment message asking to edit the doc source',
);
const translateThisDoc = translate(
- 'Translate this Doc|recruitment message asking to translate the docs'
+ 'Translate this Doc|recruitment message asking to translate the docs',
);
// inner doc component for article itself
diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js
index 3f47790a0763..9fc259935a77 100644
--- a/lib/core/DocsLayout.js
+++ b/lib/core/DocsLayout.js
@@ -30,7 +30,7 @@ class DocsLayout extends React.Component {
.replace(/^\.\.\//, '') + extension;
return url.resolve(
`${this.props.config.baseUrl}${this.props.metadata.permalink}`,
- relativeHref
+ relativeHref,
);
};
@@ -95,7 +95,7 @@ class DocsLayout extends React.Component {
className="docs-prev button"
href={this.getRelativeURL(
metadata.localized_id,
- metadata.previous_id
+ metadata.previous_id,
)}>
β
) : (
- )
+ ),
)}
{this.props.config.scripts &&
this.props.config.scripts.map(
@@ -152,7 +152,7 @@ class Head extends React.Component {
) : (
- )
+ ),
)}
{this.props.config.scrollToTop && (
@@ -168,8 +168,8 @@ class Head extends React.Component {
Object.assign(
{},
{zIndex: 100},
- this.props.config.scrollToTopOptions
- )
+ this.props.config.scrollToTopOptions,
+ ),
)}
)
});
diff --git a/lib/core/Site.js b/lib/core/Site.js
index 7d83643a58ee..b013b05c9278 100644
--- a/lib/core/Site.js
+++ b/lib/core/Site.js
@@ -122,7 +122,7 @@ class Site extends React.Component {
indexName: '${this.props.config.algolia.indexName}',
inputSelector: '#search_input_react',
algoliaOptions: ${JSON.stringify(
- this.props.config.algolia.algoliaOptions
+ this.props.config.algolia.algoliaOptions,
)
.replace('VERSION', docsVersion)
.replace('LANGUAGE', this.props.language)}
diff --git a/lib/core/__tests__/anchors.test.js b/lib/core/__tests__/anchors.test.js
index f78b2f139c66..3a05596edaf0 100644
--- a/lib/core/__tests__/anchors.test.js
+++ b/lib/core/__tests__/anchors.test.js
@@ -22,10 +22,10 @@ const render = md.renderer.rules.heading_open;
test('Anchors rendering', () => {
expect(
- render([{hLevel: 1}, {content: 'Hello world'}], 0, {}, {})
+ render([{hLevel: 1}, {content: 'Hello world'}], 0, {}, {}),
).toMatchSnapshot();
expect(
- render([{hLevel: 2}, {content: 'Hello small world'}], 0, {}, {})
+ render([{hLevel: 2}, {content: 'Hello small world'}], 0, {}, {}),
).toMatchSnapshot();
});
@@ -48,22 +48,22 @@ test('Each anchor is unique across rendered document', () => {
const env = {};
expect(render(tokens, 0, options, env)).toContain(
- 'id="almost-unique-heading"'
+ 'id="almost-unique-heading"',
);
expect(render(tokens, 2, options, env)).toContain(
- 'id="almost-unique-heading-1"'
+ 'id="almost-unique-heading-1"',
);
expect(render(tokens, 4, options, env)).toContain(
- 'id="almost-unique-heading-1-1"'
+ 'id="almost-unique-heading-1-1"',
);
expect(render(tokens, 6, options, env)).toContain(
- 'id="almost-unique-heading-1-2"'
+ 'id="almost-unique-heading-1-2"',
);
expect(render(tokens, 8, options, env)).toContain(
- 'id="almost-unique-heading-2"'
+ 'id="almost-unique-heading-2"',
);
expect(render(tokens, 10, options, env)).toContain(
- 'id="almost-unique-heading-3"'
+ 'id="almost-unique-heading-3"',
);
});
@@ -99,17 +99,17 @@ test('Anchor index resets on each render', () => {
const env2 = {};
expect(render(tokens, 0, options, env)).toContain(
- 'id="almost-unique-heading"'
+ 'id="almost-unique-heading"',
);
expect(render(tokens, 2, options, env)).toContain(
- 'id="almost-unique-heading-1"'
+ 'id="almost-unique-heading-1"',
);
expect(render(tokens, 0, options, env2)).toContain(
- 'id="almost-unique-heading"'
+ 'id="almost-unique-heading"',
);
expect(render(tokens, 2, options, env2)).toContain(
- 'id="almost-unique-heading-1"'
+ 'id="almost-unique-heading-1"',
);
});
diff --git a/lib/core/__tests__/toc.test.js b/lib/core/__tests__/toc.test.js
index 6eaa87b57046..810af4fa410b 100644
--- a/lib/core/__tests__/toc.test.js
+++ b/lib/core/__tests__/toc.test.js
@@ -12,12 +12,12 @@ const {extractMetadata} = require('../../server/metadataUtils');
const getTOCmd = readFileSync(
path.join(__dirname, '__fixtures__', 'getTOC.md'),
- 'utf8'
+ 'utf8',
);
const insertTOCmd = readFileSync(
path.join(__dirname, '__fixtures__', 'insertTOC.md'),
- 'utf8'
+ 'utf8',
);
describe('getTOC', () => {
diff --git a/lib/core/__tests__/utils.test.js b/lib/core/__tests__/utils.test.js
index 342c95c7b5f7..02182eed7fe4 100644
--- a/lib/core/__tests__/utils.test.js
+++ b/lib/core/__tests__/utils.test.js
@@ -11,30 +11,30 @@ const utils = require('../utils');
const blogPostWithTruncateContents = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'blog-post-with-truncate.md'),
- 'utf8'
+ 'utf8',
);
const blogPostWithoutTruncateContents = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'blog-post-without-truncate.md'),
- 'utf8'
+ 'utf8',
);
describe('utils', () => {
test('blogPostHasTruncateMarker', () => {
expect(utils.blogPostHasTruncateMarker(blogPostWithTruncateContents)).toBe(
- true
+ true,
);
expect(
- utils.blogPostHasTruncateMarker(blogPostWithoutTruncateContents)
+ utils.blogPostHasTruncateMarker(blogPostWithoutTruncateContents),
).toBe(false);
});
test('extractBlogPostBeforeTruncate', () => {
expect(
- utils.extractBlogPostBeforeTruncate(blogPostWithTruncateContents)
+ utils.extractBlogPostBeforeTruncate(blogPostWithTruncateContents),
).toMatchSnapshot();
expect(
- utils.extractBlogPostBeforeTruncate(blogPostWithoutTruncateContents)
+ utils.extractBlogPostBeforeTruncate(blogPostWithoutTruncateContents),
).toMatchSnapshot();
});
@@ -42,7 +42,7 @@ describe('utils', () => {
// does not change/transform path
expect(utils.getPath('/en/users.html', false)).toBe('/en/users.html');
expect(utils.getPath('/docs/en/versioning.html', false)).toBe(
- '/docs/en/versioning.html'
+ '/docs/en/versioning.html',
);
expect(utils.getPath(undefined, false)).toBeUndefined();
expect(utils.getPath(null, false)).toBeNull();
@@ -85,7 +85,7 @@ describe('utils', () => {
const nonExistingFilePath = path.join(
__dirname,
'__fixtures__',
- '.nonExisting'
+ '.nonExisting',
);
expect(utils.getGitLastUpdated(null)).toBeNull();
expect(utils.getGitLastUpdated(undefined)).toBeNull();
@@ -133,7 +133,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/lib/core/nav/HeaderNav.js b/lib/core/nav/HeaderNav.js
index 893a67205fcd..75cdb5e337aa 100644
--- a/lib/core/nav/HeaderNav.js
+++ b/lib/core/nav/HeaderNav.js
@@ -31,7 +31,7 @@ class LanguageDropDown extends React.Component {
render() {
setLanguage(this.props.language || 'en');
const helpTranslateString = translate(
- 'Help Translate|recruit community translators for your project'
+ 'Help Translate|recruit community translators for your project',
);
// add all enabled languages to dropdown
const enabledLanguages = env.translation
@@ -49,7 +49,7 @@ class LanguageDropDown extends React.Component {
siteConfig.baseUrl +
this.props.current.permalink.replace(
`/${this.props.language}/`,
- `/${lang.tag}/`
+ `/${lang.tag}/`,
);
} else if (this.props.current.id && this.props.current.id !== 'index') {
href = `${siteConfig.baseUrl + lang.tag}/${this.props.current.id}`;
@@ -81,7 +81,7 @@ class LanguageDropDown extends React.Component {
rel="noreferrer noopener">
{helpTranslateString}
-
+ ,
);
}
@@ -251,20 +251,20 @@ class HeaderNav extends React.Component {
throw new Error(
`You have 'doc' in your headerLinks, but no '${readMetadata.getDocsPath()}' folder exists one level up from ` +
`'website' folder. Did you run \`docusaurus-init\` or \`npm run examples\`? If so, ` +
- `make sure you rename 'docs-examples-from-docusaurus' to 'docs'.`
+ `make sure you rename 'docs-examples-from-docusaurus' to 'docs'.`,
);
}
if (link.blog && !fs.existsSync(`${CWD}/blog/`)) {
throw new Error(
"You have 'blog' in your headerLinks, but no 'blog' folder exists in your " +
"'website' folder. Did you run `docusaurus-init` or `npm run examples`? If so, " +
- "make sure you rename 'blog-examples-from-docusaurus' to 'blog'."
+ "make sure you rename 'blog-examples-from-docusaurus' to 'blog'.",
);
}
if (link.page && !fs.existsSync(`${CWD}/pages/`)) {
throw new Error(
"You have 'page' in your headerLinks, but no 'pages' folder exists in your " +
- "'website' folder."
+ "'website' folder.",
);
}
// We will add search bar to end if location not specified
diff --git a/lib/core/nav/SideNav.js b/lib/core/nav/SideNav.js
index 8cc150a64ea5..56c980c9152c 100644
--- a/lib/core/nav/SideNav.js
+++ b/lib/core/nav/SideNav.js
@@ -55,7 +55,7 @@ class SideNav extends React.Component {
if (metadata.path) {
return `${siteConfig.baseUrl}blog/${getPath(
metadata.path,
- siteConfig.cleanUrl
+ siteConfig.cleanUrl,
)}`;
}
return null;
diff --git a/lib/core/toSlug.js b/lib/core/toSlug.js
index 263d776e4ca7..3e640b76624b 100644
--- a/lib/core/toSlug.js
+++ b/lib/core/toSlug.js
@@ -40,7 +40,7 @@ module.exports = (string, context = {}) => {
.toLowerCase()
// Handle accentuated characters
.replace(new RegExp(`[${accents}]`, 'g'), c =>
- without.charAt(accents.indexOf(c))
+ without.charAt(accents.indexOf(c)),
)
// Replace `.`, `(` and `?` with blank string like Github does
.replace(/\.|\(|\?/g, '')
diff --git a/lib/publish-gh-pages.js b/lib/publish-gh-pages.js
index a387b07435db..9aeb8c868909 100755
--- a/lib/publish-gh-pages.js
+++ b/lib/publish-gh-pages.js
@@ -42,14 +42,14 @@ const GITHUB_HOST =
if (!ORGANIZATION_NAME) {
shell.echo(
- "Missing project organization name. Did you forget to define 'organizationName' in siteConfig.js? You may also export it via the ORGANIZATION_NAME environment variable."
+ "Missing project organization name. Did you forget to define 'organizationName' in siteConfig.js? You may also export it via the ORGANIZATION_NAME environment variable.",
);
shell.exit(0);
}
if (!PROJECT_NAME) {
shell.echo(
- "Missing project name. Did you forget to define 'projectName' in siteConfig.js? You may also export it via the PROJECT_NAME environment variable."
+ "Missing project name. Did you forget to define 'projectName' in siteConfig.js? You may also export it via the PROJECT_NAME environment variable.",
);
shell.exit(0);
}
@@ -71,7 +71,7 @@ const currentRepoUrl = shell
.exec('git config --get remote.origin.url')
.stdout.trim();
const crossRepoPublish = !currentRepoUrl.endsWith(
- `${ORGANIZATION_NAME}/${PROJECT_NAME}.git`
+ `${ORGANIZATION_NAME}/${PROJECT_NAME}.git`,
);
// build static html files, then push to DEPLOYMENT_BRANCH branch of specified repo
@@ -160,7 +160,7 @@ fs.copy(
shell.exec('git add --all');
const commitResults = shell.exec(
- `git commit -m "Deploy website" -m "Deploy website version based on ${currentCommit}"`
+ `git commit -m "Deploy website" -m "Deploy website version based on ${currentCommit}"`,
);
if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo('Error: Git push failed');
@@ -174,5 +174,5 @@ fs.copy(
shell.echo(`Website is live at: ${websiteURL}`);
shell.exit(0);
}
- }
+ },
);
diff --git a/lib/rename-version.js b/lib/rename-version.js
index fe110c3de752..e94c5e1c5d94 100755
--- a/lib/rename-version.js
+++ b/lib/rename-version.js
@@ -47,8 +47,8 @@ if (
) {
console.error(
`${chalk.yellow(
- 'Version numbers are not properly specified!'
- )}\nSpecify as command line arguments: the current version you wish to rename, then the version number you want to rename it to. `
+ 'Version numbers are not properly specified!',
+ )}\nSpecify as command line arguments: the current version you wish to rename, then the version number you want to rename it to. `,
);
process.exit(1);
}
@@ -57,8 +57,8 @@ if (
if (!fs.existsSync(`${CWD}/versions.json`)) {
console.error(
`${chalk.yellow(
- 'No versions found!'
- )}\nNo versions.json file currently exists. Use the \`versions\` script if you wish to create new versions.`
+ 'No versions found!',
+ )}\nNo versions.json file currently exists. Use the \`versions\` script if you wish to create new versions.`,
);
process.exit(1);
}
@@ -70,8 +70,8 @@ const versionIndex = versions.indexOf(currentVersion);
if (versionIndex < 0) {
console.error(
`${chalk.yellow(
- `Version ${currentVersion} does not currently exist!`
- )}\n Version ${currentVersion} is not in the versions.json file. You can only rename existing versions.`
+ `Version ${currentVersion} does not currently exist!`,
+ )}\n Version ${currentVersion} is not in the versions.json file. You can only rename existing versions.`,
);
process.exit(1);
}
@@ -79,7 +79,7 @@ if (versionIndex < 0) {
versions[versionIndex] = newVersion;
fs.writeFileSync(
`${CWD}/versions.json`,
- `${JSON.stringify(versions, null, 2)}\n`
+ `${JSON.stringify(versions, null, 2)}\n`,
);
// if folder of docs for this version exists, rename folder and rewrite doc
@@ -87,7 +87,7 @@ fs.writeFileSync(
if (fs.existsSync(`${CWD}/versioned_docs/version-${currentVersion}`)) {
fs.renameSync(
`${CWD}/versioned_docs/version-${currentVersion}`,
- `${CWD}/versioned_docs/version-${newVersion}`
+ `${CWD}/versioned_docs/version-${newVersion}`,
);
const files = glob.sync(`${CWD}/versioned_docs/version-${newVersion}/*`);
@@ -104,7 +104,7 @@ if (fs.existsSync(`${CWD}/versioned_docs/version-${currentVersion}`)) {
}
metadata.id = metadata.id.replace(
`version-${currentVersion}-`,
- `version-${newVersion}-`
+ `version-${newVersion}-`,
);
fs.writeFileSync(file, makeHeader(metadata) + rawContent);
});
@@ -119,13 +119,13 @@ if (fs.existsSync(currentSidebarFile)) {
let sidebarContent = fs.readFileSync(newSidebarFile, 'utf8');
sidebarContent = sidebarContent.replace(
new RegExp(`version-${escapeStringRegexp(currentVersion)}-`, 'g'),
- `version-${newVersion}-`
+ `version-${newVersion}-`,
);
fs.writeFileSync(newSidebarFile, sidebarContent);
}
console.log(
`${chalk.green('Successfully renamed version ')}${chalk.yellow(
- currentVersion
- )}${chalk.green(' to version ')}${chalk.yellow(newVersion)}\n`
+ currentVersion,
+ )}${chalk.green(' to version ')}${chalk.yellow(newVersion)}\n`,
);
diff --git a/lib/server/__tests__/blog.test.js b/lib/server/__tests__/blog.test.js
index 442ba0de18d2..4665858f105d 100644
--- a/lib/server/__tests__/blog.test.js
+++ b/lib/server/__tests__/blog.test.js
@@ -11,7 +11,7 @@ const blog = require('../blog');
const testFile = path.join(
__dirname,
'__fixtures__',
- '2018-08-17-docusaurus.md'
+ '2018-08-17-docusaurus.md',
);
fs.existsSync = jest.fn().mockReturnValue(true);
@@ -59,10 +59,10 @@ describe('urlToSource', () => {
});
test('valid url path', () => {
expect(blog.urlToSource(`${blog.fileToUrl(testFile)}`)).toEqual(
- '2018-08-17-docusaurus.md'
+ '2018-08-17-docusaurus.md',
);
expect(blog.urlToSource('2018/03/04/test-name-lol.html')).toEqual(
- '2018-03-04-test-name-lol.md'
+ '2018-03-04-test-name-lol.md',
);
});
});
diff --git a/lib/server/__tests__/docs.test.js b/lib/server/__tests__/docs.test.js
index 0624538e8b41..2437b2f3094a 100644
--- a/lib/server/__tests__/docs.test.js
+++ b/lib/server/__tests__/docs.test.js
@@ -42,12 +42,12 @@ const Metadata = require(path.join(__dirname, '__fixtures__', 'metadata.js'));
const doc1 = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'doc1.md'),
- 'utf8'
+ 'utf8',
);
const doc2 = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'doc2.md'),
- 'utf8'
+ 'utf8',
);
const rawContent1 = metadataUtils.extractMetadata(doc1).rawContent;
@@ -60,7 +60,7 @@ describe('mdToHtmlify', () => {
const content1 = docs.mdToHtmlify(
rawContent1,
mdToHtml,
- Metadata['en-doc1']
+ Metadata['en-doc1'],
);
expect(content1).not.toContain('/docs/en/next/');
expect(content1).toMatchSnapshot();
@@ -71,7 +71,7 @@ describe('mdToHtmlify', () => {
const content2 = docs.mdToHtmlify(
rawContent2,
mdToHtml,
- Metadata['en-doc2']
+ Metadata['en-doc2'],
);
expect(content2).toContain('/docs/en/next/');
expect(content2).toMatchSnapshot();
@@ -108,21 +108,21 @@ describe('getFile', () => {
test('translated docs', () => {
const metadata = Metadata['ko-doc1'];
expect(docs.getFile(metadata)).toEqual(
- fakeContent['website/translated_docs/ko/doc1.md']
+ fakeContent['website/translated_docs/ko/doc1.md'],
);
});
test('versioned docs', () => {
const metadata = Metadata['en-version-1.0.0-doc2'];
expect(docs.getFile(metadata)).toEqual(
- fakeContent['website/versioned_docs/version-1.0.0/doc2.md']
+ fakeContent['website/versioned_docs/version-1.0.0/doc2.md'],
);
});
test('translated & versioned docs', () => {
const metadata = Metadata['ko-version-1.0.0-doc1'];
expect(docs.getFile(metadata)).toEqual(
- fakeContent['website/translated_docs/ko/version-1.0.0/doc1.md']
+ fakeContent['website/translated_docs/ko/version-1.0.0/doc1.md'],
);
});
diff --git a/lib/server/__tests__/start.test.js b/lib/server/__tests__/start.test.js
index e175cc4a2f11..c394a5081c6f 100644
--- a/lib/server/__tests__/start.test.js
+++ b/lib/server/__tests__/start.test.js
@@ -52,7 +52,7 @@ describe('start live reload', () => {
const unusedPortError = new Error('no unused port');
portFinder.getPortPromise.mockRejectedValue(unusedPortError);
return expect(start.startLiveReloadServer()).rejects.toEqual(
- unusedPortError
+ unusedPortError,
);
});
});
diff --git a/lib/server/__tests__/utils.test.js b/lib/server/__tests__/utils.test.js
index 78769fbf111a..017140e09822 100644
--- a/lib/server/__tests__/utils.test.js
+++ b/lib/server/__tests__/utils.test.js
@@ -30,11 +30,11 @@ describe('server utils', () => {
test('minify css', () => {
const testCss = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'test.css'),
- 'utf8'
+ 'utf8',
);
const notCss = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'test.md'),
- 'utf8'
+ 'utf8',
);
utils.minifyCss(testCss).then(css => expect(css).toMatchSnapshot());
utils.minifyCss(notCss).catch(e => expect(e).toMatchSnapshot());
@@ -43,7 +43,7 @@ describe('server utils', () => {
test('autoprefix css', () => {
const testCss = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'test.css'),
- 'utf8'
+ 'utf8',
);
utils.autoPrefixCss(testCss).then(css => expect(css).toMatchSnapshot());
@@ -56,14 +56,14 @@ describe('server utils', () => {
'translated_docs',
'ja',
'en',
- 'test.md'
+ 'test.md',
);
const testDocInSubfolder = path.join('docs', 'ro', 'test.md');
const testDocNoLanguage = path.join('docs', 'test.md');
expect(utils.getLanguage(testDocEnglish, 'translated_docs')).toBe('en');
expect(utils.getLanguage(testDocJapanese, 'translated_docs')).toBe('ja');
expect(
- utils.getLanguage(testDocJapaneseInSubfolder, 'translated_docs')
+ utils.getLanguage(testDocJapaneseInSubfolder, 'translated_docs'),
).toBe('ja');
expect(utils.getLanguage(testDocInSubfolder, 'docs')).toBeNull();
expect(utils.getLanguage(testDocNoLanguage, 'docs')).toBeNull();
diff --git a/lib/server/blog.js b/lib/server/blog.js
index 0c218efc8034..d8522b50ee44 100644
--- a/lib/server/blog.js
+++ b/lib/server/blog.js
@@ -53,11 +53,11 @@ function getMetadata(file) {
return null;
}
const result = metadataUtils.extractMetadata(
- fs.readFileSync(file, {encoding: 'utf8'})
+ fs.readFileSync(file, {encoding: 'utf8'}),
);
const metadata = Object.assign(
{path: fileToUrl(file), content: result.rawContent},
- result.metadata
+ result.metadata,
);
metadata.id = metadata.title;
return metadata;
diff --git a/lib/server/docs.js b/lib/server/docs.js
index 387985198a05..dc650f3c1231 100644
--- a/lib/server/docs.js
+++ b/lib/server/docs.js
@@ -67,11 +67,11 @@ function mdToHtmlify(oldContent, mdToHtml, metadata) {
'/VERSION/',
metadata.version && metadata.version !== env.versioning.latestVersion
? `/${metadata.version}/`
- : '/'
+ : '/',
);
content = content.replace(
new RegExp(`\\]\\((\\./)?${mdLink}`, 'g'),
- `](${htmlLink}`
+ `](${htmlLink}`,
);
}
});
@@ -108,7 +108,7 @@ function getMarkup(rawContent, mdToHtml, metadata) {
language={metadata.language}
config={siteConfig}>
{content}
-
+ ,
);
}
@@ -124,7 +124,7 @@ function getRedirectMarkup(metadata) {
language={metadata.language}
config={siteConfig}
redirect={siteConfig.baseUrl + redirectlink}
- />
+ />,
);
}
diff --git a/lib/server/env.js b/lib/server/env.js
index 8e13a1558f79..751cfc144478 100644
--- a/lib/server/env.js
+++ b/lib/server/env.js
@@ -57,7 +57,7 @@ class Versioning {
console.error(
`${chalk.yellow('No versions.js file found!')}` +
`\nYou should create your versions.js file in pages/en directory.` +
- `\nPlease refer to https://docusaurus.io/docs/en/versioning.html.`
+ `\nPlease refer to https://docusaurus.io/docs/en/versioning.html.`,
);
}
diff --git a/lib/server/generate.js b/lib/server/generate.js
index 26977c1ee5e5..7160d0c315b8 100644
--- a/lib/server/generate.js
+++ b/lib/server/generate.js
@@ -87,7 +87,7 @@ async function execute() {
}
const redirectFile = join(
buildDir,
- metadata.permalink.replace('docs/en', 'docs')
+ metadata.permalink.replace('docs/en', 'docs'),
);
writeFileAndCreateFolder(redirectFile, redirectMarkup);
});
@@ -96,7 +96,7 @@ async function execute() {
if (fs.existsSync(join(CWD, '..', readMetadata.getDocsPath(), 'assets'))) {
fs.copySync(
join(CWD, '..', readMetadata.getDocsPath(), 'assets'),
- join(buildDir, 'docs', 'assets')
+ join(buildDir, 'docs', 'assets'),
);
}
@@ -176,8 +176,8 @@ async function execute() {
) {
console.error(
`${chalk.yellow(
- 'Missing color configuration.'
- )} Make sure siteConfig.colors includes primaryColor and secondaryColor fields.`
+ 'Missing color configuration.',
+ )} Make sure siteConfig.colors includes primaryColor and secondaryColor fields.`,
);
}
@@ -193,7 +193,7 @@ async function execute() {
.join(', ');
cssContent = cssContent.replace(
new RegExp(`\\$${key}`, 'g'),
- fontString
+ fontString,
);
});
}
@@ -234,7 +234,7 @@ async function execute() {
.join(', ');
cssContent = cssContent.replace(
new RegExp(`\\$${key}`, 'g'),
- fontString
+ fontString,
);
});
}
@@ -296,7 +296,7 @@ async function execute() {
let tempFile = join(__dirname, '..', 'pages', relativeFile);
tempFile = tempFile.replace(
path.basename(normalizedFile),
- `temp${path.basename(normalizedFile)}`
+ `temp${path.basename(normalizedFile)}`,
);
mkdirp.sync(path.dirname(tempFile));
fs.copySync(normalizedFile, tempFile);
@@ -308,8 +308,8 @@ async function execute() {
const regexLang = new RegExp(
`${escapeStringRegexp(`${userPagesDir}${sep}`)}(.*)${escapeStringRegexp(
- sep
- )}`
+ sep,
+ )}`,
);
const match = regexLang.exec(normalizedFile);
const langParts = match[1].split(sep);
@@ -321,7 +321,7 @@ async function execute() {
if (
language === 'en' ||
!fs.existsSync(
- normalizedFile.replace(`${sep}en${sep}`, sep + language + sep)
+ normalizedFile.replace(`${sep}en${sep}`, sep + language + sep),
)
) {
translate.setLanguage(language);
@@ -333,12 +333,12 @@ async function execute() {
description={ReactComp.description}
metadata={{id: pageID}}>
-
+ ,
);
writeFileAndCreateFolder(
// TODO: use path functions
targetFile.replace(`${sep}en${sep}`, sep + language + sep),
- str
+ str,
);
}
}
@@ -354,11 +354,11 @@ async function execute() {
description={ReactComp.description}
metadata={{id: pageID}}>
-
+ ,
);
writeFileAndCreateFolder(
targetFile.replace(`${sep}en${sep}`, sep),
- str
+ str,
);
} else {
// allow for rendering of other files not in pages/en folder
@@ -372,11 +372,11 @@ async function execute() {
description={ReactComp.description}
metadata={{id: pageID}}>
-
+ ,
);
writeFileAndCreateFolder(
targetFile.replace(`${sep}en${sep}`, sep),
- str
+ str,
);
}
fs.removeSync(tempFile);
@@ -390,7 +390,7 @@ async function execute() {
__html: fs.readFileSync(normalizedFile, {encoding: 'utf8'}),
}}
/>
-
+ ,
);
writeFileAndCreateFolder(targetFile, str);
diff --git a/lib/server/liveReloadServer.js b/lib/server/liveReloadServer.js
index 754f4b301d3d..59a0e0bb3ee8 100644
--- a/lib/server/liveReloadServer.js
+++ b/lib/server/liveReloadServer.js
@@ -24,7 +24,7 @@ function start(port) {
this.on('all', () => {
server.notifyClients(['/']);
});
- }
+ },
);
reloadScriptUrl = `http://localhost:${port}/livereload.js`;
diff --git a/lib/server/readCategories.js b/lib/server/readCategories.js
index 21c22427c5bb..472d7521074f 100644
--- a/lib/server/readCategories.js
+++ b/lib/server/readCategories.js
@@ -64,7 +64,7 @@ function readCategories(sidebar) {
}' not found. Make sure that all documents with ids specified in this version's sidebar file exist and that no ids are repeated.`
: `Improper sidebars.json file, document with id '${
metadata.next
- }' not found. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated.`
+ }' not found. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated.`,
);
}
previous[articles[metadata.next].id] = metadata.id;
diff --git a/lib/server/readMetadata.js b/lib/server/readMetadata.js
index 74d73ba0b59c..120a4681ffee 100644
--- a/lib/server/readMetadata.js
+++ b/lib/server/readMetadata.js
@@ -251,7 +251,7 @@ function generateMetadataDocs() {
if (order[id].next) {
metadata.next_id = order[id].next.replace(
`version-${metadata.version}-`,
- ''
+ '',
);
metadata.next =
(env.translation.enabled ? `${metadata.language}-` : '') +
@@ -260,7 +260,7 @@ function generateMetadataDocs() {
if (order[id].previous) {
metadata.previous_id = order[id].previous.replace(
`version-${metadata.version}-`,
- ''
+ '',
);
metadata.previous =
(env.translation.enabled ? `${metadata.language}-` : '') +
@@ -297,7 +297,7 @@ function generateMetadataDocs() {
' * @' +
'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`,
);
}
@@ -323,7 +323,7 @@ function generateMetadataBlog() {
metadata.date = new Date(
`${filePathDateArr[0]}-${filePathDateArr[1]}-${
filePathDateArr[2]
- }T06:00:00.000Z`
+ }T06:00:00.000Z`,
);
// allow easier sorting of blog by providing seconds since epoch
metadata.seconds = Math.round(metadata.date.getTime() / 1000);
@@ -332,7 +332,7 @@ function generateMetadataBlog() {
});
const sortedMetadatas = metadatas.sort(
- (a, b) => parseInt(b.seconds, 10) - parseInt(a.seconds, 10)
+ (a, b) => parseInt(b.seconds, 10) - parseInt(a.seconds, 10),
);
fs.writeFileSync(
@@ -341,7 +341,7 @@ function generateMetadataBlog() {
' * @' +
'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/lib/server/routing.js b/lib/server/routing.js
index 41039088cc35..cd5d99815d1c 100644
--- a/lib/server/routing.js
+++ b/lib/server/routing.js
@@ -27,7 +27,7 @@ function noExtension() {
function page(baseUrl) {
const gr = regex => regex.toString().replace(/(^\/|\/$)/gm, '');
return new RegExp(
- `(?!${gr(docs(baseUrl))}|${gr(blog(baseUrl))})^${baseUrl}.*.html$`
+ `(?!${gr(docs(baseUrl))}|${gr(blog(baseUrl))})^${baseUrl}.*.html$`,
);
}
diff --git a/lib/server/server.js b/lib/server/server.js
index b09df602945d..1ea0caad8282 100644
--- a/lib/server/server.js
+++ b/lib/server/server.js
@@ -186,8 +186,8 @@ function execute(port) {
fs.existsSync(
(htmlFile = htmlFile.replace(
path.basename(htmlFile),
- join('en', path.basename(htmlFile))
- ))
+ join('en', path.basename(htmlFile)),
+ )),
)
) {
if (siteConfig.wrapPagesHTML) {
@@ -203,7 +203,7 @@ function execute(port) {
__html: fs.readFileSync(htmlFile, {encoding: 'utf8'}),
}}
/>
-
+ ,
);
res.send(str);
@@ -244,8 +244,8 @@ function execute(port) {
fs.existsSync(
(userFile = userFile.replace(
path.basename(userFile),
- `en${sep}${path.basename(userFile)}`
- ))
+ `en${sep}${path.basename(userFile)}`,
+ )),
) ||
fs.existsSync((userFile = englishFile))
) {
@@ -254,7 +254,7 @@ function execute(port) {
let tempFile = join(__dirname, '..', 'pages', userFileParts[1]);
tempFile = tempFile.replace(
path.basename(file),
- `temp${path.basename(file)}`
+ `temp${path.basename(file)}`,
);
mkdirp.sync(path.dirname(tempFile));
fs.copySync(userFile, tempFile);
@@ -273,7 +273,7 @@ function execute(port) {
description={ReactComp.description}
metadata={{id: path.basename(userFile, '.js')}}>
-
+ ,
);
fs.removeSync(tempFile);
@@ -289,7 +289,7 @@ function execute(port) {
__dirname,
'..',
'static',
- req.path.toString().replace(siteConfig.baseUrl, '/')
+ req.path.toString().replace(siteConfig.baseUrl, '/'),
);
let cssContent = fs.readFileSync(mainCssPath, {encoding: 'utf8'});
@@ -311,8 +311,8 @@ function execute(port) {
) {
console.error(
`${chalk.yellow(
- 'Missing color configuration.'
- )} Make sure siteConfig.colors includes primaryColor and secondaryColor fields.`
+ 'Missing color configuration.',
+ )} Make sure siteConfig.colors includes primaryColor and secondaryColor fields.`,
);
}
@@ -328,7 +328,7 @@ function execute(port) {
.join(', ');
cssContent = cssContent.replace(
new RegExp(`\\$${key}`, 'g'),
- fontString
+ fontString,
);
});
}
@@ -340,11 +340,11 @@ function execute(port) {
// serve static assets from these locations
app.use(
`${siteConfig.baseUrl}docs/assets`,
- express.static(join(CWD, '..', readMetadata.getDocsPath(), 'assets'))
+ express.static(join(CWD, '..', readMetadata.getDocsPath(), 'assets')),
);
app.use(
`${siteConfig.baseUrl}blog/assets`,
- express.static(join(CWD, 'blog', 'assets'))
+ express.static(join(CWD, 'blog', 'assets')),
);
app.use(siteConfig.baseUrl, express.static(join(CWD, 'static')));
app.use(siteConfig.baseUrl, express.static(join(__dirname, '..', 'static')));
@@ -360,7 +360,7 @@ function execute(port) {
? `${requestUrl}.html`
: requestUrl.replace(/\/$/, '.html'),
res,
- next
+ next,
);
});
});
diff --git a/lib/server/translate-plugin.js b/lib/server/translate-plugin.js
index 6b642d4418b3..cb3c351950bd 100644
--- a/lib/server/translate-plugin.js
+++ b/lib/server/translate-plugin.js
@@ -31,14 +31,14 @@ module.exports = function translatePlugin(babel) {
t.jSXExpressionContainer(
t.callExpression(t.identifier('translate'), [
t.stringLiteral(`${text}|${description}`),
- ])
- )
+ ]),
+ ),
);
} else {
path.replaceWith(
t.callExpression(t.identifier('translate'), [
t.stringLiteral(`${text}|${description}`),
- ])
+ ]),
);
}
},
diff --git a/lib/server/translate.js b/lib/server/translate.js
index 68d929e8dc23..f51757ec9d62 100644
--- a/lib/server/translate.js
+++ b/lib/server/translate.js
@@ -47,13 +47,13 @@ function translate(str) {
// if a translated string doesn't exist, but english does then fallback
if (doesTranslationExist(str, 'en')) {
console.error(
- `Could not find a string translation in '${language}' for string '${str}'. Using English version instead.`
+ `Could not find a string translation in '${language}' for string '${str}'. Using English version instead.`,
);
return parseEscapeSequences(translation.en['pages-strings'][str]);
}
throw new Error(
- `Text that you've identified for translation ('${str}') hasn't been added to the global list in 'en.json'. To solve this problem run 'yarn write-translations'.`
+ `Text that you've identified for translation ('${str}') hasn't been added to the global list in 'en.json'. To solve this problem run 'yarn write-translations'.`,
);
}
return parseEscapeSequences(translation[language]['pages-strings'][str]);
diff --git a/lib/server/utils.js b/lib/server/utils.js
index 1f353db9e122..430086a078b0 100644
--- a/lib/server/utils.js
+++ b/lib/server/utils.js
@@ -20,7 +20,7 @@ function getLanguage(file, refDir) {
const separator = escapeStringRegexp(path.sep);
const baseDir = escapeStringRegexp(path.basename(refDir));
const regexSubFolder = new RegExp(
- `${baseDir}${separator}(.*?)${separator}.*`
+ `${baseDir}${separator}(.*?)${separator}.*`,
);
const match = regexSubFolder.exec(file);
diff --git a/lib/server/versionFallback.js b/lib/server/versionFallback.js
index bebd034dd196..49fb8f431fa6 100644
--- a/lib/server/versionFallback.js
+++ b/lib/server/versionFallback.js
@@ -58,10 +58,10 @@ files.forEach(file => {
if (!metadata.original_id) {
console.error(
- `No 'original_id' field found in ${file}. Perhaps you forgot to add it when importing prior versions of your docs?`
+ `No 'original_id' field found in ${file}. Perhaps you forgot to add it when importing prior versions of your docs?`,
);
throw new Error(
- `No 'original_id' field found in ${file}. Perhaps you forgot to add it when importing prior versions of your docs?`
+ `No 'original_id' field found in ${file}. Perhaps you forgot to add it when importing prior versions of your docs?`,
);
}
if (!metadata.id) {
@@ -69,10 +69,10 @@ files.forEach(file => {
throw new Error(`No 'id' field found in ${file}.`);
} else if (metadata.id.indexOf('version-') === -1) {
console.error(
- `The 'id' field in ${file} is missing the expected 'version-XX-' prefix. Perhaps you forgot to add it when importing prior versions of your docs?`
+ `The 'id' field in ${file} is missing the expected 'version-XX-' prefix. Perhaps you forgot to add it when importing prior versions of your docs?`,
);
throw new Error(
- `The 'id' field in ${file} is missing the expected 'version-XX-' prefix. Perhaps you forgot to add it when importing prior versions of your docs?`
+ `The 'id' field in ${file} is missing the expected 'version-XX-' prefix. Perhaps you forgot to add it when importing prior versions of your docs?`,
);
}
@@ -85,7 +85,7 @@ files.forEach(file => {
// e.g. version-1.0.0-getting-started => 1.0.0
const version = metadata.id.substring(
metadata.id.indexOf('version-') + 8, // version- is 8 characters
- metadata.id.lastIndexOf(`-${metadata.original_id}`)
+ metadata.id.lastIndexOf(`-${metadata.original_id}`),
);
available[metadata.original_id].add(version);
@@ -161,13 +161,13 @@ function processVersionMetadata(file, version, useVersion, language) {
// and original_id `readme` will have metadata id of `version-1.1.6-projectA/readme` and original_id `projectA/readme`
const subDir = utils.getSubDir(
file,
- path.join(CWD, 'versioned_docs', `version-${useVersion}`)
+ path.join(CWD, 'versioned_docs', `version-${useVersion}`),
);
if (subDir) {
metadata.original_id = `${subDir}/${metadata.original_id}`;
metadata.id = metadata.id.replace(
`version-${useVersion}-`,
- `version-${useVersion}-${subDir}/`
+ `version-${useVersion}-${subDir}/`,
);
}
@@ -188,7 +188,7 @@ function processVersionMetadata(file, version, useVersion, language) {
}
metadata.id = metadata.id.replace(
`version-${useVersion}-`,
- `version-${version}-`
+ `version-${version}-`,
);
metadata.localized_id = metadata.id;
metadata.id = (env.translation.enabled ? `${language}-` : '') + metadata.id;
@@ -225,7 +225,7 @@ function docData() {
const file = versionFiles[useVersion][id];
metadatas.push(
- processVersionMetadata(file, version, useVersion, language.tag)
+ processVersionMetadata(file, version, useVersion, language.tag),
);
});
});
@@ -246,14 +246,14 @@ function sidebarVersion(reqVersion) {
if (
requestedFound &&
fs.existsSync(
- `${CWD}/versioned_sidebars/version-${versions[i]}-sidebars.json`
+ `${CWD}/versioned_sidebars/version-${versions[i]}-sidebars.json`,
)
) {
return versions[i];
}
}
throw new Error(
- `No sidebar file available to use for version ${reqVersion}. Verify that 'version-${reqVersion}-sidebars.json' exists.`
+ `No sidebar file available to use for version ${reqVersion}. Verify that 'version-${reqVersion}-sidebars.json' exists.`,
);
}
@@ -281,7 +281,7 @@ function diffLatestSidebar() {
return (
JSON.stringify(JSON.parse(fs.readFileSync(latestSidebar, 'utf8'))).replace(
new RegExp(`version-${version}-`, 'g'),
- ''
+ '',
) !== JSON.stringify(JSON.parse(fs.readFileSync(currentSidebar, 'utf8')))
);
}
@@ -296,12 +296,12 @@ function sidebarData() {
fs
.readFileSync(
`${CWD}/versioned_sidebars/version-${version}-sidebars.json`,
- 'utf8'
+ 'utf8',
)
.replace(
new RegExp(`version-${version}-`, 'g'),
- `version-${versions[i]}-`
- )
+ `version-${versions[i]}-`,
+ ),
);
Object.assign(allSidebars, sidebar);
}
diff --git a/lib/start-server.js b/lib/start-server.js
index c31f9c324ec9..3afe5f90f16e 100755
--- a/lib/start-server.js
+++ b/lib/start-server.js
@@ -29,7 +29,7 @@ const {startDocusaurus} = require('./server/start.js');
if (!fs.existsSync(`${CWD}/siteConfig.js`)) {
console.error(
- chalk.red('Error: No siteConfig.js file found in website folder!')
+ chalk.red('Error: No siteConfig.js file found in website folder!'),
);
process.exit(1);
}
diff --git a/lib/version.js b/lib/version.js
index f897cb352b47..e4d4b5fd38fc 100755
--- a/lib/version.js
+++ b/lib/version.js
@@ -56,8 +56,8 @@ if (env.versioning.missingVersionsPage) {
if (typeof version === 'undefined') {
console.error(
`${chalk.yellow(
- 'No version number specified!'
- )}\nPass the version you wish to create as an argument.\nEx: 1.0.0`
+ 'No version number specified!',
+ )}\nPass the version you wish to create as an argument.\nEx: 1.0.0`,
);
process.exit(1);
}
@@ -65,8 +65,8 @@ if (typeof version === 'undefined') {
if (versions.includes(version)) {
console.error(
`${chalk.yellow(
- 'This version already exists!'
- )}\nSpecify a new version to create that does not already exist.`
+ 'This version already exists!',
+ )}\nSpecify a new version to create that does not already exist.`,
);
process.exit(1);
}
@@ -131,7 +131,7 @@ files.forEach(file => {
writeFileAndCreateFolder(
targetFile,
makeHeader(metadata) + rawContent,
- 'utf8'
+ 'utf8',
);
});
@@ -159,7 +159,7 @@ if (versionFallback.diffLatestSidebar()) {
fs.writeFileSync(
`${CWD}/versioned_sidebars/version-${version}-sidebars.json`,
`${JSON.stringify(versioned, null, 2)}\n`,
- 'utf8'
+ 'utf8',
);
}
@@ -167,7 +167,7 @@ if (versionFallback.diffLatestSidebar()) {
versions.unshift(version);
fs.writeFileSync(
`${CWD}/versions.json`,
- `${JSON.stringify(versions, null, 2)}\n`
+ `${JSON.stringify(versions, null, 2)}\n`,
);
console.log(`${chalk.green(`Version ${version} created!\n`)}`);
diff --git a/lib/write-translations.js b/lib/write-translations.js
index ce3f9aad8fbe..3ac558f23120 100755
--- a/lib/write-translations.js
+++ b/lib/write-translations.js
@@ -45,9 +45,9 @@ let customTranslations = {
if (fs.existsSync(`${CWD}/data/custom-translation-strings.json`)) {
customTranslations = deepmerge(
JSON.parse(
- fs.readFileSync(`${CWD}/data/custom-translation-strings.json`, 'utf8')
+ fs.readFileSync(`${CWD}/data/custom-translation-strings.json`, 'utf8'),
),
- customTranslations
+ customTranslations,
);
}
@@ -121,7 +121,7 @@ function execute() {
if (!file.endsWith('-sidebars.json')) {
if (file.endsWith('-sidebar.json')) {
console.warn(
- `Skipping ${file}. Make sure your sidebar filenames follow this format: 'version-VERSION-sidebars.json'.`
+ `Skipping ${file}. Make sure your sidebar filenames follow this format: 'version-VERSION-sidebars.json'.`,
);
}
return;
@@ -185,11 +185,11 @@ function execute() {
] = 'Translate';
translations['pages-strings'] = Object.assign(
translations['pages-strings'],
- customTranslations['pages-strings']
+ customTranslations['pages-strings'],
);
translations['localized-strings'] = deepmerge(
translations['localized-strings'],
- customTranslations['localized-strings']
+ customTranslations['localized-strings'],
);
writeFileAndCreateFolder(
`${CWD}/i18n/en.json`,
@@ -198,11 +198,11 @@ function execute() {
{
_comment: 'This file is auto-generated by write-translations.js',
},
- translations
+ translations,
),
null,
- 2
- )}\n`
+ 2,
+ )}\n`,
);
}
diff --git a/package.json b/package.json
index fd0931bfb7eb..a92ad618131f 100644
--- a/package.json
+++ b/package.json
@@ -3,28 +3,17 @@
"description": "Easy to Maintain Open Source Documentation Websites",
"version": "1.4.0",
"license": "MIT",
- "keywords": [
- "documentation",
- "websites",
- "open source",
- "docusaurus"
- ],
+ "keywords": ["documentation", "websites", "open source", "docusaurus"],
"repository": {
"type": "git",
"url": "https://github.com/facebook/Docusaurus.git"
},
"scripts": {
"ci-check": "yarn lint && yarn prettier:diff",
- "format:source": "prettier --config .prettierrc --write \"lib/**/*.js\"",
- "format:examples": "prettier --config .prettierrc --write \"examples/**/*.js\"",
- "format:website": "prettier --config .prettierrc --write \"website/**/*.js\"",
"lint": "eslint --cache \"lib/**/*.js\" \"examples/**/*.js\" \"website/**/*.js\"",
- "nit:source": "prettier --config .prettierrc --list-different \"lib/**/*.js\"",
- "nit:examples": "prettier --config .prettierrc --list-different \"examples/**/*.js\"",
- "nit:website": "prettier --config .prettierrc --list-different \"website/**/*.js\"",
"precommit": "lint-staged",
- "prettier": "yarn format:source && yarn format:examples && yarn format:website",
- "prettier:diff": "yarn nit:source && yarn nit:examples && yarn nit:website",
+ "prettier": "prettier --config .prettierrc --write \"**/*.js\"",
+ "prettier:diff": "prettier --config .prettierrc --list-different \"**/*.js\"",
"test": "jest",
"start": "cd website && yarn start",
"postinstall": "opencollective postinstall"
@@ -39,11 +28,7 @@
}
},
"jest": {
- "testPathIgnorePatterns": [
- "/node_modules/",
- "__fixtures__",
- "v2"
- ],
+ "testPathIgnorePatterns": ["/node_modules/", "__fixtures__", "v2"],
"testURL": "http://localhost/"
},
"bin": {
diff --git a/v2/.prettierignore b/v2/.prettierignore
deleted file mode 100644
index 9eb5d6bb2009..000000000000
--- a/v2/.prettierignore
+++ /dev/null
@@ -1,3 +0,0 @@
-generated
-__fixtures__
-dist
\ No newline at end of file
diff --git a/v2/.prettierrc b/v2/.prettierrc
deleted file mode 100644
index 32115bd6132d..000000000000
--- a/v2/.prettierrc
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "bracketSpacing": false,
- "jsxBracketSameLine": true,
- "parser": "flow",
- "printWidth": 80,
- "proseWrap": "never",
- "singleQuote": true
-}
diff --git a/v2/bin/munseo.js b/v2/bin/munseo.js
index fafbb8095b45..bb462b545f84 100644
--- a/v2/bin/munseo.js
+++ b/v2/bin/munseo.js
@@ -13,8 +13,8 @@ if (!semver.satisfies(process.version, requiredVersion)) {
chalk.yellow(
`\nYou are using Node ${
process.version
- }, Requirement: Node ${requiredVersion}.\n`
- )
+ }, Requirement: Node ${requiredVersion}.\n`,
+ ),
);
process.exit(1);
}
@@ -36,7 +36,7 @@ program
.description('Build website')
.option(
'-sic, --skip-image-compression ',
- 'Skip compression of image assets (default: false)'
+ 'Skip compression of image assets (default: false)',
)
.action((siteDir = '.', {skipImageCompression}) => {
wrapCommand(build)(path.resolve(siteDir), {skipImageCompression});
diff --git a/v2/lib/commands/build.js b/v2/lib/commands/build.js
index a2da9b3ddaa9..1d06e681e4f2 100644
--- a/v2/lib/commands/build.js
+++ b/v2/lib/commands/build.js
@@ -42,7 +42,7 @@ module.exports = async function build(siteDir, cliOptions = {}) {
// apply user webpack config
const {
- siteConfig: {configureWebpack}
+ siteConfig: {configureWebpack},
} = props;
clientConfig = applyConfigureWebpack(configureWebpack, clientConfig, false);
serverConfig = applyConfigureWebpack(configureWebpack, serverConfig, true);
@@ -58,20 +58,20 @@ module.exports = async function build(siteDir, cliOptions = {}) {
const {outDir} = props;
const staticDir = path.resolve(siteDir, 'static');
const staticFiles = await globby(['**'], {
- cwd: staticDir
+ cwd: staticDir,
});
await Promise.all(
staticFiles.map(async source => {
const fromPath = path.resolve(staticDir, source);
const toPath = path.resolve(outDir, source);
return fs.copy(fromPath, toPath);
- })
+ }),
);
const relativeDir = path.relative(process.cwd(), outDir);
console.log(
`\n${chalk.green('Success!')} Generated static files in ${chalk.cyan(
- relativeDir
- )}.\n`
+ relativeDir,
+ )}.\n`,
);
};
diff --git a/v2/lib/commands/eject.js b/v2/lib/commands/eject.js
index 42c630747d9d..3914d2bd7871 100644
--- a/v2/lib/commands/eject.js
+++ b/v2/lib/commands/eject.js
@@ -10,7 +10,7 @@ module.exports = async function eject(siteDir) {
const relativeDir = path.relative(process.cwd(), customTheme);
console.log(
`\n${chalk.green('Success!')} Copied default theme files to ${chalk.cyan(
- relativeDir
- )}.\n`
+ relativeDir,
+ )}.\n`,
);
};
diff --git a/v2/lib/commands/start.js b/v2/lib/commands/start.js
index bc4a35052028..baa9c9d34df5 100644
--- a/v2/lib/commands/start.js
+++ b/v2/lib/commands/start.js
@@ -44,8 +44,8 @@ module.exports = async function start(siteDir, cliOptions = {}) {
[`../${docsRelativeDir}/**/*.md`, 'blog/**/*.md', 'siteConfig.js'],
{
cwd: siteDir,
- ignoreInitial: true
- }
+ ignoreInitial: true,
+ },
);
fsWatcher.on('add', reload);
fsWatcher.on('change', reload);
@@ -69,14 +69,14 @@ module.exports = async function start(siteDir, cliOptions = {}) {
hash: true,
template: path.resolve(__dirname, '../core/devTemplate.ejs'),
filename: 'index.html',
- title: siteConfig.title
- }
+ title: siteConfig.title,
+ },
]);
config = config.toConfig();
// apply user webpack config
const {
- siteConfig: {configureWebpack}
+ siteConfig: {configureWebpack},
} = props;
config = applyConfigureWebpack(configureWebpack, config, false);
@@ -90,11 +90,11 @@ module.exports = async function start(siteDir, cliOptions = {}) {
compiler,
open: true,
devMiddleware: {
- logLevel: 'silent'
+ logLevel: 'silent',
},
hotClient: {
port: hotPort,
- logLevel: 'error'
+ logLevel: 'error',
},
logLevel: 'error',
port,
@@ -113,12 +113,12 @@ module.exports = async function start(siteDir, cliOptions = {}) {
app.use(
convert(
history({
- rewrites: [{from: /\.html$/, to: '/'}]
- })
- )
+ rewrites: [{from: /\.html$/, to: '/'}],
+ }),
+ ),
);
- }
- }
+ },
+ },
);
}, 1000);
};
diff --git a/v2/lib/core/App.js b/v2/lib/core/App.js
index 4fabf192dc63..6023181b948f 100644
--- a/v2/lib/core/App.js
+++ b/v2/lib/core/App.js
@@ -11,5 +11,5 @@ export default () =>
docsMetadatas,
docsSidebars,
pagesMetadatas,
- siteConfig
+ siteConfig,
});
diff --git a/v2/lib/core/clientEntry.js b/v2/lib/core/clientEntry.js
index 38f475e627a9..178146b2ef0a 100644
--- a/v2/lib/core/clientEntry.js
+++ b/v2/lib/core/clientEntry.js
@@ -13,7 +13,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
,
- document.getElementById('app')
+ document.getElementById('app'),
);
});
}
diff --git a/v2/lib/core/prerender.js b/v2/lib/core/prerender.js
index 7e4189361791..30adf5110fa2 100644
--- a/v2/lib/core/prerender.js
+++ b/v2/lib/core/prerender.js
@@ -13,6 +13,6 @@ export default function prerender(routeConfig, providedLocation) {
return component.preload();
}
return undefined;
- })
+ }),
);
}
diff --git a/v2/lib/core/serverEntry.js b/v2/lib/core/serverEntry.js
index 1bd7dab1803a..4469f7340aa2 100644
--- a/v2/lib/core/serverEntry.js
+++ b/v2/lib/core/serverEntry.js
@@ -15,7 +15,7 @@ export default function render(locals) {
const appHtml = ReactDOMServer.renderToString(
-
+ ,
);
const helmet = Helmet.renderStatic();
@@ -24,7 +24,7 @@ export default function render(locals) {
const metaStrings = [
helmet.title.toString(),
helmet.meta.toString(),
- helmet.link.toString()
+ helmet.link.toString(),
];
const metaHtml = metaStrings.filter(Boolean).join('\n ');
@@ -42,14 +42,14 @@ export default function render(locals) {
${cssFiles.map(
cssFile =>
- ``
+ ``,
)}
${appHtml}
${jsFiles.map(
jsFile =>
- ``
+ ``,
)}