-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
add eslint to the project #58
Conversation
This is awesome. I think we'll want to do something better than copy-pasta the React files as-is though. On the subject of all the |
@wincent Agreed about disabling |
@wincent @josephsavona cool I'll disable it and fix the issues. I copied react's one just to start this off, thought that you might have some kind of guidelines at Facebook. Any other suggestions? what do you think about this.pending && this.pending.request.abort(); with if (this.pending) {
this.pending.request.abort();
} not sure which one do you prefer? also not sure why the tests are failing on travis, seems like some issue while installing from npm |
Thinking about the implications of this more: all of the code passes our internal lint checks, and it will complicate syncing if the ESLint config here is more restrictive than our internal linting. Can you relax the rules just enough to not require any changes to files in Thanks again for collaborating on this! |
Next on my list for fbjs is to get our lint config in a good place to be shared and reused. For React we opted to be more restrictive than the rest of FB because we could be (we sync in, not out so it doesn't matter). FWIW, we actually might not be passing internally, we should force a full check :)
|
@josephsavona ok, I'll do that and update the PR. @zpao I think for now let's just add the basic ESlint rules and make sure they pass, and then we can add the ones which we see there is a need for? |
# Conflicts: # src/legacy/store/__tests__/GraphQLRange-test.js # src/mutation/RelayMutation.js # src/network-layer/default/RelayDefaultNetworkLayer.js # src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js
@josephsavona updated the code, let me know what you think. travis is still failing while trying to run Edit: |
@@ -22,6 +22,7 @@ | |||
"scripts": { | |||
"build": "[ $(ulimit -n) -lt 4096 ] && ulimit -n 4096; gulp", | |||
"prepublish": "npm run build", | |||
"lint": "`npm bin`/eslint .", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be eslint .
(npm adds node_modules/.bin
to the PATH)
@knowbody I'm sorry if my previous comment wasn't clear. The addition of ESLint here should require no changes whatsoever to the Regarding style: we do prefer trailing commas, but this is the one preference for which we don't also have an internal lint rule (and so there are some inconsistencies in the existing code). |
# Conflicts: # .travis.yml
@zpao thanks for the hints 👍 @josephsavona check it now please. I think I fixed all you asked for |
# Conflicts: # package.json
# Conflicts: # package.json
@josephsavona @wincent is anything blocking this to be merged? |
module.exports = RelayConnectionInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot accept this PR if there are changes to the src/
directory - rules should lenient enough to allow the code to pass as-is.
@knowbody See comments above. Again, we sincerely appreciate all the effort you've put into this, but to simplify syncing code for now the configuration should consider the code valid as-is, and there should be no changes to the |
@josephsavona sure, sorry fixing all that now |
@josephsavona should be good to go now |
You'll be able to drop a lot of this, apart from some finer tuning, once we pull in facebook/fbjs#49 (might end up being better to end up abandoning this PR entirely and starting clean). |
@zpao just seen the merge you've done with react. agree, let's close and I start the new PR with the rules from fbjs repo. How does it sound? @josephsavona |
closing and moving discussion to #202 |
Summary: As @zpao suggested (reference #58) here is the new PR with the rules from [facebook/fbjs#49](facebook/fbjs#49). I'll still need some guidance on what should be Relay specific. At the moment with the current fbjs rules there is a lot of errors on [no-undef](http://eslint.org/docs/rules/no-undef.html) (example: $FlowIssue, $FixMe, $Enum and also when defining Flow types, this is related to [babel-eslint/known-issues](https://github.com/babel/babel-eslint#known-issues) - [babel-eslint#130](babel/babel-eslint#130) and [babel-eslint#132](babel/babel-eslint#132)) @josephsavona @zpao what are your thoughts? Closes #202 Reviewed By: @josephsavona Differential Revision: D2417828
Summary: As @zpao suggested (reference #58) here is the new PR with the rules from [facebook/fbjs#49](facebook/fbjs#49). I'll still need some guidance on what should be Relay specific. At the moment with the current fbjs rules there is a lot of errors on [no-undef](http://eslint.org/docs/rules/no-undef.html) (example: $FlowIssue, $FixMe, $Enum and also when defining Flow types, this is related to [babel-eslint/known-issues](https://github.com/babel/babel-eslint#known-issues) - [babel-eslint#130](babel/babel-eslint#130) and [babel-eslint#132](babel/babel-eslint#132)) @josephsavona @zpao what are your thoughts? Closes #202 Reviewed By: @josephsavona Differential Revision: D2417828
This is going to solve #57
I thought it would be good to add eslint to the project at this stage. I have borrowed the eslint rules from react repo. I have fixed most of the linting errors, however in those I was not sure how you guys want to deal with refactoring I left there and added
/* eslint ... */
on top of the file to just generate the warning for now.The most common issues are:
no-shadow
no-unused-expressions
warnings
andinvariants
are missing a error messagePlease let me know how would you like to fix the above and I do those changes.