Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom extensions? #159

Open
josias-r opened this issue Oct 25, 2019 · 8 comments · May be fixed by #172
Open

Custom extensions? #159

josias-r opened this issue Oct 25, 2019 · 8 comments · May be fixed by #172

Comments

@josias-r
Copy link

Phpcs supports the cli argument --extensions=foo,bar .
Is there a way I can pass the --extensions=phtml,php to work with phtml files?
Currently, I get no linting results for phtml files inside the editor :/

@bwaindwain
Copy link

bwaindwain commented Jan 29, 2020

By default, PHP_CodeSniffer will check any file it finds with a .inc, .php, .js or .css extension

https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying-valid-file-extensions

For our Dupal work, I was able to hack this by adding lintArgs.push('--extensions=inc,install,module,php,profile,theme'); after line 111 of server/src/linter.js. Not a brilliant solution but it's a start.

An idea may be to tie into files.associations which is what intelephense does.

It would be nice to get it to do CSS and JS files too >> #17

@dawidnawrot
Copy link

@bwaindwain Is there any update around this issue? phpcs used in VSC still does not track custom extensions

@bwaindwain
Copy link

no update

@theteknocat theteknocat linked a pull request Apr 6, 2020 that will close this issue
@markfullmer
Copy link

Here's a quick reference for implementing the Drupal-specific fix in #159 (comment)

File is most likely located in ~/.vscode/extensions/ikappas.phpcs-1.0.5/server/src/linter.js

diff --git a/linter.js b/linter.js
index c8782e9..b6da7b7 100644
--- a/linter.js
+++ b/linter.js
@@ -109,6 +109,7 @@ class PhpcsLinter {
           return [];
         }
       }
+      lintArgs.push('--extensions=inc,install,module,php,profile,theme');
       lintArgs.push(`--error-severity=${settings.errorSeverity}`);
       let warningSeverity = settings.warningSeverity;
       if (settings.showWarnings === false) {

@dawidnawrot
Copy link

Thank you @markfullmer
Works like charm.

@danny-englander
Copy link

I tested #159 (comment) and it works great. Thanks @markfullmer.

@mchelen-gov
Copy link

Found another workaround to this, create a phpcs.xml.dist in project root and set the file extensions there:

<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,md,yml"/>

See https://github.com/pfrenssen/coder#store-settings-in-a-phpcsxmldist-file for sample file

@jaybabak
Copy link

I have created a PR for this change in #150, #207 - any chance it could be merged in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants