valeryan / vscode-phpsab

Php Sniffer and Beautifier for VS Code
https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpsab
MIT License
58 stars 12 forks source link

Sniffer for other file extensions #109

Closed farhadsakhaei closed 8 months ago

farhadsakhaei commented 9 months ago

Hi, How can I enable sniffer for other file extensions? like CSS and JS files?

Thank you

valeryan commented 9 months ago

Do your CSS and JS files have PHP in them? I don't think phpcs or phpcbf has any concept of scanning non-PHP files.

farhadsakhaei commented 9 months ago

@valeryan Yes, They do Some sniffers perform CSS , JS and other files analysis

valeryan commented 9 months ago

Do you have a document source for what you are talking about? I don't see anything in the documentation for PHPcs doing anything for css or js.

I feel like you may be confused about what this extension does. It's not a general sniffer it's a wrapper for phpcs and phpcbf

farhadsakhaei commented 9 months ago

@valeryan Yes, I am doing this everyday, actually I found another extension that it do that Actually WordPress coding standard do this too for CSS files and JS files too

valeryan commented 9 months ago

I can look into it but ultimately this is a php tool and the concept of using it for css or js is weird to me and I think it would be better to use something specialized in those file types like prettier and eslint.

farhadsakhaei commented 9 months ago

Some projects have their own standards for any file type So they apply such standards, like WordPress

valeryan commented 9 months ago

Yeah, but PHPcs does not lint the files it just passes the standards definitions to another tool such as csslint. https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-path-to-csslint

That will require some development of new configuration, detection and tooling to support. If one of the other maintainers wants to pick up and support this it might get added. Currently I am not looking to do more than maintain this extension with bug or security fixes.

farhadsakhaei commented 9 months ago

@valeryan BTW, Thank you for your development

I currently resolved that with the extension: https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer

phpSniffer.extraFiles: Glob patterns of extra files to match that this extension should run on. Useful for standards that don't just validate PHP files. This extension will always run on PHP files — be sure to have your files.associations setting correctly setup for PHP files.

valeryan commented 8 months ago

I am familiar with wongjin's extension. I went and found where the generic files support was added. here is the commit for reference: https://github.com/wongjn/vscode-php-sniffer/commit/89ddc08d5690b61bd5e0e200901bc059abf87edf. We should be able to adapt the concept into this extension but I can't give you anything close to a timeline.

jonathanbossenger commented 8 months ago

@valeryan it's worth noting that PHPCS has deprecated and will eventually drop support for any JS and CSS sniffs.

Relevant links

Therefore it's probably not worth adding support for something that will not be supported in newer PHPCS versions.

valeryan commented 8 months ago

@jonathanbossenger thanks for researching that for us. Given that the feature is on the way out/gone I am closing this.