-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ES6 migration, repo harminization #451
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
Conversation
src/lib/get-commits.js
Outdated
'-E', | ||
'--format=%H==SPLIT==%B==END==', | ||
`${lastRelease.gitHead ? lastRelease.gitHead + '..' : ''}HEAD`, | ||
])); |
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.
do we need to wrap this block into ()
?
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’ve seen it in a few other places, 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.
Yes in order to reuse the stdout
variable.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assignment_without_declaration
I could also use different variables.
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.
ah got it, it’s fine, code is readable as is, I was just curious. And learned something, thanks 👍
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 thinking of doing a bit more refactoring in other PR actually. Mostly modularize a bit and splitting thing in different function.
That would make the code clearer, allow us to write more docs in the form of jsdoc.
Also that would simplify a lot the situation like were have to reuse variable.
Most of the case I do that is due to try
/ catch
to avoid having all the code depending the throwing function be part of the try block.
With more modularization, each function that throws could handle it's errors (ie process the error and rethrow a SemanticRealseError) so in the parent module that calls them we could have only one try
catch
block.
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 thinking of doing a bit more refactoring in other PR actually. Mostly modularize a bit and splitting thing in different function.
That would make the code clearer, allow us to write more docs in the form of jsdoc.
Also that would simplify a lot the situation like were have to reuse variable.
yeah +1 on doing that in follow up PRs, this one is quite big already
With more modularization, each function that throws could handle it's errors (ie process the error and rethrow a SemanticRealseError) so in the parent module that calls them we could have only one try catch block.
Sounds good to me
|
||
package-lock.json | ||
yarn.lock | ||
|
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.
EDITED: ignoring lockfiles like this is harmful, because lockfiles are still in your local machine (they're just invisible)
See https://github.com/luftywiranda13/remove-lockfiles#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.
What do you mean 'they're just invisible' ?
If they are not committed to the repo, they are not in the repo.
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.
i updated my comment, sorry 😆
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.
Also I added npmrc and .yarnrc to not regenerate them.
2 dotfiles to prevent lockfiles to be generated? I think it's overkill
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 point of removing the lockfiles is to do the development with latest versions of dependencies. Your solution (unless I'm missing something) just remove the lockfiles before commit even though they wouldn't be committed anyway due to gitignore.
That doesn't solve the problem as the lockfile will be present on the local machine until the contributor do a commit. So a contributor would do all the development and run the test locally with potentially outdated libraries. Therefore what worked on their local machines might not work on the CI.
Also adding 2 extra dependency + a commit hook seem more overkill to me than two one line dotfiles.
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 point of removing the lockfiles is to do the development with latest versions of dependencies.
yes, I know. that's the main reason why I decide to never commit lockfiles in my projects
Also adding 2 extra dependency + a commit hook seem more overkill to me than two one line dotfiles.
hmmm I think #451 (comment) is a relevant answer
"nyc": "^10.0.0", | ||
"nyc": "^11.2.1", | ||
"p-map-series": "^1.0.0", | ||
"prettier": "^1.7.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.
Isn't it better to integrate prettier + eslint in pre-commit hook
?
So we can make sure prettier + eslint reformat any changes before committing
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.
Also this approach will reduce the possibility of us having code style discussion in code review
#451 (comment)
Edited: if i got it right ✌️
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.
We had this discussion about commit hook previously among maintainer and we've decided to not use commit hook for simplicity. Also that could create confusion for contributors to see their code automatically changed on commit.
The chosen solution is to enforce the formating with eslint (with eslint-plugin-prettier).
All the code format pushed is validated in CI with eslint to be sure it's formatted with prettier.
This comment is not really about style but more about a not well know javascript feature allowing to reassign let
variables with destructuring.
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.
We had this discussion about commit hook previously among maintainer...
cool, I respect that 👍
The chosen solution is to enforce the formating with eslint (with eslint-plugin-prettier).
All the code format pushed is validated in CI with eslint to be sure it's formatted with prettier.
yeah, the changes will fail on CI if they're not following our prettier config but then we still have to discuss about the code style things in the PR, right? isn't it not so good in terms of productivity?
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.
Not really because eslint
will run on npm run test
. So a contributor would figure that out before committing.
Sure we could run npm run test
on each commit or something like that but:
- Most contributor would know they have to at least run unit test before commiting
- For some less experienced contributors, we prefer answer them in the PR and help them as we believe guidance from a human would be more pleasant and helpful than an error message on commit
And there wouldn't be any style discussion, the style is enforced by eslint + prettier. There would be just explanation on how to read the eslint error, how to format properly, and maybe suggestion to use tools etc...Anything helpful for the contributor.
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.
they will also fail when you run npm test
locally
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"trailingComma": "es5" | ||
}, |
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.
IMO it's better to put prettier config directly inside eslint config. we're using eslint-plugin-prettier
, right?
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.
No because prettier config is read by editor tools and by the prettier
command itself.
Actually it work the other way around, it's eslint-plugin-prettier
that read the prettier config. See prettier/eslint-plugin-prettier#55
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.
Actually it work the other way around, it's eslint-plugin-prettier that read the prettier config. See prettier/eslint-plugin-prettier#55
yeah, it's added in v2.3.0. but it still can read the config directly if we put the config in rules
field
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.
Prettier config in prettier
property, Eslint config in eslintConfig
property seems more clear to me. Not sure what would be the point of moving it around.
But thanks for the feedback :)
do you know what’s up with codecov? |
Yes, it's because codecov has nothing to compare against to figure out if the coverage reduced as it has never ran on But let me check if I can put a config to not report statuses when there is no comparison point. |
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 for the review & comments @luftywiranda13
So there is a way to prevent codecov to fail on the first PR that use it: https://github.com/codecov/support/issues/173#issuecomment-216067683 But apparently it can also create situation in which Codecov would report success when coverage may be faulty. |
yeah feel free to merge it as is any time, I just don’t do it myself because I’m not sure if you still fine tuning it :) |
I'm fine with it as is. I'm gonna wait a few hours while I work on the following PR locally in case anyone as additional comments. @luftywiranda13 Thanks for the review 👍 |
fc06332
to
d505b5b
Compare
- Use async/await instead of callbacks - Use execa to run command line - Use AVA for tests - Add several assertions in the unit tests - Add documentation (comments) in the tests - Run tests with a real git repo instead of mocking child_process and add test helpers to create repos, commits and checkout - Simplify test directory structure - Simplify code readability (mostly with async/await) - Use eslint for for linting, prettier for formatting
- Avoid double build on PR - Add git fetch depth - Remove cache - Retry npm install
🙌 |
child_process
and add test helpers to create repos, commits and checkoutstandard
toeslint
+eslint-config-standard
+ prettier.gitignore
that would work on Windows, Linux, Mac OSThe test coverage appear to be worse than before because
src/index.js
was not included in the coverage and it is now. The coverage is actually a bit better now.I'll add more tests in a following PR.
Overall this PR doesn't change functionality, and does not fix bugs. It makes code and unit/integration tests more readable and easier to understand, hopefully making the project more accessible to contributors.
I found several improvement and bugs to fix will rewriting the tests. That will come in following PRs.
Fix #391, Fix #378, Fix #361