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 xo 0.17 errors and use root xo config for app #859

Merged
merged 3 commits into from
Oct 13, 2016
Merged

Fix xo 0.17 errors and use root xo config for app #859

merged 3 commits into from
Oct 13, 2016

Conversation

ekmartin
Copy link
Contributor

I've ignored import/prefer-default-export - as we have a lot of plural filenames that currently only export one function (basically most of ./lib/utils). We could change these to default exports, but I don't think it makes it any clearer (rather the opposite).

@@ -9,6 +9,7 @@
},
"repository": "zeit/hyper",
"description": "HTML/JS/CSS Terminal",
"xo": false,
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 makes xo look upwards in the directory hierarchy for the next package.json, see xojs/xo#151.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend placing non-standard package.json properties at the bottom.

@@ -88,7 +88,7 @@ function createExitAction(type) {
}

const sessions = keys(getState().sessions.sessions);
if (!sessions.length) {
if (sessions.length === 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(

Copy link
Contributor

Choose a reason for hiding this comment

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

Readable and consistent code ;)

sessions.length === 0
sessions.length > 3
sessions.length === 5
!sessions.length 👺

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still, I would usually write if (!something) instead of if (something === false) - even if I only wanted to compare it to false (not null etc.). If it was up to me an empty array would be falsey as well, and I'd have just written if (!sessions).

Copy link
Contributor

Choose a reason for hiding this comment

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

!something and !something.length is not the same thing. The first one is a lot clearer than the latter.

onMouseEnter={this.handleScrollEnter}
onMouseLeave={this.handleScrollLeave}
/>
<div
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 had to indent the second part of the ternary here, not sure if this is intended behaviour or a bug. @sindresorhus?

Copy link
Contributor

Choose a reason for hiding this comment

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

What was the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, maybe related to jsx-eslint/eslint-plugin-react#901

That being said, the code there is not very readable. I would personally have put them in two separate variables and used the variables in the ternary instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ye, I would've probably used a couple of extra stateless components or a render function as well - should take a look at it some time. Thanks for the link.

@@ -9,6 +9,7 @@
},
"repository": "zeit/hyper",
"description": "HTML/JS/CSS Terminal",
"xo": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend placing non-standard package.json properties at the bottom.

@@ -1,3 +1,4 @@
/* eslint-disable import/no-dynamic-require */
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be better placed inline with the code it applies to. eslint-disable-line can be used or eslint-disable-next-line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it. Didn't know about eslint-disable-next-line - thanks.

@@ -88,7 +88,7 @@ function createExitAction(type) {
}

const sessions = keys(getState().sessions.sessions);
if (!sessions.length) {
if (sessions.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Readable and consistent code ;)

sessions.length === 0
sessions.length > 3
sessions.length === 5
!sessions.length 👺

onMouseEnter={this.handleScrollEnter}
onMouseLeave={this.handleScrollLeave}
/>
<div
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the error?

"no-warning-comments": 0,
"complexity": 0,
"no-nested-ternary": 0,
"import/no-extraneous-dependencies": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove this. Not needed anymore as XO handles electron.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, found out that we missed another dependency in app as well... 👍

Choose a reason for hiding this comment

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

Yay, it's useful! :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It definitely is @jfmengels - great work :)

"quote-props": 0,
"import/no-extraneous-dependencies": 0,
"no-warning-comments": 0,
"complexity": 0,
"no-nested-ternary": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Was removed from XO. So can be removed here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 👍

@@ -63,13 +63,14 @@
"rules": {
"eqeqeq": ["error", "allow-null"],
"no-eq-null": 0,
"react/prop-types": 0,
"babel/new-cap": 0,
"new-cap": 0,
"quote-props": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Was changed to what you want, so can be removed and enabled again.

@@ -27,11 +27,11 @@ test.before(async () => {
path: pathToBinary
});

await app.start();
return app.start();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be better to use a ESLint ignore comment until it's fixed: avajs/eslint-plugin-ava#147 I would also add a TODO comment about removing the ignore when fixed in eslint-plugin-ava.

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 did that at first, but realized that using async/await only for the last promise return was a bit over the top anyway - this looks quite clean: test.after(() => app.stop()).

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how using async/await here is over the top. It works pretty much the same internally (async functions return a promise), but is more readable and easier to work with. What if you suddenly want to do something after app.start()?

Choose a reason for hiding this comment

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

eslint-plugin-ava 3.1.1 was just released and should have fixed the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks @jfmengels :)

@sindresorhus
Copy link
Contributor

We could change these to default exports, but I don't think it makes it any clearer (rather the opposite).

But does it makes it any worse? I don't think so. I feel it's generally better to use default exports when possible. One thing. One concern.

@ekmartin ekmartin force-pushed the xo_false branch 3 times, most recently from 0de1d65 to 5d06d6c Compare October 11, 2016 18:15
@sindresorhus
Copy link
Contributor

For reference, the XO release notes: https://github.com/sindresorhus/xo/releases/tag/v0.17.0

@@ -1,3 +1,4 @@
/* eslint-disable quote-props */
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

divider_horizontal and family aren't camel case identifiers. Preferably I would've changed it to be divider-horizontal instead, but it would be a bit rash as someone might be using the underscore separated identifiers in a plugin or similar.

The reason it's not dividerHorizontal is this: https://github.com/zeit/hyper/blob/master/lib/components/split-pane.js#L86 (could of course capitalize though)

@ekmartin
Copy link
Contributor Author

Thank you for the feedback.

In regards to the default exports issue I completely agree if the filename matches the intent of the export, however in these cases it really doesn't. Take this as an example. If this should've been a default export I think the file should've been called last as well (like this one), to at least make it a little less confusing. I don't think that makes it any clearer, or easier to use though.

@@ -410,7 +410,7 @@ function installDevExtensions(isDev) {
if (!isDev) {
return Promise.resolve();
}
const installer = require('electron-devtools-installer'); // eslint-disable-line global-require
const installer = require('electron-devtools-installer'); // eslint-disable-line import/no-extraneous-dependencies
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this one being ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. Normally when we have dependencies that are used in both the main process and the renderer we duplicate the dependencies to both package.json files. electron-devtools-installer is only used in dev however, and is only imported in the app itself. The problem is that install-app-deps from electron-builder doesn't install devDependencies, so we can't have it there. Not sure what the best solution would be.

Choose a reason for hiding this comment

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

It could be a slightly better idea to, instead of turning it off, changing the config of the rule at that position, to turn on the devDependencies option. That way, if someone removes it from the project while it's still being used, you'd still get the error here.

It's a bit akin to nitpicking as it's a very edge case probably, but I think it's a worthwhile change.

@sindresorhus
Copy link
Contributor

I would have called the file array-last.js.

@rauchg rauchg merged commit 7a08b1d into master Oct 13, 2016
@rauchg rauchg deleted the xo_false branch October 13, 2016 01:37
tylerong pushed a commit to tylerong/hyper that referenced this pull request Jul 3, 2017
* Use parent xo config in app/

* lint: Fix xo 0.17 errors

* app: add missing semver dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants