-
Notifications
You must be signed in to change notification settings - Fork 33
Use eslint for finer control of code format #225
Conversation
I would personally prefer to disable console statements, but I know this one is contentious so I won't do it as part of this first iteration
It's not going to be formatted correctly, better to keep it cleanly separated from the code we want to maintain
The single quotes matter 😬
.eslintrc.js
Outdated
semi: ["error", "never"], | ||
quotes: [ | ||
"error", | ||
"double", |
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.
double quotes 😫
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.
@micahalcorn Do you prefer single quotes? I'm not opinionated on it, I just chose double because more of our code was using double. 😃
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 vote for single quotes too :-)
let [ | ||
listingAddress, | ||
const [ | ||
, |
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.
Are these now rogue commas? 😕
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.
@micahalcorn Nah, it's just destructuring syntax for ignoring values we don't care about. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment (section "Ignoring some returned values")
const IN_DISPUTE = 4 // We are in a dispute | ||
const REVIEW_PERIOD = 5 // Time for reviews (only when transaction did not go through) | ||
// const IN_DISPUTE = 4 // We are in a dispute | ||
// const REVIEW_PERIOD = 5 // Time for reviews (only when transaction did not go through) |
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.
Reviews ended being parts of 2️⃣and 3️⃣. Should this just be removed completely, or are we planning to bring back a post-dispute review period @DanielVF?
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.
Imho we don't have to make that decision now - that's why I just commented them out, so we don't have to deal with it in this PR. (I think it's better to just keep this focused on the linter change.)
I'll defer to @DanielVF on some of this. I certainly favor |
I really like eslint too @tyleryasaka - thanks for working on this.
^^^ haha - oops - thought this was in the demo-dapp repo 🤦♂️ |
@jordajm Once this gets merged I can do a similar PR in demo dapp repo! |
.eslintrc.js
Outdated
@@ -0,0 +1,35 @@ | |||
module.exports = { |
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.
Can we put this in package.json instead of another dotfile?
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.
done
@@ -62,7 +60,6 @@ | |||
"mocha": "^5.1.1", | |||
"mocha-loader": "^1.1.3", | |||
"node-watch": "^0.5.8", | |||
"prettier": "1.12.1", |
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.
Does eslint do automatic file formatting? In other projects I've used both prettier and eslint together without issues
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.
@nick Yeah eslint does file formatting. Eslint does everything we need it to do - I don't see any use for prettier.
npm run format
still fixes all the files in place (to the extent that it can be done automatically).
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.
Apparently prettier is more powerful than eslint at formatting files. Perhaps we can run both eslint and prettier separately on demo-dapp, see which does a better job and decide to dump prettier based on that?
I prefer const > let > var as well.
Prettier as done a great job of just automatically working and bringing the code into formatting spec. There a big difference between a tool you just run and it works, vs something that spits out lists of spacing errors that you have to go fix yourself - which has always been my past experience with eslint. (Has it gotten better?) |
RE: single / double quotes, a convention I have heard of is to use double
quotes to specifically denote strings, since a lot of times in code there
will be string types that are not necessarily strings. Object/dictionary keys, for instance.
Sort of like the string and symbol distinction in ruby. They can be
substituted for one another, though a symbol usually denotes a string value
as opposed to a string.
…On Tue, Jun 5, 2018 at 12:09 PM, Daniel Von Fange ***@***.***> wrote:
I prefer const > let > var as well.
const does catch errors from time to time. I don't like it, since it
makes half my lines longer than the should be and harder to read, but the
utility is undoubtable, and so I use it anyway.
Prettier as done a great job of just automatically working and bringing
the code into formatting spec. There a big difference between a tool you
just run and it works, vs something that spits out lists of spacing errors
that you have to go fix yourself - which has always been my past experience
with eslint. (Has it gotten better?)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#225 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJiZ2sjy0MlzuQzOT3PgosBx4yKhl02ks5t5tdrgaJpZM4UZ9f2>
.
|
Line 14 in b111e2a
Edit: Just saw @nick 's comment. I'll try setting up prettier and eslint side by side then. |
Per @nick 's request; removes the need for yet another dot file.
This layers prettier on top of eslint for better in-place code formatting.
Updated to use prettier-eslint-cli |
By majority vote!
Single quotes it is! The vote is 2:1 in favor of single quotes. (I abstained but if I had to pick I also like single quotes - easier for me to read and type.) |
Next up: spaces vs tabs... jk jk |
@micahalcorn I believe I have addressed all the concerns raised here. How do you feel about merging this? (Good to merge as quickly as possible to reduce conflicts.) |
Checklist:
develop
branch instead ofmaster
Description:
Switches us from using just prettier to using eslint + prettier
I switched to eslint because it is much more configurable, and I have had a great experience it with it on another project.
We now have:
doublesingle or backticks)