Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Blacklist/Whitelist for fix on save for certain paths #6

Open
garygreen opened this issue Mar 23, 2019 · 4 comments
Open

Blacklist/Whitelist for fix on save for certain paths #6

garygreen opened this issue Mar 23, 2019 · 4 comments

Comments

@garygreen
Copy link

garygreen commented Mar 23, 2019

Occasionally I edit files in vendor which then triggers the auto save fix which can be frustrating, as it's usually unintentional. You can temporarily disable the fix on save, but this is fiddly as you have to go into the config every time.

It would be great to be able to configure a whitelist/blacklist of paths to enable triggering fix on save:

{
  "vscode-php-cs-fixer.fixOnSavePaths": {
      "vendor/allow-fix-on-save": true,
      "vendor": false
   }
}

Matches are done in order, first match takes priority. Paths are matched from the workspace root path, so for example when a workspace is opened for C:\Sites\my-project and following the above examples, it would match for:

  • C:\Sites\my-project\vendor\allow-fix-on-save
  • C:\Sites\my-project\vendor
    ...etc

Is this an idea you would be open to adding?

@quantizor
Copy link

It looks like the extension doesn't generally respect if you set this sort of thing in the config itself either.

For example, our config has:

$finder = \PhpCsFixer\Finder::create()
    ->exclude('vendor')
    ->in(__DIR__.'/[redacted]');

But cs fixer runs on every file regardless of this config.

@fterrag
Copy link
Owner

fterrag commented Aug 23, 2020

@probablyup what do you have vscode-php-cs-fixer.config set to?

@moussaclarke
Copy link
Contributor

Maybe a setting to set --path-mode to intersection? See https://cs.symfony.com/doc/usage.html - as far as I understand it that should take into account the config finder rather than over-riding it.

@moussaclarke
Copy link
Contributor

PR for this here:
#18

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

No branches or pull requests

4 participants