mansoorkhan96 / php-cs-fixer

PHP CS Fixer extension for VS Code with zero config
https://marketplace.visualstudio.com/items?itemName=mansoorkhan96.php-cs-fixer
MIT License
12 stars 4 forks source link

Config option "rules" raises error: Invalid JSON rules input: "Syntax error". #28

Closed pvettori closed 2 months ago

pvettori commented 2 months ago

php-cs-fixer version 1.0.8 on WSL2 (Ubuntu)

My rules are set as follows:

--rules={"@PSR1":true,"@PSR2":true,"@Symfony":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":{"operators":{"=":"at_least_single_space","=>":"align_single_space_minimal_by_scope"}},"cast_spaces":{"space":"single"},"concat_space":{"spacing":"one"},"operator_linebreak":{"only_booleans":true,"position":"end"},"phpdoc_annotation_without_dot":false,"phpdoc_no_package":false,"yoda_style":false}

I found that the issue is solved by wrapping the json string with single quotes. I changed line 77 of "extension.js" from:

args.push('--rules=' + rules)

to:

args.push(`--rules='${rules}'`)
mansoorkhan96 commented 2 months ago

Thanks. Fixed. Please update to 1.0.9