Most of the time Prettier would be added to the project’s package.json, but since we want to use it in a PHP project we’ll install it globally through NPM (or Yarn if you want). Most of the time, it will fix the latter, in very PHP specific ways, but will do very little for the former besides a few blank lines and indentation rules. PCS conflates code format (how the code is formatted, how pretty it is) and coding style (how the code is written, how good it is). However, a glance at the list of the things it fixes shines a light on the main reason I still use Prettier in addition to it. What is this? Ruby?Īt madewithlove we currently use (mainly but not only) PHP CS Fixer. So ok, Javascript and a bunch of other front-end languages (CSS, HTML, GraphQL, etc.) have this tool, but this is Serious Enterprise PHP™ we have Serious Enterprise Tools™ to take care of our code style and PSRs and RFCs and all that – we don’t just type code until it’s pretty. Once you go without them though, you will realise how much time they take up. These distractions take up much more of your day than people realise because those are micro interruptions that are scattered and as such feel inconsequential. You stop thinking about indentation, manually adding commas, or placing things for maximum readability and such. You can type code in one disgusting line, press save, and the result is nicely formatted code. The more you trust Prettier, the more you can stop worrying about formatting altogether. This may sound counter-intuitive but it tremendously reduces friction when writing code. You can pass a few basic options to Prettier (indentation, max width, the basics) but other than that it takes your whole code and reformats it from scratch, disregarding any formatting decision you may have previously taken. Prettier, however, is currently one of the most popular code formatters out there, and it has spread to a lot of different languages already for one simple reason: it gives zero fucks about how you think your code should be formatted. There are code formatters for many languages even Javascript has quite a few of them. This interesting but apparently not very useful API kept causing maintenance problems and has been removed in Prettier 2.0.0.Originally from the Javascript ecosystem, Prettier is a code formatter which means it takes your code and makes it – as its name suggests – prettier. Remove the version parameter of prettier.getSupportInfo ( #7620 by Prettier 1.8.0, it was possible to pass a version number to prettier.getSupportInfo to get information on the languages, options, etc.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |