ESLintify Part 2 (#841)

* ESLintify Part 2

* Fix

* Fix tests

* Fix tests

* Fix tests
This commit is contained in:
Yangshun Tay 2018-07-10 21:53:08 -07:00 committed by GitHub
parent 4267337fb0
commit 5ac2cee658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 188 additions and 190 deletions

View file

@ -41,20 +41,18 @@ class BlogPageLayout extends React.Component {
<Container className="mainContainer postContainer blogContainer">
<div className="posts">
{MetadataBlog.slice(page * perPage, (page + 1) * perPage).map(
post => {
return (
<BlogPost
post={post}
content={post.content}
truncate
key={
utils.getPath(post.path, this.props.config.cleanUrl) +
post.title
}
config={this.props.config}
/>
);
}
post => (
<BlogPost
post={post}
content={post.content}
truncate
key={
utils.getPath(post.path, this.props.config.cleanUrl) +
post.title
}
config={this.props.config}
/>
)
)}
<div className="docs-prevnext">
{page > 0 && (

View file

@ -103,7 +103,7 @@ class BlogPostLayout extends React.Component {
const hasOnPageNav = this.props.config.onPageNav === 'separate';
const post = this.props.metadata;
post.path = utils.getPath(post.path, this.props.config.cleanUrl);
let blogSidebarTitleConfig = this.props.config.blogSidebarTitle || {};
const blogSidebarTitleConfig = this.props.config.blogSidebarTitle || {};
return (
<Site
className={classNames('sideNavVisible', {
@ -111,13 +111,13 @@ class BlogPostLayout extends React.Component {
})}
url={'blog/' + post.path}
title={this.props.metadata.title}
language={'en'}
language="en"
description={this.getDescription()}
config={this.props.config}
metadata={{blog: true}}>
<div className="docMainWrapper wrapper">
<BlogSidebar
language={'en'}
language="en"
current={post}
config={this.props.config}
/>
@ -126,7 +126,7 @@ class BlogPostLayout extends React.Component {
<BlogPost
post={post}
content={this.props.children}
language={'en'}
language="en"
config={this.props.config}
/>
{this.renderSocialButtons()}

View file

@ -14,7 +14,7 @@ const MetadataBlog = require('./MetadataBlog.js');
class BlogSidebar extends React.Component {
render() {
let blogSidebarCount = 5;
let blogSidebarTitleConfig = this.props.config.blogSidebarTitle || {};
const blogSidebarTitleConfig = this.props.config.blogSidebarTitle || {};
let blogSidebarTitle = blogSidebarTitleConfig.default || 'Recent Posts';
if (this.props.config.blogSidebarCount) {
if (this.props.config.blogSidebarCount === 'ALL') {

View file

@ -11,7 +11,7 @@ const GridBlock = require('./GridBlock.js');
// A collection of components to provide to users
module.exports = {
MarkdownBlock: MarkdownBlock,
Container: Container,
GridBlock: GridBlock,
MarkdownBlock,
Container,
GridBlock,
};

View file

@ -85,7 +85,7 @@ class DocsLayout extends React.Component {
][metadata.previous_id] ||
translation[this.props.metadata.language][
'localized-strings'
]['previous'] ||
].previous ||
'Previous'
: metadata.previous_title || 'Previous'}
</a>
@ -103,7 +103,7 @@ class DocsLayout extends React.Component {
][metadata.next_id] ||
translation[this.props.metadata.language][
'localized-strings'
]['next'] ||
].next ||
'Next'
: metadata.next_title || 'Next'}{' '}

View file

@ -12,8 +12,8 @@ const readCategories = require('../server/readCategories.js');
class DocsSidebar extends React.Component {
render() {
let sidebar = this.props.metadata.sidebar;
let docsCategories = readCategories(sidebar);
const sidebar = this.props.metadata.sidebar;
const docsCategories = readCategories(sidebar);
const categoryName = docsCategories[this.props.metadata.language][0].name;
if (!categoryName) {
return null;

View file

@ -13,14 +13,14 @@ class Head extends React.Component {
const links = this.props.config.headerLinks;
const hasBlog = links.some(link => link.blog);
let highlight = {
const highlight = {
version: '9.12.0',
theme: 'default',
...this.props.config.highlight,
};
// Use user-provided themeUrl if it exists, else construct one from version and theme.
let highlightThemeURL = highlight.themeUrl
const highlightThemeURL = highlight.themeUrl
? highlight.themeUrl
: `//cdnjs.cloudflare.com/ajax/libs/highlight.js/${
highlight.version
@ -143,17 +143,13 @@ class Head extends React.Component {
))}
{this.props.config.scrollToTop && (
<script
src={
'https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js'
}
/>
<script src="https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js" />
)}
{this.props.config.scrollToTop && (
<script
dangerouslySetInnerHTML={{
__html: `
document.addEventListener("DOMContentLoaded", function(){
document.addEventListener('DOMContentLoaded', function() {
addBackToTop(
${JSON.stringify(
Object.assign(

View file

@ -10,6 +10,7 @@ const fs = require('fs');
const HeaderNav = require('./nav/HeaderNav.js');
const Head = require('./Head.js');
const Footer = require(process.cwd() + '/core/Footer.js');
const translation = require('../server/translation.js');
const constants = require('./constants');

View file

@ -10,6 +10,7 @@ const CWD = process.cwd();
const React = require('react');
const fs = require('fs');
const classNames = require('classnames');
const siteConfig = require(CWD + '/siteConfig.js');
const translation = require('../../server/translation.js');
const env = require('../../server/env.js');
@ -18,16 +19,18 @@ const translate = require('../../server/translate.js').translate;
const setLanguage = require('../../server/translate.js').setLanguage;
const readMetadata = require('../../server/readMetadata.js');
readMetadata.generateMetadataDocs();
const Metadata = require('../metadata.js');
const utils = require('../utils.js');
const extension = siteConfig.cleanUrl ? '' : '.html';
// language dropdown nav item for when translations are enabled
class LanguageDropDown extends React.Component {
render() {
setLanguage(this.props.language || 'en');
let helpTranslateString = translate(
const helpTranslateString = translate(
'Help Translate|recruit community translators for your project'
);
// add all enabled languages to dropdown

View file

@ -15,7 +15,7 @@ const utils = require('../utils.js');
class SideNav extends React.Component {
// return appropriately translated category string
getLocalizedCategoryString(category) {
let categoryString = translation[this.props.language]
const categoryString = translation[this.props.language]
? translation[this.props.language]['localized-strings'][category] ||
category
: category;

View file

@ -25,7 +25,7 @@ class MarkdownRenderer {
// Highlight.js expects hljs css classes on the code element.
// This results in <pre><code class="hljs css languages-jsx">
langPrefix: 'hljs css languages-',
highlight: function(str, lang) {
highlight(str, lang) {
lang =
lang || (siteConfig.highlight && siteConfig.highlight.defaultLang);
if (lang) {
@ -90,6 +90,4 @@ class MarkdownRenderer {
const renderMarkdown = new MarkdownRenderer();
module.exports = source => {
return renderMarkdown.toHtml(source);
};
module.exports = source => renderMarkdown.toHtml(source);

View file

@ -42,9 +42,9 @@ module.exports = (string, context = {}) => {
// Handle uppercase characters
.toLowerCase()
// Handle accentuated characters
.replace(new RegExp('[' + accents + ']', 'g'), c => {
return without.charAt(accents.indexOf(c));
})
.replace(new RegExp('[' + accents + ']', 'g'), c =>
without.charAt(accents.indexOf(c))
)
// Replace `.`, `(` and `?` with blank string like Github does
.replace(/\.|\(|\?/g, '')
// Dash special characters