Skip to content

Commit

Permalink
chore(v2): fix code style (revert previous changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Apr 5, 2020
1 parent 1480a7e commit 1f00d15
Show file tree
Hide file tree
Showing 143 changed files with 457 additions and 458 deletions.
18 changes: 9 additions & 9 deletions jest/stylelint-rule-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function getOutputCss(output) {

global.testStylelintRule = (config, tests) => {
describe(tests.ruleName, () => {
const checkTestCaseContent = testCase =>
const checkTestCaseContent = (testCase) =>
testCase.description || testCase.code || 'no description';

if (tests.accept && tests.accept.length) {
describe('accept cases', () => {
tests.accept.forEach(testCase => {
tests.accept.forEach((testCase) => {
const spec = testCase.only ? it.only : it;

spec(checkTestCaseContent(testCase), () => {
Expand All @@ -30,7 +30,7 @@ global.testStylelintRule = (config, tests) => {
syntax: tests.syntax,
};

return stylelint.lint(options).then(output => {
return stylelint.lint(options).then((output) => {
expect(output.results[0].warnings).toEqual([]);

if (!tests.fix) {
Expand All @@ -40,8 +40,8 @@ global.testStylelintRule = (config, tests) => {
// Check the fix.
return stylelint
.lint({...options, fix: true})
.then(fixedOutput => getOutputCss(fixedOutput))
.then(fixedCode => expect(fixedCode).toBe(testCase.fixed));
.then((fixedOutput) => getOutputCss(fixedOutput))
.then((fixedCode) => expect(fixedCode).toBe(testCase.fixed));
});
});
});
Expand All @@ -50,7 +50,7 @@ global.testStylelintRule = (config, tests) => {

if (tests.reject && tests.reject.length) {
describe('reject cases', () => {
tests.reject.forEach(testCase => {
tests.reject.forEach((testCase) => {
const skip = testCase.skip ? it.skip : it;
const spec = testCase.only ? it.only : skip;

Expand All @@ -61,7 +61,7 @@ global.testStylelintRule = (config, tests) => {
syntax: tests.syntax,
};

return stylelint.lint(options).then(output => {
return stylelint.lint(options).then((output) => {
const {warnings} = output.results[0];
const warning = warnings[0];

Expand Down Expand Up @@ -93,8 +93,8 @@ global.testStylelintRule = (config, tests) => {
// Check the fix.
return stylelint
.lint({...options, fix: true})
.then(fixedOutput => getOutputCss(fixedOutput))
.then(fixedCode => expect(fixedCode).toBe(testCase.fixed));
.then((fixedOutput) => getOutputCss(fixedOutput))
.then((fixedCode) => expect(fixedCode).toBe(testCase.fixed));
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-1.x/examples/basics/pages/en/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Help(props) {
const {baseUrl, docsUrl} = siteConfig;
const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
const langPart = `${language ? `${language}/` : ''}`;
const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`;
const docUrl = (doc) => `${baseUrl}${docsPart}${langPart}${doc}`;

const supportLinks = [
{
Expand Down
21 changes: 11 additions & 10 deletions packages/docusaurus-1.x/examples/basics/pages/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,38 @@ class HomeSplash extends React.Component {
const {baseUrl, docsUrl} = siteConfig;
const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
const langPart = `${language ? `${language}/` : ''}`;
const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`;
const docUrl = (doc) => `${baseUrl}${docsPart}${langPart}${doc}`;

const SplashContainer = props => (
const SplashContainer = (props) => (
<div className="homeContainer">
<div className="homeSplashFade">
<div className="wrapper homeWrapper">{props.children}</div>
</div>
</div>
);

const Logo = props => (
const Logo = (props) => (
<div className="projectLogo">
<img src={props.img_src} alt="Project Logo" />
</div>
);

const ProjectTitle = props => (
const ProjectTitle = (props) => (
<h2 className="projectTitle">
{props.title}
<small>{props.tagline}</small>
</h2>
);

const PromoSection = props => (
const PromoSection = (props) => (
<div className="section promoSection">
<div className="promoRow">
<div className="pluginRowBlock">{props.children}</div>
</div>
</div>
);

const Button = props => (
const Button = (props) => (
<div className="pluginWrapper buttonWrapper">
<a className="button" href={props.href} target={props.target}>
{props.children}
Expand Down Expand Up @@ -79,7 +79,7 @@ class Index extends React.Component {
const {config: siteConfig, language = ''} = this.props;
const {baseUrl} = siteConfig;

const Block = props => (
const Block = (props) => (
<Container
padding={['bottom', 'top']}
id={props.id}
Expand Down Expand Up @@ -170,14 +170,15 @@ class Index extends React.Component {
}

const showcase = siteConfig.users
.filter(user => user.pinned)
.map(user => (
.filter((user) => user.pinned)
.map((user) => (
<a href={user.infoLink} key={user.infoLink}>
<img src={user.image} alt={user.caption} title={user.caption} />
</a>
));

const pageUrl = page => baseUrl + (language ? `${language}/` : '') + page;
const pageUrl = (page) =>
baseUrl + (language ? `${language}/` : '') + page;

return (
<div className="productShowcaseSection paddingBottom">
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-1.x/examples/basics/pages/en/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Users extends React.Component {
return null;
}

const showcase = siteConfig.users.map(user => (
const showcase = siteConfig.users.map((user) => (
<a href={user.infoLink} key={user.infoLink}>
<img src={user.image} alt={user.caption} title={user.caption} />
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Versions(props) {
<table className="versions">
<tbody>
{versions.map(
version =>
(version) =>
version !== latestVersion && (
<tr key={version}>
<th>{version}</th>
Expand Down
14 changes: 7 additions & 7 deletions packages/docusaurus-1.x/lib/__tests__/build-files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Build files', () => {
glob(`${buildDir}/${siteConfig.projectName}/docs/**/*.html`),
glob(`${docsDir}/assets/*`),
glob(`${buildDir}/${siteConfig.projectName}/img/*`),
]).then(results => {
]).then((results) => {
[
inputMarkdownFiles,
outputHTMLFiles,
Expand All @@ -62,33 +62,33 @@ describe('Build files', () => {
});

test('Build folder exists', () =>
fs.stat(buildDir).then(status => {
fs.stat(buildDir).then((status) => {
expect(status.isDirectory()).toBeTruthy();
}));

test('Generated HTML for each Markdown resource', () => {
const metadata = outputHTMLFiles.map(file =>
const metadata = outputHTMLFiles.map((file) =>
filepath.create(file).basename(),
);
inputMarkdownFiles.forEach(file => {
inputMarkdownFiles.forEach((file) => {
const data = fs.readFileSync(file, 'utf8');
const frontmatter = fm(data);
expect(metadata).toContain(`${frontmatter.attributes.id}.html`);
});
});

test('Generated table of contents', () => {
outputHTMLFiles.forEach(file => {
outputHTMLFiles.forEach((file) => {
const fileContents = fs.readFileSync(file, 'utf8');
expect(fileContents).not.toContain('<AUTOGENERATED_TABLE_OF_CONTENTS>');
});
});

test('Copied assets from /docs/assets', () => {
const metadata = outputAssetsFiles.map(file =>
const metadata = outputAssetsFiles.map((file) =>
filepath.create(file).basename(),
);
inputAssetsFiles.forEach(file => {
inputAssetsFiles.forEach((file) => {
const path = filepath.create(file);
expect(metadata).toContain(path.basename());
});
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-1.x/lib/build-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ generate()
.then(() => {
console.log("Site built successfully. Generated files in 'build' folder.");
})
.catch(error => {
.catch((error) => {
console.error(error);
process.exit(1);
});
12 changes: 6 additions & 6 deletions packages/docusaurus-1.x/lib/copy-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const path = require('path');

const CWD = process.cwd();

const toHex = color => {
const toHex = (color) => {
const hex = color.toString(16);
return hex.length === 1 ? `0${hex}` : hex;
};
Expand All @@ -37,7 +37,7 @@ let feature;

commander
.arguments('[feature]')
.action(feat => {
.action((feat) => {
feature = feat;
})
.parse(process.argv);
Expand Down Expand Up @@ -85,7 +85,7 @@ if (feature === 'translations') {
fs.copySync(`${folder}/crowdin.yaml`, `${CWD}/../crowdin.yaml`);
}
const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
files.forEach((file) => {
if (fs.lstatSync(file).isDirectory()) {
return;
}
Expand All @@ -112,7 +112,7 @@ if (feature === 'translations') {
// copy files for versions
const folder = path.join(__dirname, '..', 'examples', 'versions');
const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
files.forEach((file) => {
if (fs.lstatSync(file).isDirectory()) {
return;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ if (feature === 'translations') {
// copy other files
const files = glob.sync(`${folder}/**/*`);
const {primaryColor, secondaryColor} = colorScheme();
files.forEach(file => {
files.forEach((file) => {
if (fs.lstatSync(file).isDirectory()) {
return;
}
Expand Down Expand Up @@ -235,7 +235,7 @@ if (feature === 'translations') {
});

const svgs = glob.sync(`${CWD}/static/img/**/*.svg`);
svgs.forEach(file => {
svgs.forEach((file) => {
// Replace primary colors of SVGs.
const newImage = fs
.readFileSync(file, 'utf8')
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-1.x/lib/core/BlogPageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MetadataBlog = require('./MetadataBlog.js');
const MetadataPublicBlog =
process.env.NODE_ENV === 'development'
? MetadataBlog
: MetadataBlog.filter(item => !item.unlisted);
: MetadataBlog.filter((item) => !item.unlisted);
const Site = require('./Site.js');
const utils = require('./utils.js');

Expand Down Expand Up @@ -48,7 +48,7 @@ class BlogPageLayout extends React.Component {
{MetadataPublicBlog.slice(
page * perPage,
(page + 1) * perPage,
).map(post => (
).map((post) => (
<BlogPost
post={post}
content={post.content}
Expand Down
10 changes: 6 additions & 4 deletions packages/docusaurus-1.x/lib/core/BlogPostLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class BlogPostLayout extends React.Component {
{/* Facebook SDK require 'fb-comments' class */}
<div
className="fb-comments"
data-href={`${this.props.config.url +
this.props.config.baseUrl}blog/${post.path}`}
data-href={`${
this.props.config.url + this.props.config.baseUrl
}blog/${post.path}`}
data-width="100%"
data-numposts="5"
data-order-by="time"
Expand All @@ -52,8 +53,9 @@ class BlogPostLayout extends React.Component {
{/* Facebook SDK require 'fb-like' class */}
<div
className="fb-like"
data-href={`${this.props.config.url +
this.props.config.baseUrl}blog/${post.path}`}
data-href={`${
this.props.config.url + this.props.config.baseUrl
}blog/${post.path}`}
data-layout="standard"
data-share="true"
data-width="225"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-1.x/lib/core/BlogSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MetadataBlog = require('./MetadataBlog.js');
const MetadataPublicBlog =
process.env.NODE_ENV === 'development'
? MetadataBlog
: MetadataBlog.filter(item => !item.unlisted);
: MetadataBlog.filter((item) => !item.unlisted);

class BlogSidebar extends React.Component {
render() {
Expand All @@ -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,
})),
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-1.x/lib/core/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'), '');
}
Expand Down Expand Up @@ -135,7 +135,7 @@ const cleanTheCodeTag = (content, indents) => {
};
const contents = content.split(/(<pre>)(.*?)(<\/pre>)/gms);
let inCodeBlock = false;
const cleanContents = contents.map(c => {
const cleanContents = contents.map((c) => {
if (c === '<pre>') {
inCodeBlock = true;
return c;
Expand All @@ -159,8 +159,8 @@ class Doc extends React.Component {
let indents = 0;
return content.replace(
/(\t|\s{4})*?(<!--DOCUSAURUS_CODE_TABS-->\n)(.*?)((\n|\t|\s{4})<!--END_DOCUSAURUS_CODE_TABS-->)/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})+)<!--DOCUSAURUS_CODE_TABS-->/) || []
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-1.x/lib/core/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -130,15 +130,15 @@ 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 ? (
<link rel="stylesheet" key={source.href} {...source} />
) : (
<link rel="stylesheet" key={source} href={source} />
),
)}
{this.props.config.scripts &&
this.props.config.scripts.map(source =>
this.props.config.scripts.map((source) =>
source.src ? (
<script type="text/javascript" key={source.src} {...source} />
) : (
Expand Down
Loading

0 comments on commit 1f00d15

Please sign in to comment.