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

Fix flow bugs #91

Merged
merged 6 commits into from
Nov 7, 2018
Merged

Fix flow bugs #91

merged 6 commits into from
Nov 7, 2018

Conversation

SebastienGllmt
Copy link
Contributor

As I was documenting some stuff, I noticed there were some flow mistakes in our code.
@sarveshwar-singh sorry for the merge conflict 🙏

The ugly // eslint-disable-next-line space-infix-ops is because of a bug in eslint that seems to have been fixed in 2016 but we have to upgrade our package to use it (hence why the branch name of this PR seems to be unrelated)

@SebastienGllmt SebastienGllmt changed the title Upgrade eslint & fix flow bugs Fix flow bugs Nov 5, 2018
@SebastienGllmt SebastienGllmt added the WIP / DO NOT MERGE Shows that a PR shouldn't be merge label Nov 6, 2018
@SebastienGllmt
Copy link
Contributor Author

Note: This PR doesn't solve all the errors that upgraded the packages discovered for us.

Notably, I left the following as warnings since they are clearly errors but they require more thought so they should probably be done in a separate PR:

react/require-default-props why this is a problem
react/button-has-type why this is a problem
react/no-array-index-key: why this is a problem

@@ -1,5 +1,12 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because the version of eslint we use is super recent so it can support a higher version of babel than we support for our actual codebase. Notably, it includes some change that requires you to change the order decorators are associated in your class. To disable this feature on linting (to match the version we are actually compiling with) I had to add this very cryptic extra field.

You can see the occasional Github issue come up related to this topic: babel/babel-eslint#662

@@ -112,8 +113,8 @@ export async function saveAsAdaAddresses(
addresses: Array<string>,
addressType: AddressType
): Promise<void> {
const mappedAddresses: Array<AdaAddress> = addresses.map((hash, index) =>
const mappedAddresses: Array<AdaAddress> = addresses.map((hash, index) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

I’m curious. I think it shouldn’t be necessary to add those 2 extra ( ). is it a configuration of the eslint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rule in Javascript is you can have a => on a new line without putting any parenthesis.

The eslint rules says if you put a => on a separate line, you should put () around it even if it's not required.

I think this makes sense. It's the same reason linters for various languages complain when you have an if that don't use curly braces. It's a common source of bugs when refactoring code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general though eslint is super strict that parenthesis should go on new lines. I agree that in cases like this it improves readability but in other places in the PR it you can see it just kind of bloats the code. Usually in cases where there is upside & downside to a linter rule I tend to just follow what the linter says since at least it allows us to standardize on some rule even if we don't always agree with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

eslint is a rule applier so it depends on the rules that we want. I didn’t know if you added the rule / if you preferred that way or both. 👍

@nicarq
Copy link
Contributor

nicarq commented Nov 6, 2018

@SebastienGllmt this is awesome!!! I would like to ask you if we could sync with the prettier formatter 🙏🙏🙏 so we don’t need to spend time doing crazy formating

@SebastienGllmt SebastienGllmt added NFC No Functional Change (pure refactoring/cleanup) and removed WIP / DO NOT MERGE Shows that a PR shouldn't be merge labels Nov 7, 2018
@nicarq nicarq merged commit df1d3ac into develop Nov 7, 2018
@nicarq nicarq deleted the fix/upgradePackages branch November 7, 2018 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NFC No Functional Change (pure refactoring/cleanup)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants