<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jose Mendoza</title>
    <description>The latest articles on DEV Community by Jose Mendoza (@josebmendozam).</description>
    <link>https://dev.to/josebmendozam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F362733%2F57c6993e-b78a-497f-a3d7-3145077edcf1.jpg</url>
      <title>DEV Community: Jose Mendoza</title>
      <link>https://dev.to/josebmendozam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/josebmendozam"/>
    <language>en</language>
    <item>
      <title>🤖 Automate sorting declarations in just 4 steps</title>
      <dc:creator>Jose Mendoza</dc:creator>
      <pubDate>Fri, 11 Sep 2020 01:17:19 +0000</pubDate>
      <link>https://dev.to/josebmendozam/automate-sorting-declarations-in-just-4-steps-49p4</link>
      <guid>https://dev.to/josebmendozam/automate-sorting-declarations-in-just-4-steps-49p4</guid>
      <description>&lt;p&gt;First off, it should work with &lt;a href="https://github.com/hudochenkov/postcss-sorting/blob/master/README.md"&gt;CSS, PostCSS, Less and SCSS&lt;/a&gt; (but I just tested CSS) and it is also available on &lt;a href="https://github.com/hudochenkov/sublime-postcss-sorting"&gt;Sublime Text&lt;/a&gt;, &lt;a href="https://github.com/lysyi3m/atom-postcss-sorting"&gt;Atom&lt;/a&gt; and &lt;a href="https://github.com/P233/postcss-sorting.el"&gt;Emacs&lt;/a&gt; (but this post only covers &lt;a href="https://github.com/mrmlnc/vscode-postcss-sorting"&gt;VsCode&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Let's start! I'm working on my projects at &lt;a href="https://www.freecodecamp.org/learn/"&gt;freeCodeCamp Responsive Web Design's Certification&lt;/a&gt; and started to ask in my head: is writing random stuff on my CSS files the only way to do it? I mean, shouldn't it be ordered in some way? Aren't there ways to order CSS properties out there?.&lt;/p&gt;

&lt;p&gt;After some googling found &lt;a href="https://medium.com/@jerrylowm/alphabetize-your-css-properties-for-crying-out-loud-780eb1852153"&gt;an article covering the topic&lt;/a&gt; where there was a &lt;a href="https://medium.com/@danielsamuels/its-really-not-701515978ab6"&gt;particular response&lt;/a&gt; that caught my attention and made me think even further about it. I kept searching and found &lt;a href="https://dev.to/thekashey/happy-potter-and-the-order-of-css-5ec"&gt;a great post in this community&lt;/a&gt; and yeah, after all, there wasn't one but many (&lt;strong&gt;random, alphabetically, in groups&lt;/strong&gt; and probably more I'm not even aware of yet).&lt;/p&gt;

&lt;p&gt;So I found myself wanting to give a try to &lt;a href="http://smacss.com/"&gt;SMACSS&lt;/a&gt; and thinking: what about automating the process? Sorting each file manually probably isn't the best idea (I couldn't even imagine following this approach in a large codebase), there must be an efficient way to handle this! Again, after some more googling found a great VSCode extension called &lt;strong&gt;&lt;a href="https://github.com/mrmlnc/vscode-postcss-sorting"&gt;PostCSS Sorting&lt;/a&gt; that do the job&lt;/strong&gt; and also &lt;a href="https://mollykannn.github.io/2019/03/18/vscode-css-sorting%20copy/"&gt;an awesome article explaining an implementation&lt;/a&gt; with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What I did:&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Installed &lt;a href="https://marketplace.visualstudio.com/items?itemName=mrmlnc.vscode-postcss-sorting"&gt;PostCSS Sorting extension&lt;/a&gt; on VsCode by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pressing Ctrl + P&lt;/li&gt;
&lt;li&gt;Pasting this: &lt;code&gt;ext install mrmlnc.vscode-postcss-sorting&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Pressing Enter key&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Edited settings.json (there is a &lt;a href="https://supunkavinda.blog/vscode-editing-settings-json"&gt;good guide with many methods&lt;/a&gt;. I used the first, so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;went to File -&amp;gt; Preferences -&amp;gt; Settings (you could just press Ctrl+Comma as well) -&amp;gt; Extensions -&amp;gt; PostCSS Sorting Configuration -&amp;gt; "Edit in settings.json"&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Replaced the default &lt;code&gt;"postcssSorting.config": {}&lt;/code&gt; with &lt;a href="https://pastebin.com/1Bh68kZR"&gt;this code&lt;/a&gt; because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It corresponds to the &lt;a href="https://github.com/Siilwyn/css-declaration-sorter/tree/master/orders"&gt;most recent smacss.json&lt;/a&gt; version at the time of writing&lt;/li&gt;
&lt;li&gt;&lt;em&gt;(don't worry if you prefer to use others!)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 4:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Saved changes and tested:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Went to a CSS file &lt;/li&gt;
&lt;li&gt;Pressed F1&lt;/li&gt;
&lt;li&gt;Searched for "PostCSS Sorting: Run" &lt;/li&gt;
&lt;li&gt;Pressed Enter key&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Step 5 (extra):&lt;/em&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Enjoy 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm combining it with &lt;a href="https://prettier.io/"&gt;Prettier&lt;/a&gt; (for formatting) but I'm curious about your preferred way to do all that stuff! &lt;strong&gt;Feel free to share which it is and why in the comments&lt;/strong&gt;. Thanks for reading.&lt;/p&gt;

</description>
      <category>css</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
