Skip to content

Exclude test and tooling code from WPCS - #71

Merged
rdom-si merged 1 commit into
masterfrom
fix/wpcs-exclude-test-tooling
Sep 14, 2026
Merged

rdom-si merged 1 commit into
masterfrom
fix/wpcs-exclude-test-tooling

Conversation

@rdom-si

@rdom-si rdom-si commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Problem

phpcs.xml scans the whole repo (<file>.</file>) and excluded only the plugin's own css and js. The integration test work merged around 11 September added Playwright configs at the repo root, helper scripts under scripts/, and specs and PHP fixtures under tests/. WPCS lints all of it as WordPress plugin code and it fails on indentation and missing file docblocks.

wpcs.yml runs on: pull_request only, so nothing re-checked master after that merge. The breakage stayed invisible until the next PR was opened against master, and every PR raised against master currently fails this way, including #70.

Fix

Exclude tests/, playwright*.config.js, scripts/ and node_modules/.

Only /siteimprove is copied into the published package (cp -r siteimprove/* deploy/ in the deploy action), so the linted scope now matches the code that actually ships.

Verification

Every file WPCS flagged is covered by the new patterns, and no plugin source is:

  • covered: playwright*.config.js (3), scripts/*.js (2), tests/** (13, including the PHP fixtures and template)
  • still linted: everything under siteimprove/ apart from the pre-existing css and js exclusions

I could not run phpcs locally, since PHP is not installed on this machine, so CI on this PR is the real check.

Note

If you would rather the PHP fixtures under tests/ stay linted, the narrower option is to exclude only the JS and keep tests/**/*.php in scope. I excluded the whole directory because test fixtures are not shipped code.

A more durable alternative to a growing exclusion list is changing <file>.</file> to <file>siteimprove</file>, which scopes WPCS to the published directory permanently and means new root-level tooling can never break CI again. I did not do that here because it is a broader change than the one asked for, but it is worth considering as a follow-up.

phpcs.xml scans the whole repo and excluded only the plugin's own css and js.
The integration test work added Playwright configs at the repo root, helper
scripts under scripts/, and specs and fixtures under tests/, none of which are
WordPress plugin code. WPCS lints them anyway and they fail on indentation and
missing file docblocks.

wpcs.yml runs on pull_request only, so nothing re-checked master after that
merge and the breakage was invisible until the next PR opened against it. Every
PR raised against master currently fails for this reason.

Exclude tests/, playwright*.config.js, scripts/ and node_modules/. Only
/siteimprove is copied into the published package, so the linted scope now
matches the code that actually ships.
@rdom-si
rdom-si requested a review from a team as a code owner September 14, 2026 15:41
@rdom-si
rdom-si merged commit e477833 into master Sep 14, 2026
1 check passed
@rdom-si
rdom-si deleted the fix/wpcs-exclude-test-tooling branch September 14, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant