<?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: Tanvir Ahammad Chy</title>
    <description>The latest articles on DEV Community by Tanvir Ahammad Chy (@tanvir510).</description>
    <link>https://dev.to/tanvir510</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%2F253923%2F5821117b-fc13-491f-846d-6a0a75a3ae88.jpg</url>
      <title>DEV Community: Tanvir Ahammad Chy</title>
      <link>https://dev.to/tanvir510</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanvir510"/>
    <language>en</language>
    <item>
      <title>Eslint &amp; Prettier configuration in React project</title>
      <dc:creator>Tanvir Ahammad Chy</dc:creator>
      <pubDate>Tue, 02 Aug 2022 11:16:00 +0000</pubDate>
      <link>https://dev.to/tanvir510/eslint-prettier-configuration-in-react-project-c4o</link>
      <guid>https://dev.to/tanvir510/eslint-prettier-configuration-in-react-project-c4o</guid>
      <description>&lt;p&gt;When building web applications, using linting tools help you a crucial role in web development process. I think every developer should know, how to install and configure the linting process in your application. So, today i'll discuss about linting configuration and efficiently making sure that the best code standards are applied to our project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 01:&lt;/strong&gt; Install &lt;code&gt;eslint&lt;/code&gt; package in your project as dev dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add eslint --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 02:&lt;/strong&gt; Eslint need to initialize, &lt;code&gt;.eslintrc.json&lt;/code&gt; file will be created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn run eslint --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 03:&lt;/strong&gt; Eslint rules updated from &lt;code&gt;.eslintrc.json&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"rules": {
  "react/react-in-jsx-scope": "off",
  "no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
  "prettier/prettier": ["error", { "singleQuote": true }],
  "no-console": "warn"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 04:&lt;/strong&gt; Required plugins are needed to be install,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add eslint-config-prettier eslint-plugin-prettier prettier --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 05:&lt;/strong&gt; Update extends array on &lt;code&gt;.eslintrc.json&lt;/code&gt; file,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 06:&lt;/strong&gt; Create new &lt;code&gt;.prettierrc&lt;/code&gt; file, paste following codes,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "semi": true,
  "tabWidth": 2,
  "printWidth": 100,
  "singleQuote": true,
  "jsxSingleQuote": true,
  "trailingComma": "none",
  "jsxBracketSameLine": true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 07:&lt;/strong&gt; Update your &lt;code&gt;package.json&lt;/code&gt; file with following codes,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"lint": "eslint .",
"lint:fix": "eslint --fix",
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the script &lt;code&gt;yarn format&lt;/code&gt; will format the code style of all JavaScript files. Like &lt;code&gt;ESLint&lt;/code&gt;, it has amazing Code Editors extensions that enable the &lt;code&gt;Prettier&lt;/code&gt; to run on files when they are being saved, formating them on the fly without the need to run the script manually!&lt;/p&gt;

&lt;p&gt;Note: For this process i've used &lt;code&gt;yarn&lt;/code&gt; packages, if you're familiar with npm, then you can use &lt;code&gt;npm&lt;/code&gt; packages.&lt;/p&gt;

&lt;p&gt;Time is everything in a fast pace environment so it's important to have a good setup of tools allowing the developers to be more efficient and spend more time developing new features than looking for errors on the code.&lt;/p&gt;

&lt;p&gt;Thank you !&lt;/p&gt;

</description>
      <category>react</category>
      <category>eslint</category>
      <category>prettier</category>
      <category>guideline</category>
    </item>
  </channel>
</rss>
