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

@ -71,9 +71,7 @@ function execute(port, options) {
}
}
/****************************************************************************/
let readMetadata = require('./readMetadata.js');
const readMetadata = require('./readMetadata.js');
let Metadata;
let MetadataBlog;
let siteConfig;
@ -103,8 +101,6 @@ function execute(port, options) {
}
}
/****************************************************************************/
const TABLE_OF_CONTENTS_TOKEN = '<AUTOGENERATED_TABLE_OF_CONTENTS>';
const insertTableOfContents = rawContent => {
@ -119,8 +115,6 @@ function execute(port, options) {
return rawContent.replace(TABLE_OF_CONTENTS_TOKEN, tableOfContents);
};
/****************************************************************************/
function isSeparateCss(file) {
if (!siteConfig.separateCss) {
return false;
@ -181,8 +175,6 @@ function execute(port, options) {
);
}
/****************************************************************************/
reloadMetadata();
reloadMetadataBlog();
extractTranslations();
@ -192,10 +184,10 @@ function execute(port, options) {
// handle all requests for document pages
app.get(docsRouting(siteConfig.baseUrl), (req, res, next) => {
let url = req.path.toString().replace(siteConfig.baseUrl, '');
const url = req.path.toString().replace(siteConfig.baseUrl, '');
// links is a map from a permalink to an id for each document
let links = {};
const links = {};
Object.keys(Metadata).forEach(id => {
const metadata = Metadata[id];
links[metadata.permalink] = id;
@ -254,7 +246,7 @@ function execute(port, options) {
rawContent = insertTableOfContents(rawContent);
}
let defaultVersion = env.versioning.defaultVersion;
const defaultVersion = env.versioning.defaultVersion;
// replace any links to markdown files to their website html links
Object.keys(mdToHtml).forEach(key => {
@ -326,7 +318,7 @@ function execute(port, options) {
app.get(feedRouting(siteConfig.baseUrl), (req, res, next) => {
res.set('Content-Type', 'application/rss+xml');
let file = req.path
const file = req.path
.toString()
.split('blog/')[1]
.toLowerCase();
@ -354,8 +346,8 @@ function execute(port, options) {
page < Math.ceil(MetadataBlog.length / perPage);
page++
) {
let language = 'en';
const metadata = {page: page, perPage: perPage};
const language = 'en';
const metadata = {page, perPage};
const blogPageComp = (
<BlogPageLayout
metadata={metadata}
@ -369,7 +361,7 @@ function execute(port, options) {
blogPages[pagePath] = str;
}
let parts = req.path.toString().split('blog/');
const parts = req.path.toString().split('blog/');
// send corresponding blog page if appropriate
if (parts[1] === 'index.html') {
res.send(blogPages['/index.html']);
@ -412,7 +404,7 @@ function execute(port, options) {
);
metadata.id = metadata.title;
let language = 'en';
const language = 'en';
removeModuleAndChildrenFromCache(join('..', 'core', 'BlogPostLayout.js'));
const BlogPostLayout = require(join('..', 'core', 'BlogPostLayout.js'));
@ -502,7 +494,7 @@ function execute(port, options) {
fs.existsSync((userFile = englishFile))
) {
// copy into docusaurus so require paths work
let userFileParts = userFile.split('pages' + sep);
const userFileParts = userFile.split('pages' + sep);
let tempFile = join(__dirname, '..', 'pages', userFileParts[1]);
tempFile = tempFile.replace(
path.basename(file),
@ -546,7 +538,7 @@ function execute(port, options) {
);
let cssContent = fs.readFileSync(mainCssPath, {encoding: 'utf8'});
let files = glob.sync(join(CWD, 'static', '**', '*.css'));
const files = glob.sync(join(CWD, 'static', '**', '*.css'));
files.forEach(file => {
if (isSeparateCss(file)) {
@ -604,8 +596,8 @@ function execute(port, options) {
// "redirect" requests to pages ending with "/" or no extension so that,
// for example, request to "blog" returns "blog/index.html" or "blog.html"
app.get(noExtRouting(), (req, res, next) => {
let slash = req.path.toString().endsWith('/') ? '' : '/';
let requestUrl = 'http://localhost:' + port + req.path;
const slash = req.path.toString().endsWith('/') ? '' : '/';
const requestUrl = 'http://localhost:' + port + req.path;
requestFile(requestUrl + slash + 'index.html', res, () => {
requestFile(
slash === '/'