tsdoc icon indicating copy to clipboard operation
tsdoc copied to clipboard

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

Open prescience-data opened this issue 3 years ago • 2 comments

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?

prescience-data avatar May 05 '22 00:05 prescience-data

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.

octogonz avatar May 05 '22 02:05 octogonz

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?

prescience-data avatar May 05 '22 10:05 prescience-data