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

Integrate eslint & precommit to codebase #815

Merged
merged 5 commits into from
Jul 1, 2018
Merged

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Jun 30, 2018

Motivation

  1. Adding ESLint to catch errors & precommit hook to automatically run linting & prettier (better developer experience)
  2. This PR also includes fixes to linting errors

P.S Our ESLint config is based on Facebook ESLint configuration (https://github.com/facebook/fbjs/tree/master/packages/eslint-config-fbjs)

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

  1. ESLint
    eslint

  2. Precommit hook
    precommit

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jun 30, 2018

Deploy preview for docusaurus-preview ready!

Built with commit 417efda

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

@endiliey endiliey force-pushed the eslint branch 2 times, most recently from 6906482 to 1f7df7f Compare June 30, 2018 15:08
Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

Looks great! What are the next steps you're planning for the ESLint integration? Are we enabling more rules?

.eslintrc.json Outdated
@@ -0,0 +1,16 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use .js extension. It's much more flexible than JSON and we can add comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

"eslint": "^5.0.1",
"eslint-config-fbjs": "^2.0.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-babel": "^5.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we using them yet? I don't see them in eslintrc. Maybe we should add them later if we're not using yet.

Copy link
Contributor Author

@endiliey endiliey Jul 1, 2018

Choose a reason for hiding this comment

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

eslint-config-fbjs requires it as peer dependencies
https://github.com/facebook/fbjs/blob/d308fa83c99c93e8e588de3396cf55b31e56b14e/packages/eslint-config-fbjs/package.json#L21-L28

I've only added eslint-config-prettier so far to remove eslint-prettier conflict.

Edit: So for now we're effectively using eslint-config-fbjs & eslint-config-prettier

.eslintrc.json Outdated
}
}
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add newline.

.eslintrc.json Outdated
@@ -0,0 +1,16 @@
{
"extends": ["fbjs", "prettier"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we adding more of them later?

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 think not so soon. fbjs config is quite ok for now. We can always overrides their rules later on

@@ -56,9 +56,9 @@ beforeAll(() => {
});
});

function afterAll() {
afterAll(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes the meaning - It was declaring a function before, now it's executing it. The after version looks more correct though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup. it's actually caught by the linter. Otherwise the function is never used

@yangshun
Copy link
Contributor

yangshun commented Jul 1, 2018

Feel free to merge this when you feel it's ready. We could add more rules later on/fix more issues.

@endiliey
Copy link
Contributor Author

endiliey commented Jul 1, 2018

I'm going to add some more specific rules for libs that can cause bugs. Lot of linting errors are turned off at fbjs.

@yangshun
Copy link
Contributor

yangshun commented Jul 1, 2018

Hmm in that case I wonder if fbjs is the right one to use. Let's get @JoelMarcey's opinion on this when he's available. But in the meanwhile we can merge this.

@endiliey
Copy link
Contributor Author

endiliey commented Jul 1, 2018

I'm changing it to .js version. Give me few mins 😃

@endiliey endiliey merged commit 21dcea2 into facebook:master Jul 1, 2018
@endiliey endiliey deleted the eslint branch July 1, 2018 04:27
@JoelMarcey
Copy link
Contributor

I approve of the .js versaion that @endiliey has changed it to.

@yangshun yangshun mentioned this pull request Jul 7, 2018
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