-
Notifications
You must be signed in to change notification settings - Fork 925
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
refactor: port load to typescript #786
Conversation
25b5861
to
5b08411
Compare
@commitlint/cli/src/cli.js
Outdated
@@ -1,7 +1,8 @@ | |||
#!/usr/bin/env node | |||
require('babel-polyfill'); // eslint-disable-line import/no-unassigned-import | |||
|
|||
const load = require('@commitlint/load'); | |||
// fix: commitlint load is ported to typescript, until this one is ported we need to unpack it | |||
const {default: load} = require('@commitlint/load'); |
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 amounts to a breaking change for CommonJS consumers. Can we emit the module to contain the module.exports = ...
stanza instead? If i remember correctly there was a tsc settings for this...
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'll check it out!
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.
Doesn't fix the breakage for external CommonJS
consumers but we can use the default import interop babel provides.
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.
Maybe we should create a building library that works like bob
. With such a tool we can build commonjs
, module
and just typescript
definition files. I think that might be best to keep support for all platforms, right? Internally, we can just use the latest default module system.
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.
Looks good at first glance! I'll fiddle around a bit with the any
types and check if we can avoid the CommonJS breakage
Yeah, I agree with the |
Good job on switching to jest mocking! Thinking about it we might speed up Regarding the TS setting to emit CommonJS |
No idea why the pluginloader test acts up now... |
I'll take a look tomorrow! I bet it's still repairable 😬 |
@marionebl I may need some help finishing this one 😄 The types you added are great, but they also overlap with types from I also implemented the |
Yes, let's export and use the |
Co-authored-by: Armano <armano2@users.noreply.github.com>
jest.config.js
Outdated
'**/@commitlint/travis-cli/src/*.test.js?(x)', | ||
'**/@commitlint/cli/src/*.test.js?(x)', | ||
'**/@commitlint/prompt-cli/*.test.js?(x)' | ||
'**/@commitlint/{lint,read,travis-cli,cli,prompt-cli,load}/src/*.test.js?(x)' |
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 is not correct as prompt-cli
has no src
folder
Description
Part of #659
Motivation and Context
It's kind of an old attempt from me, with some new mocking mechanisms. Instead of using proxyquire, it uses jest. With jest, we can actually import typescript, with proxyquire we cant... I also "made it work" in the CLI, by unpacking from default. Think there might be some things in here that we should change, like the
any
castings. Let me know what you think! 😁Usage examplesHow Has This Been Tested?Types of changesChecklist: