junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

How to change rule stragegy? #172

Closed RossTsachev closed 2 years ago

RossTsachev commented 2 years ago

Hi, I'm using @PhpCsFixer ruleset, but want to override the strategy of rule 'multiline_whitespace_before_semicolons' from 'new_line_for_chained_calls' to 'no_multi_line' : https://cs.symfony.com/doc/rules/semicolon/multiline_whitespace_before_semicolons.html I can add .php-cs-fixer.php file to one of my projects, but want to make it global. Is there any way to do that within the configurations settings?

junstyle commented 2 years ago

like this:

"php-cs-fixer.rules": {     
  "@Symfony": true,     
  "array_syntax": { "syntax": "short" }
}

json formatted value

If the --rules option is used rules from config files are ignored.

RossTsachev commented 2 years ago

Worked like charm

"php-cs-fixer.rules": {     
  "@PhpCsFixer": true,  
  "multiline_whitespace_before_semicolons'": { "strategy": "no_multi_line" }
}

Thank you :)

stollr commented 1 year ago

@junstyle Would be nice if you could document how to adjust specific rules in the php-cs-fixer.rules setting.