fterrag / vscode-php-cs-fixer

Support for php-cs-fixer in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=fterrag.vscode-php-cs-fixer
MIT License
12 stars 7 forks source link

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

Open garygreen opened 5 years ago

garygreen commented 5 years ago

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:

Is this an idea you would be open to adding?

quantizor commented 4 years ago

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 commented 4 years ago

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

moussaclarke commented 3 years ago

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 commented 2 years ago

PR for this here: https://github.com/fterrag/vscode-php-cs-fixer/pull/18