Skip to content
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

Various JSDoc + type checking fixes (for v4.4.0 only) #2997

Merged
merged 6 commits into from
Nov 10, 2022

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Nov 10, 2022

This PR fixes various JSDoc (and related code) issues identified in #2971

Including things like:

  1. I18n, Character Count and Accordion config param are optional
  2. I18n plural form other` is optional (with caveats)
  3. I18n alternative i18n.${lookupKey} translation usage removed
  4. Character Count config.maxlength and config.maxwords are mutually exclusive
  5. Various minor type fixes, test configs checked against JSDoc

All working fab here.

Screenshot showing wordsUnderLimit (string) not matching the TranslationPluralForms (object) JSDoc type

JSDoc comments for wordsUnderLimit mismatch as string

@colinrotherham colinrotherham added this to the v4.4.0 milestone Nov 10, 2022
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2997 November 10, 2022 12:23 Inactive
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting it, this feels much safer to merge ahead of the release 🙌🏻 Just noticed one possible misunderstanding about a test that got removed around flat keys for the character count JS config.

@colinrotherham
Copy link
Contributor Author

@romaricpascal Think we're all sorted now

I forgot we also accept config.accordion and config.characterCount on all.mjs

So I've had to link to the JSDoc config @typedef blocks from there too:
https://govuk-frontend-pr-2997.herokuapp.com/docs/javascript/global.html#initAll

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2997 November 10, 2022 14:00 Inactive
@@ -10,5 +10,8 @@ module.exports = {
source: {
includePattern: '.+\\.m?js$',
excludePattern: '.+\\.test.m?js$'
},
templates: {
cleverLinks: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not used @see or @link yet to other areas of the code but we're ready for it now

Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little mix-up when replacing the AccordionConfig, but all good to go otherwise 😄

Comment on lines +101 to +111
/**
* Config for all components
*
* @typedef {object} Config
* @property {HTMLElement} [scope=document] - Scope to query for components
* @property {import('./components/accordion/accordion.mjs').AccordionConfig} [accordion] - Accordion config
* @property {import('./components/button/button.mjs').ButtonConfig} [button] - Button config
* @property {import('./components/character-count/character-count.mjs').CharacterCountConfig} [characterCount] - Character Count config
* @property {import('./components/error-summary/error-summary.mjs').ErrorSummaryConfig} [errorSummary] - Error Summary config
* @property {import('./components/notification-banner/notification-banner.mjs').NotificationBannerConfig} [notificationBanner] - Notification Banner config
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, we were so focused on the individual components that all was completely neglected 😬 Good spot! 🙌🏻

@@ -31,13 +31,11 @@ var TRANSLATIONS_DEFAULT = {
*
* @class
* @param {HTMLElement} $module - HTML element to use for accordion
* @param {object} config - Accordion config
* @param {AccordionTranslations} config.i18n - Translations
* @param {AccordionTranslations} [config] - Accordion config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param {AccordionTranslations} [config] - Accordion config
* @param {AccordionConfig} [config] - Accordion config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant spot. All fixed and ready for you again 😊

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2997 November 10, 2022 15:06 Inactive
@colinrotherham
Copy link
Contributor Author

colinrotherham commented Nov 10, 2022

See the generated JSDoc config served by the review app

@colinrotherham colinrotherham requested a review from a team November 10, 2022 15:25
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@colinrotherham colinrotherham added 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) javascript assurance labels Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assurance 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) javascript
Projects
Development

Successfully merging this pull request may close these issues.

3 participants