microsoft / tsdoc

A doc comment standard for TypeScript
https://tsdoc.org/
MIT License
4.7k stars 130 forks source link

`eslint-plugin-tsdoc` plugin AST to convert jsdoc to tsdoc on `--fix` #323

Open prescience-data opened 2 years ago

prescience-data commented 2 years ago

I'm tinkering around to see if this is possible but would love to avoid going down a rabbit hole if not likely to work.

https://github.com/wvbe/experimental-jsdoc-to-tsdoc-tool

I've been using a local version of this library to convert any jsdoc blocks autogenerated by a team member's IDE to tsdoc prior to calling @microsoft/api-extractor and before eslint --fix in CI.

It would be awesome if there was an experimental/opt-in way to have eslint-plugin-tsdoc (which already has identified the problem blocks) to auto-convert jsdoc comments to their tsdoc equivalent (and remove non-conforming tags) in real-time via the IDE's eslint integration.

I've been encouraged by the way eslint-plugin-prefer-arrow seems to be able to rewrite function foo() {} to const foo = () => {} reliably, but haven't dug deep enough into eslint to be sure the scenario described above is feasble.

Separate from any sort of official support or implementation - does this sound like something that is actually possible with eslint?

octogonz commented 2 years ago

The approach of experimental-jsdoc-to-tsdoc-tool seems pretty good. Thanks for sharing that link BTW -- I wasn't aware of it!

I'd also be in favor of providing an ESLint "fixer" so that comments can be converted without having to install and invoke a separate CLI tool. For big bulk conversions, the CLI tool is maybe a superior approach (since it can have more options and controls), but certainly for quick fixes the ESLint integration would be handy.

For details about how ESLint fixers are defined, see these docs.

I probably don't have time to work on this myself, but if someone else wants to a contribute a PR, I can help with the design & approval.

prescience-data commented 2 years ago

someone else wants to a contribute a PR, I can help with the design & approval.

Is there a style guide for the tsdoc repo that should be referenced for PRs?