-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
3.0 release #78
3.0 release #78
Conversation
@davidtheclark What should the behavior when
I think we should exit early with either an error or |
@sudo-suhas: These first two commits look good (ea485ed and 1f372ab). 82d5b79 does too much, though. I would have much preferred if the step of ES6ifying the code was a separate commit, because with all the formatting changes it's not possible review refactoring changes that you also made. If you're confident it's going to work fine, we can go with it — but I can't really review it.
So the file exists but has no content. Your idea of adding a more friendly error message sounds good 👍 . I'd suggest separating it from this PR, since it's a new feature instead of a code style & convention update. |
I have split and rebased it into separate commits. While I am reasonable confident with the changes(tests passed), it would be better if it were reviewed as well.
Though it is unlikely to impact anyone, technically this is a breaking change and that is why I brought it up here.. |
Thanks for splitting the commits! I'm going to ask that you split one more time, though, for safety. I think it's safer to refactor the code first without changing the tests, then refactor the tests without changing the code. That way you know you didn't introduce a bug in your code refactor that your test refactor swallowed. If we can do that, I'll be satisfied :) All the changes look great!
Ah, yes. Makes sense. |
Done 👍 Hopefully we can finish the rest of the refactoring by next week end. Edit: Did I misunderstand what you meant by one more split? Did you want me to split the ES6 refactoring commit for |
@sudo-suhas: Excellent! The branch looks great so far. |
I usually have the |
cosmiconfig did not have a consistent behavior for empty files. See #78 (comment) Throw error if cosmiconfig gets an empty file(JS/JSON/YAML) Add tests for empty file(JS/JSON/YAML)
cosmiconfig did not have a consistent behavior for empty files. See #78 (comment) Throw error if cosmiconfig gets an empty file(JS/JSON/YAML) Add tests for empty file(JS/JSON/YAML)
@davidtheclark, need a little help. I have migrated the test file |
@sudo-suhas: I'm not a big fan of the
My preference is to use the same syntax (and same linting) in the tests as in the codebase. |
Alright. I tend to take the dedupe thing a bit too far sometimes 😅. Please don't mind but what do you think of a middle ground? A simple function which just calls the given test function once in sync and once in async. function testSyncAndAsync(name, testFn) {
describe('sync', () => {
it(name, testFn(true));
});
describe('async', () => {
it(name, testFn(false));
});
} The differences in sync and async mode could be handled using |
👋 @sudo-suhas sorry this feel off my radar. I was visiting extended family. I will look at it soon! |
No problem at all 😄. Edit: I did a small commit amend for unneeded jest config in package.json: "jest": {
"testEnvironment": "node",
- "testPathIgnorePatterns": [
- "/node_modules/",
- "/_bkp_test/"
- ]
} |
@sudo-suhas: Seems ok to me 👌 . Is there anything in particular you wanted me to look at? |
Great. One of the things I wanted to know if you were okay with the helpers |
@sudo-suhas: Yeah, I'm a little wary of how much complexity there is in the tests now, making them more difficult to read and add to — but you've invested the time here, so if you think it's worthwhile, I'll take your word for it. Probably it makes plenty of sense after you write a few tests with the framework 👍 Am I right in thinking that 3.0 makes only one intentional change — introducing |
@davidtheclark I understand that we should strike the right balance wrt complexity and ease of writing a test(mainly repetition of similar steps). If you feel that we need to drop the helpers, I am more than willing to refactor all the required tests. Please take another look. Actually, there are a couple of other changes as well. The most important of which is dropping support for node < 4. Additionally, an error will be thrown on encountering an empty config file. |
Dropping support for Node 0.12 seems totally fine with me. Also, I like the empty config file error. Regarding test helpers — let's just go with what you wrote and see how it works! If we or contributors have problems with it, we can always refactor later. Does that sound good? |
That sounds great 👍 |
Oooooooh, the latest Prettier release uses cosmiconfig! https://github.com/prettier/prettier#configuration-file That means we have another big user, like stylelint, that we probably should double-check against before releasing this branch, @sudo-suhas 😬 |
That.. is pretty cosmic 😁. I remember we discussed integration tests. I had been meaning to ask you about it. So here's what I have so far. Use |
@sudo-suhas A few thoughts came to mind about this branch:
|
I can do that, no problem. Though, even now, remembering to format is not required as this is taken care by
As you can see in #78 (comment), we already throw errors for empty files in almost all cases. We would just be throwing a more accurate error instead of different ones for different file formats. Are you sure you want me to remove this check? |
@sudo-suhas: Ok, good decisions 👍 |
Setup pre-commit hook using husky with lint-staged Setup prettier and use eslint-config-prettier to avoid conflicts with eslint Run all files through prettier
- createExplorer.js - Add func resolveDir to check if given path is a dir and return parent dir if not(sync or async mode supported). - Use the same identity func for both sync and async. - loadRc.js - Add func makeRcFileParser to create a rc file parser for the given parse func, extension and the next extension. - funcRunner.js - Simplify using reduce
Move utility funcs statStubIsDirectory, makeReadFileSyncStub, assertSearchSequence,used for tests , to util.js
cosmiconfig did not have a consistent behavior for empty files. See #78 (comment) Throw error if cosmiconfig gets an empty file(JS/JSON/YAML) Add tests for empty file(JS/JSON/YAML)
@davidtheclark I have rebased and removed |
cosmiconfig did not have a consistent behavior for empty files. See #78 (comment) Throw error if cosmiconfig gets an empty file(JS/JSON/YAML) Add tests for empty file(JS/JSON/YAML)
Merged! |
The `3.0` branch was [merged] and [deleted], so we should use the default branch now. [merged]: cosmiconfig/cosmiconfig#78 (comment) [deleted]: cosmiconfig/cosmiconfig#78 (comment)
The `3.0` branch was [merged] and [deleted], so we should use the default branch now. [merged]: cosmiconfig/cosmiconfig#78 (comment) [deleted]: cosmiconfig/cosmiconfig#78 (comment)
Changelog
node-version-check
from deps() => {}
,const
/let
,${template} strings
createExplorer.js
resolveDir
to check if given path is a dir and return parent dir if not(sync or async mode supported).identity
func for both sync and async.loadRc.js
- Add funcmakeRcFileParser
to create a rc file parser for the given parse func, extension and the next extension.object-assign
from deps.statStubIsDirectory
,makeReadFileSyncStub
,assertSearchSequence
,used for tests , toutil.js
TODO
Closes #71