vscode-extensionsphpcs

How do I fix code not being ignored by phpcs in VSCode


I'm trying to (temporarily) ignore some errors about not using Nonces. I've tried using // @codingStandardsIgnoreLine. before the line, and I've tried using // phpcs:ignore WordPress.Security.NonceVerification.Missing., I'm still being notified of a nonce problem:

enter image description here

What have I done wrong? I'm using VSCode. I have PHPCS installed using composer, and the PHPCS (and -BF) extensions installed.


Solution

  • Did you add /Users/your-username/.composer/vendor/bin/phpcs as part of the installation? I had a similar issue because I had added another username.

    Also, make sure that the following line is at the root of your project in a terminal:

    composer require --dev squizlabs/php_codesniffer
    

    To ignore the line, you can alternatively type // phpcs:disable and // phpcs:enable at the beginning and end of the line.