Helper documentation/restructure POC #811
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Towards #722 and #725.
For the documentation, we can build upon jsdocs basically. The main thing is the description of the helper function: it should include where it is typically called (inline, at the top of a specific block, as a reference to the create method, etc), and the typical use case ("paired with other logic to conditionally do X or Y").
For the restructuring, I went with the intent of separating things out into their own files as much as possible, then from there creating directories for things that belong together. In this draft for example, the testHelpers file is split into 3 separate files with each housed in a testHelpers directory (the JSXAttributes file would be split out similarly, I only added some documentation there for now). The
getImportPath
helper, though, may not really fit in with any other helpers and would remain in the mainhelpers
directory.One question could be what we want to do with things that may not be used elsewhere, e.g. the checkMatchingImportDeclaration helper has a
checkSpecifierExists
function that's only used for that helper. We could just move those things to their own file as well -- worse case it's an extra file, best case maybe that file itself can be used elsewhere as well. I don't have a strong opinion either way.This PR also includes some tweaks I had made when I was originally working on a new modal codemod - namely the new getCodeModDataComment helper and some tweaks to the checkMatchingImportDeclaration helper.