Skip to content

Implement CLI filtering for audits and groups in plugins #922

@hanna-skryl

Description

@hanna-skryl

User story

As a CLI user, I want to have more granular control over which audits and groups are executed by plugins so that I can customize my reports without modifying the configuration file for every run.

Currently, CLI supports filtering by categories and plugins through options like --onlyPlugins, --skipPlugins, --onlyCategories, and --skipCategories. By introducing finer-grained filtering for audits and groups, I will be able to run tailored reports that focus on exactly what I need.

While individual plugins are not required to implement custom filtering logic, extending plugin configurations to support these filters is recommended for better user control and consistency.

Acceptance criteria

  • CLI arguments --onlyAudits, --skipAudits, --onlyGroups, and --skipGroups are parsed and passed correctly to the filtering middleware.
  • Middleware identifies and filters out items (audits/groups) marked as skipped based on options passed directly to the configuration object (no regression).
  • Categories with no valid references after filtering are removed from the final report.
  • If an audit is referenced by multiple groups and one group is filtered out, the audit should remain in the report if it is still referenced by another group.
  • The CLI should log all applied filters and list the affected audits, groups, plugins, and categories.
  • Ensure backward compatibility by maintaining existing behavior when no audit or group filters are applied.

Implementation details

Middleware Extension

Extend the existing filterMiddleware to handle new CLI options (--onlyAudits, --skipAudits, --onlyGroups, --skipGroups).

Plugin Modification (optional)

Currently, only the Lighthouse plugin supports options for filtering by audits and groups, which allows early marking of skipped audits and groups. To enable similar filtering behavior in other plugins, their respective configurations may be extended to handle these options.

While this extension is optional, it is recommended as it can improve user control over which audits and groups to include in the report.

Logging and Validation

  • Extend existing logging to display removed audits and groups, and plugins and categories that were emptied by audit- and group-level filters.
  • Extend final state validation logic to ensure consistency and prevent empty reports.
  • If all plugins are filtered out, display a warning and exit gracefully.
  • If --onlyAudits and --skipAudits or --onlyGroups and --skipGroups are both provided, throw an error indicating conflicting options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤓 UXUX improvement for CLI users

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions