Throw error on nonalphanumeric namespace #3
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.
[Closes #2]
Here's the PR to prevent users from accidentally choosing a namespace for a skill that will cause errors later.
I have 2 separate commits. The first sets up a minimal
tape
test environment and a single unit test for the error. If you're like me, you're more comfortable squashing a bug when there's a test to demonstrate it's fixed. However, if you don't want the dev dependency ontape
, which also pulls a number of other packages in (even though it's supposed to be the lightweight testing alternative), or you prefer a different library likemocha
orjasmine
, feel free to ask me to discard or change this commit.The second commit has the actual edit to
chatskills.js
. I decided to keep it as simple as I could, so I have a RegExp test for non-alphanumerics. I did not extract the namespace part of the RegExp expression in thesession
method because I think it would be difficult to use the partial pattern both in theadd
method and thesession
method. I don't think RegExps do not compose easily. Again, if you'd prefer I try to DRY things out, let me know.