Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#49781 closed enhancement (fixed)

PHPCS config: exclude plugins and themes within src

Reported by: johnbillion's profile johnbillion Owned by: johnbillion's profile johnbillion
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-dev-note
Focuses: coding-standards Cc:

Description

When running the PHPCS linting locally (eg. with composer lint:errors), there are files that can exist within an installation that's running from src which should not be linted:

  • Plugins
  • Must-Use Plugins
  • Drop-in plugins
  • Themes other than the twenty* themes

These should all be excluded from linting so that a clean lint can be run on an active installation of WordPress running from src.

Attachments (1)

49781.diff (1.6 KB) - added by johnbillion 4 years ago.

Download all attachments as: .zip

Change History (10)

@johnbillion
4 years ago

#1 @johnbillion
4 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 5.5

#2 @SergeyBiryukov
4 years ago

  • Keywords commit added

#3 @jrf
4 years ago

  • Keywords commit removed

@johnbillion How do those files get into the src directory ?
Are there dev environment commands in place which generate those files ? or put them there ?

If not and if it's dev choice to put them there (for testing purposes or otherwise), this could become a never-ending list as different devs use different tools.

In that case, adjusting the WP Core ruleset is not the way to "fix" this.
Instead you should add a phpcs.xml file to the project root in your local environment. That file will be automatically ignored for committing, but should be automatically picked up by the PHPCS run.

In that file, you'd then have something like the following:

<?xml version="1.0"?>
<ruleset name="My WP Core ruleset">

	<!-- Import the main ruleset. -->
	<rule ref="./phpcs.xml.dist"/>

	<!-- ... add your own exclude rules tailored to your dev environment ... -->

</ruleset>

Does that help ?

Last edited 4 years ago by jrf (previous) (diff)

#4 @johnbillion
4 years ago

This is for running a WordPress site from src using npm run dev. It's a standard setup.

None of the exclusions are custom for my particular dev environment, they're all files that WordPress core supports and uses.

#5 @johnbillion
4 years ago

It's worth noting that all the files listed in 49781.diff already exist in .gitignore for the same reason.

#6 @jrf
4 years ago

  • Keywords commit added

Ok, in that case, sounds reasonable. Though it might be helpful to annotate the start and end of the list with a note saying that that list should be kept in sync with the .gitignore file ?

#7 @johnbillion
4 years ago

That's a good idea, and reminds me that the svn:ignore prop for SVN needs to be synced too as it's out of date. I'll open a ticket.

#8 @johnbillion
4 years ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from new to closed

In 47742:

Build/Test Tools: Exclude plugins and themes within src.

Just like the build directory, src can include plugins and themes which shouldn't be linted by PHPCS.

Fixes #49781

#9 @desrosj
4 years ago

  • Keywords has-dev-note added; commit removed
Note: See TracTickets for help on using tickets.