-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Conversation
@@ -9,6 +9,7 @@ | |||
}, | |||
"repository": "zeit/hyper", | |||
"description": "HTML/JS/CSS Terminal", | |||
"xo": false, |
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 makes xo
look upwards in the directory hierarchy for the next package.json
, see xojs/xo#151.
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.
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) { |
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.
:(
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.
Readable and consistent code ;)
sessions.length === 0
sessions.length > 3
sessions.length === 5
!sessions.length 👺
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.
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)
.
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.
!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 |
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.
I had to indent the second part of the ternary here, not sure if this is intended behaviour or a bug. @sindresorhus?
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.
What was the error?
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.
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.
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.
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.
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, |
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.
I would recommend placing non-standard package.json properties at the bottom.
@@ -1,3 +1,4 @@ | |||
/* eslint-disable import/no-dynamic-require */ |
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 would be better placed inline with the code it applies to. eslint-disable-line
can be used or eslint-disable-next-line
.
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.
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) { |
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.
Readable and consistent code ;)
sessions.length === 0
sessions.length > 3
sessions.length === 5
!sessions.length 👺
onMouseEnter={this.handleScrollEnter} | ||
onMouseLeave={this.handleScrollLeave} | ||
/> | ||
<div |
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.
What was the error?
"no-warning-comments": 0, | ||
"complexity": 0, | ||
"no-nested-ternary": 0, | ||
"import/no-extraneous-dependencies": 0, |
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.
You can remove this. Not needed anymore as XO handles electron
.
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.
Thanks, found out that we missed another dependency in app as well... 👍
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.
Yay, it's useful! :D
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.
It definitely is @jfmengels - great work :)
"quote-props": 0, | ||
"import/no-extraneous-dependencies": 0, | ||
"no-warning-comments": 0, | ||
"complexity": 0, | ||
"no-nested-ternary": 0, |
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.
Was removed from XO. So can be removed here too.
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.
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, |
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.
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(); |
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.
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.
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.
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())
.
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.
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()
?
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.
eslint-plugin-ava 3.1.1 was just released and should have fixed the issue.
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.
fixed, thanks @jfmengels :)
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. |
0de1d65
to
5d06d6c
Compare
For reference, the XO release notes: https://github.com/sindresorhus/xo/releases/tag/v0.17.0 |
@@ -1,3 +1,4 @@ | |||
/* eslint-disable quote-props */ |
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.
Just curious, why?
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.
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)
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 |
@@ -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 |
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.
Why is this one being ignored?
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.
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.
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.
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.
I would have called the file |
* Use parent xo config in app/ * lint: Fix xo 0.17 errors * app: add missing semver dependency
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).