-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Update ESLint and add Stylistic Formatting #305
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
The tests are failing because I didn't run |
A appreciate the intention to make the code's formatting consistent and reproducible, but infortunately in the past years, whenever I have encountered prettier-formatted code, prettier's formatting style was really incompatible with the line-based nature of Git and trying to minimise unrelated changes in commits. I'm aware that I'm letting technical limitations of Git dictate my code style here, but given that I'm bound to use Git, the benefits of having Git-diff-friendly code formatting are significant: Less conflicts while rebasing/merging, more meaningful The problem that I have with automated formatting: It depends on a specific code section's business logic how likely it is to be extended in the future (e.g. an another argument added to a function call, or another field to an object), and the current tools cannot estimate that. For example a If we accept a "dumb" and therefore inherently Git-diff-unfriendly code formatting tool, let's pick one – or a well-supported way to get prettier to do this – that does the following:
|
Thank you for the detailed explanation! This gives me a new perspective and I'm thinking about adapting my usual workflow. Since prettier has very few options, I have chosen a different approach with the last commit. stylistic is much more adjustable than prettier. What do you think, is it worth going further in this direction? |
As example I added the linted/formatted index.js. |
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.
The linting setup currently produces output like this:
const locHints = (l.remarkRefs || []).
filter(ref => !!ref.hint && Array.isArray(ref.tagL)).
filter(({tagL}) => tagL.includes('RES_LOC') ||
tagL.find(t => t.slice(
0,
8,
) === 'RES_LOC_'), // e.g. `RES_LOC_H3`
// eslint-disable-next-line @stylistic/function-paren-newline
).
map(ref => ref.hint)
Following the goals I outlined before, I would like it to look as follows:
const locHints = (l.remarkRefs || [])
.filter(ref => !!ref.hint && Array.isArray(ref.tagL))
.filter(({tagL}) => (
tagL.includes('RES_LOC') ||
tagL.find(t => t.slice(0, 8) === 'RES_LOC_' // e.g. `RES_LOC_H3`
))
.map(ref => ref.hint)
(I wouldn't really mind the first .filter()
call being broken up into multiple lines; Same for the .find()
call. But trust people (contributors and me) to decide case-by-case, and would therefore turn off the rule about this.)
Sorry to put the tedious task of configuring a linter on you…
169f4af
to
3cf63fd
Compare
index.js
Outdated
}, opt) | ||
includeRelatedStations: true, | ||
}, | ||
opt) |
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 dislike the style, but for the sake of consistency, can we get all of thee arguments indented and with a trailing comma?
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.
Now it looks like that:
includeRelatedStations: true,
}, opt)
Do you want a trailing comma after opt?
I see it as a learning process, don't worry. Sorry, I just realized that I have to go back a few steps. Please wait with the review. |
6a1db01
to
8cd243e
Compare
I think I'm a bit closer to this what you want, but now I have to figure out why the tests are failing here. Locally they are not failing. I'll try to continue in the next few days. |
7103e25
to
6f813ca
Compare
Okay, the unit tests are now running 🚀 and I think we are now close to your specifications. I'm delighted that stylistic is so customizable 😃 There's certainly still potential for some fine-tuning. Would you like to take a look? There are changes to only 171 files 😅 |
0ee7b00
to
300a3e4
Compare
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'm happy with almost all formatting! Just some small items left.
Because I couldn't find a better way to contact you, so I'll ask here, independently of this PR: What do you think about becoming a co- oder fallback maintainer (up to you which) in case I end up not being able to take care of |
a7f0a56
to
22441fd
Compare
Co-Authored-By: Jannis R <[email protected]>
follow-up of 228c725
Thanks! |
🥳 |
Prettier and ESLint are a nice combination.Update: Because prettier hardly allows any customization, we switched to stylistic in the process of the review.