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

Consider JSDoc @import for non-exported types #5239

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/scripts/comments.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ function getReviewAppUrl(prNumber, path = '/') {
*/

/**
* @typedef {import('@octokit/plugin-rest-endpoint-methods').RestEndpointMethodTypes["issues"]} IssuesEndpoint
* @import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
* @typedef {RestEndpointMethodTypes["issues"]} IssuesEndpoint
* @typedef {IssuesEndpoint["listComments"]["parameters"]} IssueCommentsListParams
* @typedef {IssuesEndpoint["getComment"]["response"]["data"]} IssueCommentData
*/
157 changes: 125 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-jsdoc": "^48.2.2",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-markdown": "^4.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export function getHTMLCode(componentName, options) {
}

/**
* @typedef {import('@govuk-frontend/lib/components').MacroRenderOptions} MacroRenderOptions
* @import {MacroRenderOptions} from '@govuk-frontend/lib/components'
*/
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ export function getNunjucksCode(componentName, options) {
}

/**
* @typedef {import('@govuk-frontend/lib/components').MacroRenderOptions} MacroRenderOptions
* @import {MacroRenderOptions} from '@govuk-frontend/lib/components'
*/
9 changes: 6 additions & 3 deletions packages/govuk-frontend/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ module.exports = function (api) {
)

// Flag any JSDoc comments worth keeping
const isDocumentation = ['* @param', '* @returns', '* @typedef'].some(
(tag) => comment.includes(tag)
)
const isDocumentation = [
'* @param',
'* @returns',
'* @typedef',
'* @import'
].some((tag) => comment.includes(tag))

// Print only public JSDoc comments
return !isPrivate && isDocumentation
Expand Down
4 changes: 2 additions & 2 deletions packages/govuk-frontend/src/govuk/all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export { isSupported } from './common/index.mjs'
export { GOVUKFrontendComponent as Component } from './govuk-frontend-component.mjs'

/**
* @typedef {import('./init.mjs').Config} Config
* @typedef {import('./init.mjs').ConfigKey} ConfigKey
* @typedef {import('./init.mjs').Config} Config for all components via `initAll()`
* @typedef {import('./init.mjs').ConfigKey} ConfigKey - Component config keys, e.g. `accordion` and `characterCount`
*/
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ describe('normaliseDataset', () => {
})

/**
* @typedef {import('./../configuration.mjs').Schema} Schema
* @import { Schema } from '../configuration.mjs'
*/
Original file line number Diff line number Diff line change
Expand Up @@ -639,5 +639,5 @@ export class Accordion extends GOVUKFrontendComponentConfigurable {
*/

/**
* @typedef {import('../../common/configuration.mjs').Schema} Schema
* @import { Schema } from '../../common/configuration.mjs'
*/
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ export class Button extends GOVUKFrontendComponentConfigurable {
*/

/**
* @typedef {import('../../common/configuration.mjs').Schema} Schema
* @import { Schema } from '../../common/configuration.mjs'
*/
Loading