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

When I add exclude pattern *.js in xml then it will not working every php file that has json name #2955

Closed
pokemonhan opened this issue May 12, 2020 · 4 comments

Comments

@pokemonhan
Copy link

pokemonhan commented May 12, 2020

phpcs v 3.5.5
<exclude-pattern>*/*.js</exclude-pattern>
after adding this and then below files will not able to check errors and
show nothing errrors.
StaticJsonHandler.php
StaticJsonServiceProvider.php
static_json.php

@jrfnl
Copy link
Contributor

jrfnl commented May 12, 2020

The exclude patterns are a special kind of regex in which * gets replaced by .*.
Other regex special characters - like . - will retain their normal meaning.

This is documented behaviour, see: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders

Try using this instead:
<exclude-pattern>*/*\.js$</exclude-pattern>

@pokemonhan
Copy link
Author

Thank you, its work.

@rmpel
Copy link

rmpel commented Jun 4, 2024

It works, but, why does *.js which gets expanded to .*.js exclude (for example) index.php, in which there is no j or s to be found?

@jrfnl
Copy link
Contributor

jrfnl commented Jun 4, 2024

@rmpel See #2955 (comment) - might be something in your file path which triggers the rule. See the more stable example to use in the comment.

On another note: This repo is abandoned and https://github.com/PHPCSStandards/PHP_CodeSniffer is its successor. See: #3932. If you need further assistance with this, I suggest you open a discussion item in the new repo.

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

No branches or pull requests

4 participants