You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With JS and CSS tokenizers slated to be removed in 4.0 of PHPCS, we may have to remove our JS/CSS sniffs for compatibility: squizlabs/PHP_CodeSniffer#2448
Side note: @gudmdharalds has confirmed that the vip-go-ci bot can integrate eslint, and we can therefore look at having it use something like https://github.com/mozilla/eslint-plugin-no-unsanitized and similar eslint plugins to identify some of what the sniffs here are looking out for.
squizlabs/PHP_CodeSniffer#2448 (comment) says that PHPCS 4 won't be released until at least 2020, so we have plenty of time before this needs actioning (unless we feel that the eslint solution gives a better outcome / fewer false positives and want to use it sooner rather than later).
In PHPCS itself, PHPCSStandards/PHP_CodeSniffer#276 was used to add @deprecated annotations to the relevant sniffs as a "soft deprecation" (defined as "deprecation via changelog mention and/or announcement only."). We can do this today.
Also PHPCSStandards/PHP_CodeSniffer#188 covers how the sniffs will be hard deprecated ("a deprecation notice will be shown at runtime, but will not affect the exit code of PHPCS.") in the last PHPCS 3.x minor release. This is using the new native handling of deprecated sniffs for PHPCS 3.9 (which we'll need VIPCS to have as a minimum to make use of it).
We can do the same for VIPCS. It means we'll need to have a major VIPCS release that fully removes these sniffs, before we can support PHPCS 4 (which will have the CSS and JS tokenizers removed that our deprecated sniffs would otherwise try and use).
@GaryJones Glad you like what I've done to make deprecating sniffs more user-friendly 😀
Just to give you some idea, I'm hoping to release version 4.0 ~ end of May (though conferences & speaking may interfere with my planning).
Before 4.0 will be released, some utilities will be added to PHPCSUtils to make cross-version support for PHPCS 3.x/4.x (for scanning PHP files and running tests) easier and to make it more straight-forward to make sniffs compatible with the Tokenizer changes which are included in PHPCS 4.0.
I want those things to be available before releasing 4.0, which should hopefully also encourage more external standards to adopt PHPCSUtils.
I'm currently working on these new features in Utils and intend to include these utilities in PHPCSUtils 1.1.0 (along with some other new helper functionality).
@rebeccahum I see you included the UserExperience/AdminBarRemovalSniff.php sniff in the list, which uses CSS and PHP tokenizers. Do you think there is value in stripping out the CSS portion and just leaving the PHP checks?
Likewise, how about the Twig, UnderscoreJS, VueJS, Mustache sniffs? Should the whole sniff be soft deprecated, or is there still something to be gained by checking with just the PHP tokenizer?
Activity
GaryJones commentedon Sep 11, 2019
Side note: @gudmdharalds has confirmed that the vip-go-ci bot can integrate eslint, and we can therefore look at having it use something like https://github.com/mozilla/eslint-plugin-no-unsanitized and similar eslint plugins to identify some of what the sniffs here are looking out for.
squizlabs/PHP_CodeSniffer#2448 (comment) says that PHPCS 4 won't be released until at least 2020, so we have plenty of time before this needs actioning (unless we feel that the eslint solution gives a better outcome / fewer false positives and want to use it sooner rather than later).
GaryJones commentedon Feb 16, 2024
In PHPCS itself, PHPCSStandards/PHP_CodeSniffer#276 was used to add
@deprecatedannotations to the relevant sniffs as a "soft deprecation" (defined as "deprecation via changelog mention and/or announcement only."). We can do this today.Also PHPCSStandards/PHP_CodeSniffer#188 covers how the sniffs will be hard deprecated ("a deprecation notice will be shown at runtime, but will not affect the exit code of PHPCS.") in the last PHPCS 3.x minor release. This is using the new native handling of deprecated sniffs for PHPCS 3.9 (which we'll need VIPCS to have as a minimum to make use of it).
We can do the same for VIPCS. It means we'll need to have a major VIPCS release that fully removes these sniffs, before we can support PHPCS 4 (which will have the CSS and JS tokenizers removed that our deprecated sniffs would otherwise try and use).
jrfnl commentedon Feb 16, 2024
@GaryJones Glad you like what I've done to make deprecating sniffs more user-friendly 😀
Just to give you some idea, I'm hoping to release version 4.0 ~ end of May (though conferences & speaking may interfere with my planning).
Before 4.0 will be released, some utilities will be added to PHPCSUtils to make cross-version support for PHPCS 3.x/4.x (for scanning PHP files and running tests) easier and to make it more straight-forward to make sniffs compatible with the Tokenizer changes which are included in PHPCS 4.0.
I want those things to be available before releasing 4.0, which should hopefully also encourage more external standards to adopt PHPCSUtils.
I'm currently working on these new features in Utils and intend to include these utilities in PHPCSUtils 1.1.0 (along with some other new helper functionality).
GaryJones commentedon Feb 16, 2024
@rebeccahum I see you included the
UserExperience/AdminBarRemovalSniff.phpsniff in the list, which uses CSS and PHP tokenizers. Do you think there is value in stripping out the CSS portion and just leaving the PHP checks?Likewise, how about the Twig, UnderscoreJS, VueJS, Mustache sniffs? Should the whole sniff be soft deprecated, or is there still something to be gained by checking with just the PHP tokenizer?
Edit: added develop...feature/soft-deprecate-sniffs-for-phpcs-4.0 but will hold off on the PR until these questions have answers.
Soft deprecate sniffs which will be removed for PHPCS 4.0
rebeccahum commentedon Feb 16, 2024
Re: the admin bar, yeah, I think that would be fine since that is something we will strongly discourage.
Re: the other templating engines, I'm not sure how useful they are, so I'm fine with a soft deprecation.
[-]Remove JS/CSS Sniffs [/-][+]4.0 | Remove JS/CSS Sniffs [/+]jrfnl commentedon Jul 14, 2025
I've prepared a branch which removes the JS specific sniffs and removes the JS/CSS specific code from mixed sniffs: https://github.com/Automattic/VIP-Coding-Standards/tree/WAIT-4.0/DROP-SUPPORT-FOR-PHPCS-lt-4/feature/remove-css-js-sniff-code
This branch is intended for VIPCS 4.0 and presumes that support for PHPCS < 4.0 will be/has been dropped in VIPCS 4.0.
Once work on VIPCS 4.0 commences, rebase the branch and this ticket should be good to go.