-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSDoc to document plugin configs etc #2386
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c6be717
Add JSDoc types for `govuk-prototype-kit.config.json`
colinrotherham 57ff592
Add JSDoc types to argv parser
colinrotherham 0151084
Add JSDoc types to plugin validator
colinrotherham a3c6a13
Add JSDoc types for application scripts
colinrotherham 4d32d0d
Fix JSDoc `@returns` in `mkPrototype()`
colinrotherham 8f229fd
Fix JSDoc `@param` in `mkPrototype()`
colinrotherham 5e534e7
Fix to validate `nunjucksPaths` as a string
colinrotherham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any logic to support
nunjucksPath
being a string rather than an array of strings – I think we'd end up iterating over each character in the string on line 48?It looks like this might also be optional?
Should it be…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, the cypress tests use strings and a few places in the wild too:
UKHomeOffice/home_office_design_kit/blob/master/govuk-prototype-kit.config.json
that-firefly/testing-personal-prototypes/blob/testing-eg/govuk-prototype-kit.config.json
Possibly because we documented below (bit out of date) that strings were allowed?
govuk-prototype-kit/lib/plugins/plugins.js
Lines 27 to 30 in bb9528b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely give #2354 a try to see lots more red squiggles
Similar to 77b7943 you'll see it's still possible to access
configEntry.path
andconfigEntry.importFrom
even thoughconfigEntry
might be a string etcOr sometimes we just check the
key
name but not the type:govuk-prototype-kit/lib/plugins/plugin-validator.js
Lines 188 to 190 in bb9528b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like possibly the kit supports
nunjucksPaths
being a string but this validator doesn't allow for it?I mean, technically you can pass a string, but it'll try and iterate over it character by character and result in errors – what are we trying to document in the JSDoc? Technical compatibility or how it's designed to be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's it exactly
Just tried it with GOV.UK and everything works. The code was simplified recently but it's
flat()
that does the magic:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added JSDoc to document how the kit is currently used
That way (in theory) the compiler can error or show red squiggles on all the code that doesn't support the current usage. Except for looping strings, which is valid 🤦♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed up a tweak to handle
undefined
and strings at the same time in 5e534e7Ideally we should leave broken things broken and triage them?