Remove unused GitLab UI exports

What does this MR do?

Removes exports from GitLab UI modules that nothing uses, and stops publishing mock data:

  1. Stop publishing the mock_data.js files. They're fixtures for GitLab UI's own specs and stories, but the package's files list and the Rollup build both included them, so they were published in both src and dist.
  2. Remove unused chart mock data (mockRawBarData, mockDefaultLineChartConfig and mockDefaultBarChartConfig), and stop exporting getUniquePanelId from the dashboards mock data. As mock data is no longer published, this needs no changeset.
  3. Remove badgeSizeOptions, triggerVariantOptions and truncateOptions from src/utils/constants.js. The first has been obsolete since GlBadge lost its size prop, and the other two only listed prop values in the old Storybook docs.
  4. Remove the deprecated getDefaultTooltipContent from src/utils/charts/config.js.
  5. Stop exporting symbols only used within their own modules, such as pad in GlDatepicker and getAnnotationsConfig in src/utils/charts/config.js. The axes and xAxis chart presets stay exported alongside yAxis, which the column charts use.
  6. Stop publishing icon.figma.batch.ts, the icon Code Connect template, which the files list missed. It imports the figma module, 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-ui

The 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 badgeTypes constant, 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, and dist has no mock data files or imports of them.
  • npm pack --dry-run with npm 11.6.2, which publish_npm_packages uses: the only changes to the package contents are that the five src/**/mock_data.js files and icon.figma.batch.ts are gone. On main, dist also has a copy of each mock data file.
  • yarn lint:eslint and yarn 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

Documentation

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-label for 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" to aria-expanded="true" when an accordion is expanded.
  • Color combinations have sufficient contrast.
Edited by Mark Florian

Merge request reports

Loading
Loading