Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettify all JavaScript files #964

Merged
merged 4 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"printWidth": 80,
"proseWrap": "never",
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "all"
Copy link
Contributor

@gustavohenke gustavohenke Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke Node 6 support (LTS until April 2019) 🙃

But I assume my CI file could be tweaked to not build docs on all supported versions...
https://github.com/express-validator/express-validator/blob/b4f0c256d281fb917b59221f4bfa93c2d81cd91a/.travis.yml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies. We did mention that Docusaurus requires Node 8 and above: https://docusaurus.io/docs/en/installation#installing-docusaurus

}
38 changes: 19 additions & 19 deletions docusaurus-init/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
2 changes: 1 addition & 1 deletion examples/basics/pages/en/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/versions/pages/en/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Versions() {
<a href="">Release Notes</a>
</td>
</tr>
)
),
)}
</tbody>
</table>
Expand Down
8 changes: 4 additions & 4 deletions lib/__tests__/build-files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 => {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/build-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
56 changes: 28 additions & 28 deletions lib/copy-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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`,
);
}

Expand All @@ -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`);
Expand All @@ -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`,
);
}
});
Expand All @@ -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`,
);
}
});
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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]}`,
)}.`,
);
}
});
Expand All @@ -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`,
);
}
2 changes: 1 addition & 1 deletion lib/core/BlogPageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BlogPageLayout extends React.Component {
}
config={this.props.config}
/>
)
),
)}
<div className="docs-prevnext">
{page > 0 && (
Expand Down
4 changes: 2 additions & 2 deletions lib/core/BlogPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
</a>
Expand Down Expand Up @@ -66,7 +66,7 @@ class BlogPost extends React.Component {
<a
href={`${this.props.config.baseUrl}blog/${utils.getPath(
post.path,
this.props.config.cleanUrl
this.props.config.cleanUrl,
)}`}>
{post.title}
</a>
Expand Down
4 changes: 2 additions & 2 deletions lib/core/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/core/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DocsLayout extends React.Component {
.replace(/^\.\.\//, '') + extension;
return url.resolve(
`${this.props.config.baseUrl}${this.props.metadata.permalink}`,
relativeHref
relativeHref,
);
};

Expand Down Expand Up @@ -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,
)}>
<span className="arrow-prev">← </span>
<span
Expand All @@ -112,7 +112,7 @@ class DocsLayout extends React.Component {
className="docs-next button"
href={this.getRelativeURL(
metadata.localized_id,
metadata.next_id
metadata.next_id,
)}>
<span
className={
Expand Down
8 changes: 4 additions & 4 deletions lib/core/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Head extends React.Component {
<link rel="stylesheet" key={source.href} {...source} />
) : (
<link rel="stylesheet" key={source} href={source} />
)
),
)}
{this.props.config.scripts &&
this.props.config.scripts.map(
Expand All @@ -152,7 +152,7 @@ class Head extends React.Component {
<script type="text/javascript" key={source.src} {...source} />
) : (
<script type="text/javascript" src={source} key={source} />
)
),
)}

{this.props.config.scrollToTop && (
Expand All @@ -168,8 +168,8 @@ class Head extends React.Component {
Object.assign(
{},
{zIndex: 100},
this.props.config.scrollToTopOptions
)
this.props.config.scrollToTopOptions,
),
)}
)
});
Expand Down
2 changes: 1 addition & 1 deletion lib/core/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
Loading