-
-
Notifications
You must be signed in to change notification settings - Fork 26.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
Support React Hooks (#5602) #5997
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Doesn't this enable loose mode for all destructuring operations? This can be very breaking and diverges from ES6 quite a bit. Instead it should only be enabled when destructuring from useState and equivalent. |
You're right. Do you know how I might go about achieving it only for known hooks? |
Ping @Pajn |
Sorry, I completely missed the first notification. I'm not too knowledgeable with the babel plugins or AST but I imagine that you would have to create a custom babel plugin (based on the |
@eivind88 based on @Pajn's advice, I've adapted Have a look at lvl99/babel@e2600c3 and let me know if it could be used here. Edit: PR on babel available here: babel/babel#9486 |
@lvl99 Great! I've updated my PR; Could you have a look and verify that I've understood your change correctly? :) This PRs dependency versions will need to be bumped after you PR is merged. |
@eivind88 I think since you have Perhaps I need to rethink what exactly is happening or how we want to use it. Maybe my const isLoose = this.selectiveLoose
? checkNameMatchesSelectiveLoose(objRef.name, this.selectiveLoose))
: loose; I think that would make more sense! Edit: otherwise, if you set |
@lvl99 Updated. Where do we go from here, considering that changes will need to be merged into Babel before this is usable? |
@eivind88 not sure! Maybe we could post comments on the PR and try and get others like @gaearon to help get it assessed for appropriateness and (hopefully) merged into Babel. |
@iansu Any thoughts?😃 |
We are also going to want to add this rule: |
@iansu: Like so? |
A stable version of |
Done! |
Thanks! I'm just looking into the unit test failures. They're not related to your changes but I'd like to fix them before we merge. |
I think there's overlap with the babel plugin here and the work being done in #6219? If so we probably want to remove that change from this PR and focus on the ESLint plugin side of things. |
@ianschmitz Are you referring to the loose mode destructuring part? I don't think #6219 is going to make it into 3.0 so I'm thinking we include this for now and then remove it in #6219. What do you think? |
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.
Small comment, otherwise codewise LGTM
Thanks! |
* masterd: (24 commits) Add TypeScript linting support (facebook#6513) Support React Hooks (facebook#5602) (facebook#5997) Support browserslist in @babel/preset-env (facebook#6608) Add empty mock for http2 (facebook#5686) Add note about npx caching (facebook#6374) change named import into default import (facebook#6625) Stage files for commit after ejecting (facebook#5960) Upgrade dependencies (facebook#6614) Make compiler variable const instead of let (facebook#6621) Type check JSON files (facebook#6615) Change class components to functional components in templates (facebook#6451) Convert JSON.stringify \n to os.EOL when writing tsconfig.json (facebook#6610) Update html-webpack-plugin (facebook#6361) Enable click to go to error in console for TypeScript (facebook#6502) Update webpack-dev-server to 3.2.1 (facebook#6483) [docs] revert removal of newlines from html (facebook#6386) Publish Prepare 2.1.8 release Reapply "Speed up TypeScript v2 (facebook#6406)" (facebook#6586) Publish ... # Conflicts: # packages/babel-preset-react-app/create.js # packages/react-scripts/scripts/build.js
Ref. #5602
ESLint plugin should probably be behind an option in the preset, but enabled in CRA by default – this is not yet implemented.