Remove unused GitLab UI exports
What does this MR do?
Removes exports from GitLab UI modules that nothing uses, and stops publishing mock data:
- Stop publishing the
mock_data.jsfiles. They're fixtures for GitLab UI's own specs and stories, but the package'sfileslist and the Rollup build both included them, so they were published in bothsrcanddist. - Remove unused chart mock data (
mockRawBarData,mockDefaultLineChartConfigandmockDefaultBarChartConfig), and stop exportinggetUniquePanelIdfrom the dashboards mock data. As mock data is no longer published, this needs no changeset. - Remove
badgeSizeOptions,triggerVariantOptionsandtruncateOptionsfromsrc/utils/constants.js. The first has been obsolete since GlBadge lost itssizeprop, and the other two only listed prop values in the old Storybook docs. - Remove the deprecated
getDefaultTooltipContentfromsrc/utils/charts/config.js. - Stop exporting symbols only used within their own modules, such as
padin GlDatepicker andgetAnnotationsConfiginsrc/utils/charts/config.js. TheaxesandxAxischart presets stay exported alongsideyAxis, which the column charts use. - Stop publishing
icon.figma.batch.ts, the icon Code Connect template, which thefileslist missed. It imports thefigmamodule, which only exists in Code Connect.
Consumers can deep import these modules, so the first, third, fourth and fifth commits are breaking changes, each with its own major changeset that explains each removal. The last commit has a patch changeset, as that file could never be imported.
The vendored Bootstrap Vue files have many more exports that are only used internally, but they are left alone, as that code is being removed rather than maintained.
How this was found
This came from running knip 6.44.1 against packages/gitlab-ui. The config isn't committed. To reproduce, save this as knip.json in the repository root:
{
"$schema": "https://unpkg.com/knip@6/schema.json",
"workspaces": {
"packages/gitlab-ui": {
"entry": [
"src/index.js",
"src/charts.js",
"src/utils.js",
"src/config.js",
"bin/**/*.{js,mjs}",
"src/**/*.figma.ts",
"src/**/*.figma.batch.ts",
".storybook/webpack.config.js",
"test-runner-jest.config.js"
],
"project": [
"src/**/*.{js,vue}",
"bin/**/*.{js,mjs}",
"tests/**/*.js",
".storybook/**/*.js"
],
"ignore": [
"src/tokens/build/**",
"src/vendor/bootstrap-vue/docs/**",
"src/vendor/bootstrap-vue/.eslintrc.js",
"src/vendor/bootstrap-vue/scripts/**"
],
"paths": {
"~/*": [
"src/*"
],
"~helpers/*": [
"tests/__helpers__/*"
],
"@gitlab/ui": [
"src/index.js"
]
}
}
}
}Then run:
npx -p knip -p typescript knip --workspace packages/gitlab-uiThe entry points treat src/index.js as the main entry, plus src/charts.js, src/utils.js and src/config.js, which the GitLab monolith imports directly. Knip can't see everything, so each finding was checked by hand:
- The site workspace wasn't included in the knip run, so the site's imports were checked separately. That's why
HEX_REGEX, which knip reports as unused, is kept: the site's color contrast component uses it. - GitLab code search on the default branches of GitLab, CustomersDot, Duo UI, Status Page, Docs and Switchboard finds no use of any removed or unexported symbol. Duo UI has its own
badgeTypesconstant, which is unrelated.
Integrations
No integration merge requests are needed: code search on the default branches of the projects listed in the template found no use of any removed or unexported symbol, or any import of the mock data files.
Verification
- GitLab UI unit tests with Vue 2 and Vue 3: pass.
- GitLab UI build (
yarn build): passes, anddisthas no mock data files or imports of them. npm pack --dry-runwith npm 11.6.2, whichpublish_npm_packagesuses: the only changes to the package contents are that the fivesrc/**/mock_data.jsfiles andicon.figma.batch.tsare gone. Onmain,distalso has a copy of each mock data file.yarn lint:eslintandyarn lint:prettier: pass.- Not run locally: Storybook, the site build, and the visual and integration tests. CI covers those.
Does this MR meet the acceptance criteria?
This checklist encourages the authors, reviewers, and maintainers of merge requests (MRs) to confirm changes were analyzed for conformity with the project's guidelines, security and accessibility.
Toggle the acceptance checklist
Conformity
- The “What does this MR do?” section in the MR description is filled out, explaining the reasons for and scope of the proposed changes, per “Say why not just what”.
- For example, if the MR is focused on usage guidelines, addressing accessibility challenges could be added in a separate MR.
- Relevant label(s) are applied to the MR.
- The MR is added to a milestone.
- Added the
~"component:*"label(s) if applicable. - A changeset is added when this MR will do a patch, minor, or major update. More information can be found in
doc/changesets.md.
Components
- GitLab UI's contributing guidelines.
- If the MR changes a component's API, integration MR(s) have been opened (see integrations above).
Documentation
- If creating a new component page from scratch, it follows the page template structure.
- Content follows the GitLab Documentation Style Guide when appropriate.
- Related pages are cross-linked, where helpful. Component pages have related components and patterns defined in their Markdown front matter.
- If embedding a Figma file, it follows the Figma embed guide.
- Review requested from any GitLab designer or directly from a maintainer or trainee maintainer.
- Maintainer review follows the Pajamas UX maintainer review checklist.
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- Label as security and @ mention
@gitlab-com/gl-security/appsec - Security reports checked/validated by a reviewer from the AppSec team
Accessibility
If this MR adds or modifies a component, take a few moments to review the following:
- All actions and functionality can be done with a keyboard.
- Links, buttons, and controls have a visible focus state.
- All content is presented in text or with a text equivalent. For example, alt text for SVG, or
aria-labelfor icons that have meaning or perform actions. - Changes in a component’s state are announced by a screen reader. For example, changing
aria-expanded="false"toaria-expanded="true"when an accordion is expanded. - Color combinations have sufficient contrast.