<?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: Tiago Vaccari</title>
    <description>The latest articles on DEV Community by Tiago Vaccari (@tvaccari34).</description>
    <link>https://dev.to/tvaccari34</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%2F196782%2F1a5742f6-0ad7-4d26-a65e-47b0e4976f2b.jpg</url>
      <title>DEV Community: Tiago Vaccari</title>
      <link>https://dev.to/tvaccari34</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tvaccari34"/>
    <language>en</language>
    <item>
      <title>Project Patterns and Tools - Prettier</title>
      <dc:creator>Tiago Vaccari</dc:creator>
      <pubDate>Thu, 03 Sep 2020 19:26:17 +0000</pubDate>
      <link>https://dev.to/tvaccari34/project-patterns-and-tools-prettier-498</link>
      <guid>https://dev.to/tvaccari34/project-patterns-and-tools-prettier-498</guid>
      <description>&lt;p&gt;The last tool we are going to configure is Prettier.&lt;/p&gt;

&lt;p&gt;Prettier is another tool to make our code format with the same standard for the whole team. It consist in makes your code as the same as the rest of your code. By using Prettier, your team will, or maybe not, skips all disagreements about spacing, semicolons, commas, etc, because Prettier will re-formatt the code as your configuration.&lt;/p&gt;

&lt;p&gt;Before we begin the configuration, be aware you will need to remove  Prettier - Code Formatter from your VSCode because it can cause some incompatibilities with our configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting the configuration
&lt;/h2&gt;

&lt;p&gt;Remember that, all these configuration will be the same for NodeJS, ReactJS and React Native.&lt;/p&gt;

&lt;p&gt;We will start with the Prettier package installation by run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add prettier eslint-config-prettier eslint-plugin-prettier &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three dependencies will be added to format the code and integrate Prettier with ESLint.&lt;/p&gt;

&lt;p&gt;After that instalation, we have to change the files .eslintrc.json adding the lines below in to "extends":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"prettier/@typescript-eslint"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="s2"&gt;"plugin:prettier/recommended"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and we need to add "prettier" configuration in to "plugins" option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"@typescript-eslint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"prettier"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For "rules" I'm gonna add one line to enable ESLint display all errors where Prettier can not lead the corrections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"import/extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"ignorePackages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"never"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"prettier/prettier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, the final file should be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"es2020"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"airbnb-base"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"plugin:@typescript-eslint/recommended"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"prettier/@typescript-eslint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"plugin:prettier/recommended"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"parser"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@typescript-eslint/parser"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"parserOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ecmaVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"sourceType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"@typescript-eslint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"prettier"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"import/extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"ignorePackages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"never"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"prettier/prettier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"settings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"import/resolver"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"typescript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After all those configurations, chances are you got some conflicts between ESLint and Prettier.&lt;/p&gt;

&lt;p&gt;To sort this conflicts out we are going to create a file at the project's root named "prettier.config.js" and add the lines below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;module.export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;singleQuote:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;trailingComma:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'all'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;arrowParens:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'avoid'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Don't bother yourself by manually formatting your code. We know it takes time that can be better spent writing more code and also and can be different from your teammates. &lt;/p&gt;

&lt;p&gt;Take advantage of the amazing modern tools out there and set up EditorConfig, ESLint and Prettier for your projects!&lt;/p&gt;

&lt;h2&gt;
  
  
  That's it, folks!
&lt;/h2&gt;

&lt;p&gt;Thanks for reading and I hope it's been useful for you. Please do comment your questions and suggestions.&lt;br&gt;
Say Hi 👋! on &lt;a href="https://twitter.com/vaccari_tiago"&gt;Twitter&lt;/a&gt; - &lt;a href="https://www.instagram.com/tiagovaccari/"&gt;Instagram&lt;/a&gt; - &lt;a href="https://www.facebook.com/tiago.vaccari.3"&gt;Facebook&lt;/a&gt; - &lt;a href="https://www.linkedin.com/in/tiago-vaccari-0b159a54/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>prettier</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Project Patterns and Tools - ESLint</title>
      <dc:creator>Tiago Vaccari</dc:creator>
      <pubDate>Fri, 28 Aug 2020 15:45:09 +0000</pubDate>
      <link>https://dev.to/tvaccari34/project-patterns-and-tools-eslint-1hjd</link>
      <guid>https://dev.to/tvaccari34/project-patterns-and-tools-eslint-1hjd</guid>
      <description>&lt;p&gt;The next tool that help us to go further and keep our code well formatted are ESLint and today we are going to configure this tool to work with TypeScript.&lt;/p&gt;

&lt;p&gt;Maybe, ESLint is the most important tool of those three tools (eslint, editorconfig and prettier) to keep our code "under control".&lt;/p&gt;

&lt;p&gt;For example, semicolon is not required at the end of the line for JavaScript, also we can use quotation marks or double quotes, it depends on your taste.&lt;/p&gt;

&lt;p&gt;With ESLint we can define what kind of format our team need to follow, helping to keep our code readable and avoiding conflicts when we are trying to merge those code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/13HgwGsXF0aiGY/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/13HgwGsXF0aiGY/giphy.gif" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;First things first, so before we start, we need to install ESLint extension for VSCode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint"&gt;eslint&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have to set up the option codeActionOnSave on VSCode if you want to format your files when you save the code, you will need to add the code below in the configuration.&lt;/p&gt;

&lt;p&gt;Open VSCode's settings.json and add the configuration below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"editor.codeActionsOnSave"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"source.fixAll.eslint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we can install ESLint as a development dependency for our NodeJS project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add eslint &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the installation, we have to initialize eslint to add the configuration for our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn eslint &lt;span class="nt"&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we need to select the set up for our project, so I'm gonna select the following configuration as a example (you can select the options you want for your own project):&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to configure ESLint
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;How would you like to use ESLint?
&amp;gt; To check syntax, find problems and enforce code style&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;What type of modules does your project use?
&amp;gt; JavaScript modules (import/export)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Which framework does your project use?
&amp;gt; None of these (because we are configuring the backend project)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Does your project use TypeScript?
&amp;gt; Yes&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Where does your code run?
(Use the space bar to unselect Browser and select Node)
&amp;gt; Node&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;How would you like to define a style for your project?
&amp;gt; Use a popular style guide&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Which style guide do you want to follow?
&amp;gt; Airbnb&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;What format do you want your config file to be in?
&amp;gt; JSON&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Would you like to install them now with npm?
&amp;gt; No (In our case, because I'm using yarn, I will need to answer No and then, install the dependencies manually).&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, we need to run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add @typescript-eslint/eslint-plugin@latest eslint-config-airbnb-base@latest eslint@^5.16.0 &lt;span class="o"&gt;||&lt;/span&gt; ^6.8.0 &lt;span class="o"&gt;||&lt;/span&gt; ^7.2.0 eslint-plugin-import@^2.21.2 @typescript-eslint/parser@latest &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to create the file .eslintignore and type the configuration below to ignore linting for some files that is not needed.&lt;/p&gt;

&lt;p&gt;/*.js&lt;br&gt;
node_modules&lt;br&gt;
dist&lt;/p&gt;

&lt;p&gt;Finally, we are going to configure the file .eslintrc.json created when we configured the ESLint initialization.&lt;/p&gt;

&lt;p&gt;We need to add the line below inside of "extends" option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"plugin:@typescript-eslint/recommended"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, now we have to install one dependency to enable the Node's ability to understand "import" TypeScript.&lt;/p&gt;

&lt;p&gt;For that, type the command below and hit enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add eslint-import-resolver-typescript &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then, add the configuration below for .eslintrc.json file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"settings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"import/resolver"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"typescript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside "rules", add the configuration below to enable "import" from files type "tsx" without the extensions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"import/extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"ignorePackages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"never"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our file should be like the file below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"es2020"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"airbnb-base"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"plugin:@typescript-eslint/recommended"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"parser"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@typescript-eslint/parser"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"parserOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ecmaVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"sourceType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"@typescript-eslint"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"import/extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"ignorePackages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"never"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"settings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"import/resolver"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"typescript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;It's done!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To finish and apply all changes, we need to close and reopen VSCode at the root folder for the project, so we can verify if all changes is working as expected.&lt;/p&gt;

&lt;p&gt;If you want, you can try to write a wrong code and ESLint should spot the error.&lt;/p&gt;

&lt;p&gt;In the next post, I'm gonna configure Prettier for VSCode with ESLint.&lt;/p&gt;

&lt;p&gt;That's it, folks!&lt;/p&gt;

&lt;p&gt;Thanks for reading and I hope it's been useful for you. Please do comment your questions and suggestions.&lt;/p&gt;

</description>
      <category>eslint</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Project Patterns and Tools - Configuring EditorConfig</title>
      <dc:creator>Tiago Vaccari</dc:creator>
      <pubDate>Sat, 15 Aug 2020 20:40:39 +0000</pubDate>
      <link>https://dev.to/tvaccari34/project-patterns-and-tools-configuring-editorconfig-31kl</link>
      <guid>https://dev.to/tvaccari34/project-patterns-and-tools-configuring-editorconfig-31kl</guid>
      <description>&lt;p&gt;Following the previous post, today we are going to configure EditorConfig on VSCode.&lt;/p&gt;

&lt;p&gt;That tool can help us to change the code format settings for the IDE configuration.&lt;/p&gt;

&lt;p&gt;But how does it work? EditorConfig is a file format and collection of text editor plugins for maintaining consistent coding styles between different editors and IDEs.&lt;/p&gt;

&lt;p&gt;Also, this plugin attemps to override user or workspace settings with settings found in .editorconfig files. No additional or vscode-specific files are required.&lt;/p&gt;

&lt;p&gt;So, let's start to set it up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/3o84sJXOIrnjvlwnF6/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3o84sJXOIrnjvlwnF6/giphy.gif" alt="alt text" title="Time to learn"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first thing we need to do is install the EditorConfig for VS Code extension.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X_H7lfsa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ne56xkw67vdiagv0q0eu.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X_H7lfsa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ne56xkw67vdiagv0q0eu.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the installation has finished, we can right click on the file explorer and select the "Generate .editorconfig" option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NmbljhWF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/21jvvgzlw1avr61fb44h.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NmbljhWF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/21jvvgzlw1avr61fb44h.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will create a file named ".editorconfig" with the following content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Editoconfig Content&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;root = true&lt;/p&gt;

&lt;p&gt;[*]&lt;br&gt;
indent_style = space&lt;br&gt;
indent_size = 2&lt;br&gt;
charset = utf-8&lt;br&gt;
trim_trailing_whitespace = false&lt;br&gt;
insert_final_newline = false&lt;/p&gt;

&lt;p&gt;That file contains the configuration we want to use to keep our code with the same format for our team.&lt;/p&gt;

&lt;p&gt;We can find indent style, indent size, charset, insert final newline and a lot of different options.&lt;/p&gt;

&lt;p&gt;Now, we are going to change the option &lt;em&gt;trim_trailing_whitespace = false&lt;/em&gt; to &lt;em&gt;trim_trailing_whitespace = true&lt;/em&gt; and add a new option like this &lt;em&gt;end_of_line = lf&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;trim_trailing_whitespace = true&lt;/em&gt; will remove any whitespace characters preceding newline characters.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;end_of_line = lf&lt;/em&gt; will control how line breaks are represented.&lt;/p&gt;

&lt;p&gt;As a result of our change the file should be like this now:&lt;/p&gt;

&lt;p&gt;root = true&lt;/p&gt;

&lt;p&gt;[*]&lt;br&gt;
indent_style = space&lt;br&gt;
indent_size = 2&lt;br&gt;
charset = utf-8&lt;br&gt;
trim_trailing_whitespace = true&lt;br&gt;
insert_final_newline = false&lt;br&gt;
end_of_line = lf&lt;/p&gt;

&lt;p&gt;Finally, to make sure our code uses the new format properly, we need to open the project's files and save them again.&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

&lt;p&gt;From now, our code will be formatted with this rules and we can use the same configuration for our team, doesn't matter if they are using VS Code or other IDEs. The only thing we need to do is configure EditorConfig for them using the same configuration file.&lt;/p&gt;

&lt;p&gt;If you would like to go deep in EditorConfig check it out at &lt;a href="https://editorconfig.org/"&gt;editorconfig.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the next post, I'm going to show how to configure ESLint for VSCode to make our code and life a little bit better.&lt;/p&gt;

&lt;p&gt;That's it, folks!&lt;/p&gt;

&lt;p&gt;Thanks for reading and I hope it's been useful for you. Please do comment your questions and suggestions.&lt;/p&gt;

</description>
      <category>editorconfig</category>
    </item>
    <item>
      <title>Project Patterns and Tools</title>
      <dc:creator>Tiago Vaccari</dc:creator>
      <pubDate>Sun, 02 Aug 2020 21:01:40 +0000</pubDate>
      <link>https://dev.to/tvaccari34/project-patterns-and-tools-28c0</link>
      <guid>https://dev.to/tvaccari34/project-patterns-and-tools-28c0</guid>
      <description>&lt;p&gt;Did you find yourself stuck in a project simply because the patterns used between your colleagues is different? Probably yes!&lt;/p&gt;

&lt;p&gt;Actually, to keep the code patterns and conventions for all companies and development teams is one of the most challenge thing they are facing.&lt;br&gt;
Why does it happens? In simple term, because everyone working on this industry learned to program differently, they had different background, they have their own preferences and habits.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/8gJ28HfjAkc9y/source.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/8gJ28HfjAkc9y/source.gif" alt="alt text" title="rules"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because that, subjects as clean code, SOLID principles, KISS principles and so on are trends, but is there a way to try to automate or at least keep the code under some patterns defined previously?&lt;/p&gt;

&lt;p&gt;In that post I will explain about some tools we can use to help us to keep our code under control and make our life easier when our projects is becoming bigger and more developers is join the project.&lt;/p&gt;

&lt;p&gt;For that purpose we can use three tools to keep our code with the same standard. Those tools are EditorConfig, ESLint and Prettier.&lt;/p&gt;

&lt;h1&gt;
  
  
  EditorConfig
&lt;/h1&gt;

&lt;p&gt;EditorConfig is a tool to help development teams work with the same pattern, doesn't matter if they are working with different IDE's as code editor.&lt;/p&gt;

&lt;p&gt;Can you imagine if a team is working with different IDE's as VSCode, Atom, Sublime or other one? Probably they are working with different text configuration as well, so in the end of the day, we will get every sort of inconsistency in our code when we are trying to merge our code and also, when we are trying to build it.&lt;/p&gt;

&lt;p&gt;EditorConfig can help us by given a set of configurations as the type of indentation, which charset we need to use, the end of line and so on.&lt;/p&gt;

&lt;p&gt;If would you like to go deep in EditorConfig check it out at &lt;a href="https://editorconfig.org/"&gt;editorconfig.org&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  ESLint
&lt;/h1&gt;

&lt;p&gt;I can say ESlint maybe is one of the most important tool to automate code convention. We can use it for projects using NodeJS, ReactJS, React Native and more.&lt;/p&gt;

&lt;p&gt;For example, ";" is optional for Javascript at the end of line and that is not a problem to run the code. But when we are creating an object, we can use "," at the last item of the object but it is optional.&lt;/p&gt;

&lt;p&gt;With ESLint we can keep just one pattern for our team.&lt;/p&gt;

&lt;p&gt;You can find out more at &lt;a href="https://eslint.org/"&gt;eslint.org&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Prettier
&lt;/h1&gt;

&lt;p&gt;Finally, we have Prettier! That tool is used to customize our code format. It means Prettier will remove all original styling code and ensures that all outputted code conforms to a consistent style.&lt;/p&gt;

&lt;p&gt;Prettier enforces a consistent code style across our entire codebase by parsing it away and re-printing the parser with its own rules that take the maximum line length into account, wrapping code when necessary.&lt;/p&gt;

&lt;p&gt;If you want to get more information about it, check it out at &lt;a href="https://prettier.io/"&gt;prettier.io&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the next post, I will show how to configure EditorConfig for VSCode and start to keep our code under control.&lt;/p&gt;

&lt;p&gt;That's it, folks!&lt;/p&gt;

&lt;p&gt;Thanks for reading and I hope it's been useful for you. Please do comment your questions and suggestions.&lt;/p&gt;

</description>
      <category>editorconfig</category>
      <category>eslint</category>
      <category>prettier</category>
    </item>
  </channel>
</rss>
