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
WIP: replace flow with typescript-jsdoc #4325
Conversation
I see you removed flow directive from all files. You decided to remove all Flow code first, and add JSDoc whenever you can think of? Or Flow is still running? Could you add TypeScript to npm scripts, please? Can it also be added to |
Flow is running, but does not lint anything, I did it just for development purpose (don’t think about flow types). We can revert this commit and commit that removes flow-typed later |
Looks like our actual JavaScript got broken in the last commit. |
yes you are correct =) I will revert this for now |
This reverts commit 8b31acf
If someone wants to help I suggest to write what you are taking here. I will fix
I think files from this list are prioritize |
I have created issue related to |
FYI I've created a PR for adding definitions for |
@G-Rath I know how it works =) I just did not realizes that so many packages support both ways. Thanks for deep explanation! (babel as well provides util for both exports |
@G-Rath As I know there is no a lot of typescript in jsdoc examples + it poor documented (if compare with common Typescript), could you suggest any source of examples / rich information about typescript in jsdoc? as I know there are a lot of tests here - https://github.com/microsoft/TypeScript/tree/master/tests/cases/fourslash. However, it hard to find usage some use cases there (folder is pretty large) |
@vankop sadly not really; you've pretty much summed up the state of the situation. The two places I'd recommend are looking at The other place of information is the handbook. Finally, the eslint team are actually looking into this same thing, and so you might find interesting code in the PR. I'm also happy to experiment and mess around with things, so you're welcome to chuck code snippets at me to play w/ if something isn't working as nicely as you'd like, or point me at a file you'd like double-checked or think could be improved :) |
@hudochenkov looks like problem with CI still exists |
In a totally new places. Might be that it happens with code changes made in this PR. Though locally nothing fails in this branch. |
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 PR would be close to impossible to review :(
I've done the following to check not type related changes:
-
In a separate folder installed
npm install @babel/core @babel/cli prettier
. -
Add config for Prettier from repository and following config for Babel:
{ "generatorOpts": { "comments": false } }
It removes all comments and doesn't do any transpiling.
-
Run Babel to remove comments and then Prettier. Run on parent commit files, and then on the latest commit files.
npx babel ../stylelint/lib --out-dir before npx prettier "before/**/*.js" --write
Then compare two folders in Kaleidoscope.
There are quite few changes to JavaScript itself.
I've notices some changes and commented on them, but I don't think it makes much sense to do this comparison before this PR is ready and has not failing tests.
} | ||
|
||
if (cli.flags.version || cli.flags.v) { | ||
if (cli.flags.version) { |
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.
-h
and -v
removed. Please, add them back.
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.
as I understand from meow
this flags are aliases for help
and version
so it should work, or there is another behaviour?
let source; | ||
|
||
if (postcssResult) { | ||
if (postcssResult && postcssResult.root) { |
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.
Why add this check?
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.
Root possible undefined
|
||
const cached /*: ?postcss$result*/ = stylelint._postcssResultCache.get(options.filePath); | ||
const cached = options.filePath ? stylelint._postcssResultCache.get(options.filePath) : undefined; |
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.
Why this ternary?
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.
You can’t pass undefined in Map get
method
lib/getPostcssResult.js
Outdated
@@ -58,7 +58,7 @@ module.exports = function(stylelint /*: stylelint$internalApi*/) /*: Promise<?Ob | |||
stringify: postcss.stringify, | |||
}; | |||
} | |||
} else if (syntax) { | |||
} else if (stylelint._options.syntax) { |
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.
Why not use syntax
as before?
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.
here is a little bit tricky place stylelint._options.syntax
is undefined | string
so after assigning on line 41 syntax
implicitly have type undefined | string
, but after we assign to syntax
object - {parse: any, stringify: any}
as well.
@@ -122,13 +122,23 @@ module.exports = function(stylelint /*: stylelint$internalApi*/) /*: Promise<?Ob | |||
return result; | |||
}) | |||
.then((postcssResult) => { | |||
stylelint._postcssResultCache.set(options.filePath, postcssResult); | |||
if (options.filePath) { |
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.
Why additional check?
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.
options.filePath possible undefined same with get
method
Obviously, it is a problematic to review, if you have an idea how to split this, I will be glad to discuss.
Sorry, I did not have time to fix last 20 warnings. All welcome to take a look on them =) |
I would recommend focusing on adding the types, rather than removing flow. For example, there are a lot of files that have been changed b/c you're removed Even if flow is generating errors, the whole point of the PR is to move away from flow, so the errors shouldn't matter. You can also remove the typing files for flow in another PR, as while sure they're not needed anymore, they're also not doing anything and so don't need to be removed in this PR :) |
First I can suggest create separate PR with tsconfig and provided types. I think we can take types folder from this PR, then we can make PRs step by step with or without flow (on your demand).
I did it for the reason as described above - just for development reasons. As I see now it is not necessary (however some times flow and ts types are misleading)
Yes you are right, we can revert this commit
I think the main idea to stay with flow while TS will not cover stylelint' "core" |
@hudochenkov after restarting CI still fail for Node.js 12.x.x, maybe it is relates to my changes =) |
Was thinking this might be something I. could help with... But,I cannot get the logs of the failing jobs to display past line |
@ntwb it's a scrollable area. I always keep scrollbar enabled in OS settings :) |
# Conflicts: # lib/getPostcssResult.js
types is fine now, I think I will start to split this in several PRs |
@vankop btw the definitions for I'll circle back during the week and look to create definitions for the other libraries when I have a chance. Also, |
Thanks all for your reviews! All this work is done in separate issues 🎉 |
#4245
Help wanted 🤗