Refactor classes into files #1522
Merged
+2,539
−2,500
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.
Pull Request
Problem
The single-file
index.js
is a bit intimidating to work in, specially for new contributors. We now have some classes which can stand alone.Issue: #1496
Solution
Short version: factor out the classes into separate files!
Implementation detail: the Help class takes parameter types of multiple classes, but this is a type dependency and not a code dependency. Using a TypeScript style JSDoc import allows the strong typing checks without introducing a circular
require
dependency betweenhelp.js
andcommand.js
. I am using Visual Studio Code which understands this for IntelliSense, and TypeScript uses this fornpm run typescript-checkJS
. If we have other editors people want to use that have their own imports, we can add them as required.I like that the exports are now simple and obvious in
index.tab
.ChangeLog
index.tab
into a file per class