Remove scanning of JS files
What problem would the enhancement address for VIP?
PHP_CodeSniffer is removing support for scanning JS & CSS files
Describe the solution you'd like
- [ ] VIPCS should no longer include JS/CSS when scanning.
- [ ] All JS/CSS-related rules should be removed
- [ ] VIP docs might need to be updated with other recommendations for linting JS code
Additional context
This is the message I am seeing at the moment when running VIPCS @ 3.0.1:
DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0. The WordPressVIPMinimum.JS.Window sniff is listening for JS. DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0. The WordPressVIPMinimum.JS.DangerouslySetInnerHTML sniff is listening for JS. DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0. The WordPressVIPMinimum.JS.InnerHTML sniff is listening for JS. DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0. The WordPressVIPMinimum.JS.StrippingTags sniff is listening for JS. DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0. The WordPressVIPMinimum.JS.StringConcat sniff is listening for JS. DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0. The WordPressVIPMinimum.JS.HTMLExecutingFunctions sniff is listening for JS.
Thanks @philipjohn.
We have https://github.com/Automattic/VIP-Coding-Standards/issues/552 which looks at all of the PHPCS 4 compatibility items, not just the JS/CSS-related items.
The deprecation notices can be silenced by using the -q (=quiet) CLI flag.
@philipjohn In addition to what @GaryJones said, if you don't want to use the -q flag, excluding those particular sniffs from within your own ruleset, should also get rid of these notifications.
@GaryJones As removing these sniffs will require a new major - how about we start preparing for that by formally deprecating the sniffs ?
We could initially soft-deprecate (changelog notification only). Or we could go straight to a hard deprecation by implementing the DeprecatedSniff interface.
Also, when we do this, we could choose to exclude the sniffs from the ruleset(s) already, even though the removal of the actual sniff files themselves would have to wait for the VIPCS 4.0 release.
Let me know what you think.
I'm fine with going for hard deprecation and removing them from the rulesets. We'll need a VIP announcement post to highlight that reports from JS/CSS-based sniffs will no longer show up.
Somewhat related to this convo. What's the alternative workflow today to check text domains in js/ts files (e.g: blocks/slotfills, etc)?
@jrfnl mentioned here to use eslint. But I wonder if VIP or WP core is recommending something else.
I can't find the "right, new, way" to do this after this change. 🤔
I guess https://www.npmjs.com/package/@wordpress/eslint-plugin is the way.