10up / wpcs-action

GitHub Action to help you lint your PHP without additional dependencies within your codebase
MIT License
54 stars 13 forks source link

Update docs to note way to exclude rule #28

Closed harunollyo closed 1 year ago

harunollyo commented 1 year ago

I want to exclude these rules given below but did not find any option to pass it to GitHub action.

WordPress.Files.FileName.NotHyphenatedLowercase
WordPress.Files.FileName.InvalidClassFileName

I have tried with this but it did not work.

with:
    args: |
        --standard=WordPress
        --ignore=WordPress.Files.FileName.NotHyphenatedLowercase
        --ignore=WordPress.Files.FileName.InvalidClassFileName

Code of Conduct

jeffpaul commented 1 year ago

@10up/open-source-practice can someone please help chime in here?

peterwilsoncc commented 1 year ago

Hi @harunollyo,

You can use a project ruleset by creating file named phpcs.xml.dist in the root directory of your project, it should contain something like the following:

<?xml version="1.0"?>
<ruleset name="Project Rules">
    <rule ref="WordPress">
    <!-- Any of `WordPress|WordPress-Core|WordPress-Docs|WordPress-Extra|WordPress-VIP-Go|WordPressVIPMinimum|10up-Default` -->
        <exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
        <exclude name="WordPress.Files.FileName.InvalidClassFileName" />
    </rule>
</ruleset>

When setting up your workflow, use the use_local_config argument to specify the use of your repos file:

        - name: WPCS check
          uses: 10up/wpcs-action@stable
          with:
            standard: 'WordPress' # Standard to use. Accepts WordPress|WordPress-Core|WordPress-Docs|WordPress-Extra|WordPress-VIP-Go|WordPressVIPMinimum|10up-Default.
            use_local_config: 'true' # Use local config if available
jeffpaul commented 1 year ago

Updating this for us to update the docs to call out this sort of example

champsupertramp commented 10 months ago

Just want to add to the doc that they need to add repo_branch parameter if you're trying to process a specific branch because without this parameter, it defaults to the master or main branch:

Here's mine with the refactor branch:

name: WPCS check

on:
   pull_request:
   push:
      branches:
         - refactor
jobs:
   phpcs:
      name: WPCS
      runs-on: ubuntu-latest
      steps:
         - uses: actions/checkout@v2
         - name: WPCS check
           uses: 10up/wpcs-action@stable
           with:
               standard: 'WordPress|WordPress-Extra|10up-Default'
               use_local_config: 'true'
               repo_branch: 'refactor'
jeffpaul commented 10 months ago

@champsupertramp that's helpful, thanks! Mind opening a PR to edit the docs to note that?