Skip to content

ESLintify Part 1#837

Merged
yangshun merged 3 commits intofacebook:masterfrom
yangshun:eslint
Jul 8, 2018
Merged

ESLintify Part 1#837
yangshun merged 3 commits intofacebook:masterfrom
yangshun:eslint

Conversation

@yangshun
Copy link
Contributor

@yangshun yangshun commented Jul 8, 2018

Motivation

Enable some ESLint rules by making the code ESLint-compliant.

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Local + Netlify.

Related PRs

#836

@yangshun yangshun requested a review from endiliey July 8, 2018 07:53
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 8, 2018
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jul 8, 2018

Deploy preview for docusaurus-preview ready!

Built with commit cae7d27

https://deploy-preview-837--docusaurus-preview.netlify.com

Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. I had few comments though

</a>
);
});
const showcase = siteConfig.users.filter(user => user.pinned).map(user => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of filter and then map, I think using reduce can be a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd have to use an if inside reduce, which makes the code less declarative, so I don't think it's a good idea.

const mkdirp = require('mkdirp');
const glob = require('glob');
const mkdirp = require('mkdirp');
const nodePath = require('path');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we use nodePath instead of path ? I saw path being used in another file. Is there conflicting name here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you're right

let sidebarContent = fs.readFileSync(newSidebarFile, 'utf8');
sidebarContent = sidebarContent.replace(
new RegExp(`version-${RegExp.escape(currentVersion)}-`, 'g'),
new RegExp(`version-${escapeRegexp(currentVersion)}-`, 'g'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can escape it using a library instead of our own escape function. Its alrd in our dependencies

Copy link
Contributor Author

@yangshun yangshun Jul 8, 2018

Choose a reason for hiding this comment

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

I'll look into using escape-string-regexp

lib/core/Head.js Outdated
let hasBlog = false;
links.map(link => {
if (link.blog) hasBlog = true;
links.forEach(link => {
Copy link
Contributor

Choose a reason for hiding this comment

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

const hasBlog = links.some(link => link.blog);

@yangshun yangshun merged commit e8e3f42 into facebook:master Jul 8, 2018
@yangshun yangshun deleted the eslint branch July 8, 2018 16:13
@JoelMarcey
Copy link
Contributor

Hi 👋 I think there was a build failure from this. Syntax error? Maybe we need to upgrade our Circle build infra to support new constructs? Or there was a genuine error 😄

Sent with GitHawk

@yangshun
Copy link
Contributor Author

yangshun commented Jul 8, 2018

Hmm odd. I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants