Open jrfnl opened 6 years ago
I think this is the code that I started https://gist.github.com/grappler/db2918097f54775680c0704890d9a394
I'll tag this as next release, so that we have 0.2.0 out before WCEU (and not to block Theme Sniffer new release) 🙂
Oh and just thinking: regarding the filtering out of minified JS/CSS files, instead of using the bootstrap
for this, this can probably be done via a custom Filter
class. (new feature in PHPCS 3)
Technical info:
<arg>
directive..dev.js
vs .js
or the .js
vs .min.js
file name pattern is used..js
files where a .dev.js
file is also found with the same name can be removed from the filelist..min.js
files where a .js
file is also found with the same name can be removed from the filelist.min
and dev
- we need to do some more complicated logic.Refs:
This is good to filter out the obvious minified files. But we'll still have issues with minified files that don't end in .min.js
or .dev.js
.
Definitely something we'd like for the next update :+1:
Well, the filter could also examine the contents of files, but to be fair, PHPCS itself already does this and is a lot better at detecting and excluding minified files since v3.
Once the repo has been de-forked - see #169 -, a bootstrap file can be added which can analyse the
style.css
file in the theme root. This info can then be used by sniffs.Another thing which we may or may not be able to do via the bootstrap file (needs investigation) is remove minified JS files from the list of files to analyse.
I know @grappler has done some initial work on something like this - @grappler is there a branch somewhere with what you did ?
Important: while having this information available can make certain sniffs possible/better, this isn't a silver bullet.
Example: Once this has been implemented, we can add a sniff checking
add_theme_support()
function calls to verify that all supported features are tagged in thestyle.css
file, but we still will not be able to check that all tags used have the correspondingadd_theme_support()
function call as that won't be clear until the last token of the last file has been reached and at that point, we can no longer throw an error for it.