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

Allow deletion BOM inside plugin #4050

Open
alexander-akait opened this issue Feb 26, 2018 · 0 comments
Open

Allow deletion BOM inside plugin #4050

alexander-akait opened this issue Feb 26, 2018 · 0 comments
Labels
area:api Issues with Prettier's Application Programming Interface area:plugin api type:enhancement A potential new feature to be added, or an improvement to how we print something

Comments

@alexander-akait
Copy link
Member

alexander-akait commented Feb 26, 2018

Sorry issue template not relevant.

For php we have PSR-1, PSR-2 and PSR-12 standards for code.
One of rule about BOM:

Files MUST use only UTF-8 without BOM for PHP code.

Unfortunately we don't have original text of file inside parse method https://github.com/prettier/plugin-php/blob/master/src/parser.js#L4.

Here prettier remove BOM

const hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
and add after reformatting
if (hasUnicodeBOM) {

I do not know how to solve this problem better. Maybe:

  1. Always pass original text to parser.
  2. Add export option here https://github.com/prettier/plugin-php/blob/master/src/index.js#L55 (example - 'stripBOM').
@alexander-akait alexander-akait added type:enhancement A potential new feature to be added, or an improvement to how we print something area:api Issues with Prettier's Application Programming Interface labels Feb 26, 2018
@alexander-akait alexander-akait changed the title Allow deletion of bom inside plugin Allow deletion BOM inside plugin Feb 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:api Issues with Prettier's Application Programming Interface area:plugin api type:enhancement A potential new feature to be added, or an improvement to how we print something
Projects
None yet
Development

No branches or pull requests

2 participants