<?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: Bruno A.</title>
    <description>The latest articles on DEV Community by Bruno A. (@bybruno).</description>
    <link>https://dev.to/bybruno</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%2F192971%2F409bdd5d-d212-4a3e-8ca9-d92fd1f91025.png</url>
      <title>DEV Community: Bruno A.</title>
      <link>https://dev.to/bybruno</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bybruno"/>
    <language>en</language>
    <item>
      <title>Node is dead! All you need to know</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Tue, 19 May 2020 13:07:12 +0000</pubDate>
      <link>https://dev.to/bybruno/node-is-dead-all-you-need-to-know-31nn</link>
      <guid>https://dev.to/bybruno/node-is-dead-all-you-need-to-know-31nn</guid>
      <description>&lt;p&gt;Of course, he is not dead!&lt;/p&gt;

&lt;p&gt;Stop following the hype and focus on technology or language that pays or will pay your salary.&lt;/p&gt;

</description>
      <category>node</category>
      <category>deno</category>
      <category>jokes</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How do you react when receiving feedback?</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Sun, 21 Jul 2019 20:38:47 +0000</pubDate>
      <link>https://dev.to/bybruno/how-are-you-when-you-receive-feedback-2gi8</link>
      <guid>https://dev.to/bybruno/how-are-you-when-you-receive-feedback-2gi8</guid>
      <description>&lt;p&gt;[en-US]&lt;br&gt;
When someone gives you feedback whether positive or negative, how do you react to it?&lt;/p&gt;

&lt;p&gt;Do you understand that this is part of the process of personal and professional growth or depends on who gives the feedback?&lt;/p&gt;

&lt;p&gt;[pt-BR]&lt;br&gt;
Quando alguém lhe dá um feedback positivo ou negativo, como você reage a isso?&lt;/p&gt;

&lt;p&gt;Você entende que isso faz parte do processo de crescimento pessoal e profissional ou depende de quem dá o feedback?&lt;/p&gt;

</description>
      <category>career</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Configurando caminhos absolutos no React para Web sem ejetar [pt-BR]</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Sun, 21 Jul 2019 06:29:52 +0000</pubDate>
      <link>https://dev.to/bybruno/configurando-caminhos-absolutos-no-react-para-web-sem-ejetar-pt-br-3ko0</link>
      <guid>https://dev.to/bybruno/configurando-caminhos-absolutos-no-react-para-web-sem-ejetar-pt-br-3ko0</guid>
      <description>&lt;p&gt;📢 English Version:&lt;br&gt;
&lt;a href="https://dev.to/heybrunoandrade/configuring-absolute-paths-in-react-for-web-without-ejecting-en-us-52h6"&gt;https://dev.to/heybrunoandrade/configuring-absolute-paths-in-react-for-web-without-ejecting-en-us-52h6&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depois de ter feito um artigo mostrando como realizar a configuração de &lt;a href="https://dev.to/heybrunoandrade/configurando-caminhos-absolutos-no-react-native-pt-br-471o"&gt;caminhos absolutos no React Native&lt;/a&gt;, agora venho mostrar como realizar essa configuração no React para Web.&lt;/p&gt;

&lt;p&gt;Enquanto a equipe do React não implementa isso no CRA, vamos configurar com as nossas próprias mãos e sem ejetar. Continue lendo e verá a mágica acontecer.&lt;/p&gt;
&lt;h2&gt;
  
  
  Uma pequena introdução ☕
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Por que não ejetar o projeto?
&lt;/h3&gt;

&lt;p&gt;Bom, o motivo disso é que você estará quebrando as "garantias" do CRA. Mas calma, pego projetos o tempo todo que foram ejetados e eles estão até hoje funcionando perfeitamente em produção, o único problema de ejetar, é que as configurações serão minhas e tenho que dá suporte a elas.&lt;/p&gt;

&lt;p&gt;"Coisas podem quebrar" - &lt;a href="https://twitter.com/dan_abramov/status/1045809734069170176" rel="noopener noreferrer"&gt;Dan Abramov&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mas felizmente, utilizando ferramentas como o &lt;a href="https://github.com/sharegate/craco" rel="noopener noreferrer"&gt;craco&lt;/a&gt;, podemos voltar facilmente para as configurações padrões do CRA caso as coisas deem erradas. E isso é incrível!&lt;/p&gt;

&lt;p&gt;Já que vamos mexer somente no &lt;em&gt;alias&lt;/em&gt;, você não tem muito com o que se preocupar, o craco irá injetar as novas configurações que fizermos no arquivo &lt;em&gt;craco.config.js&lt;/em&gt; dentro das configurações padrões do CRA.&lt;/p&gt;

&lt;p&gt;Caso você não saiba, o intuito de configurar caminhos absolutos em um projeto feito com Reactjs, é para facilitar a importação de arquivos. Para isso podemos utilizar um símbolo para representar um diretório root dos nossos códigos. Veja um exemplo abaixo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
Use isto 😍
import Form from &lt;span class="s1"&gt;'@/components/Form'&lt;/span&gt;

E Evite isto 😤
import Form from &lt;span class="s1"&gt;'../../../../../components/Form'&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dizem que é praticando que se aprende 🏊
&lt;/h2&gt;

&lt;p&gt;☝ Então vamos lá, abra o seu terminal e instale as dependências necessárias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# yarn&lt;/span&gt;
yarn add @craco/craco

&lt;span class="c"&gt;# npm&lt;/span&gt;
npm i @craco/craco
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✌ Após realizar a instalação do &lt;em&gt;craco&lt;/em&gt;, precisaremos renomear algumas linhas de comando do &lt;em&gt;package.json&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Substitua o "react-scripts" por &lt;em&gt;"craco"&lt;/em&gt;.&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;"scripts"&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;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"craco start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"craco build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"craco test"&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;Isso fará com que os scripts do CRA seja executado pelo &lt;em&gt;craco&lt;/em&gt; o qual irá realizar injeções das configurações que estarão no arquivo &lt;em&gt;craco.config.js&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;🛠 Crie o arquivo no diretório raiz do projeto chamado: &lt;em&gt;craco.config.js&lt;/em&gt; e inclua as configurações abaixo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;webpack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;jest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;moduleNameMapper&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;^@(.*)$&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;rootDir&amp;gt;/src$1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Uma pitada de VueJS, por favor! 🍲
&lt;/h2&gt;

&lt;p&gt;Estou utilizando o &lt;em&gt;alias&lt;/em&gt; "@" para imitar o Vuejs. Você pode utilizar o &lt;em&gt;alias&lt;/em&gt; que achar interessante, tais como "~" ou "#", por exemplo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meu VSCode não está entendendo nada 😢
&lt;/h2&gt;

&lt;p&gt;Ao fazer isso iremos nos deparar com o primeiro problema, o autocomplete. Já estamos acostumados a ter autocomplete quando vamos importar os arquivos utilizando caminhos relativos.&lt;/p&gt;

&lt;p&gt;Esse erro acontece porque o VSCode não entende que o "@" é a pasta "src" do nosso projeto. Para ativarmos o autocomplete precisaremos configurar o VSCode para que ele entenda. E para isso precisaremos criar um arquivo chamado &lt;em&gt;jsconfig.json&lt;/em&gt; no diretório raiz do projeto.&lt;/p&gt;

&lt;p&gt;Saiba mais sobre o &lt;a href="https://code.visualstudio.com/docs/languages/jsconfig" rel="noopener noreferrer"&gt;jsconfig.json&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Inclua as seguintes propriedades dentro do arquivo:&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;"compilerOptions"&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;"baseUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"paths"&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;"@/*"&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="s2"&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;"exclude"&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="s2"&gt;"node_modules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"**/node_modules/*"&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;Incrível!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferd77ak66u8ky3oybsid.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferd77ak66u8ky3oybsid.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agora está funcionando perfeitamente, utilize o comando: npm start para executar o seu projeto.&lt;/p&gt;

&lt;h2&gt;
  
  
  Uma ferramenta que gosta de reclamar o tempo todo! 😡
&lt;/h2&gt;

&lt;p&gt;Se você estiver utilizando o &lt;em&gt;eslint&lt;/em&gt;, irá perceber que ele irá reclamar em todas as importações que você realizar utilizando "@".&lt;/p&gt;

&lt;p&gt;Graças a Deus, existe uma forma de acalmar o &lt;em&gt;eslint&lt;/em&gt; utilizando o &lt;a href="https://www.npmjs.com/package/eslint-import-resolver-alias" rel="noopener noreferrer"&gt;eslint-import-alias&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;☝ Primeiramente adicione as bibliotecas abaixo como dependências de desenvolvimento, pelo amor de Deus! 😰&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="c"&gt;# npm&lt;/span&gt;
npm i eslint-plugin-import eslint-import-resolver-alias &lt;span class="nt"&gt;-D&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✌ No seu arquivo .eslintrc.json inclua as seguintes propriedades:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="s2"&gt;"settings"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"import/resolver"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"alias"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"map"&lt;/span&gt;: &lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="s2"&gt;"@"&lt;/span&gt;, &lt;span class="s2"&gt;"./src"&lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Perguntas que parecem idiotas mas não são 😳💬
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Posso utilizar esta técnica em projetos que vão para produção?
&lt;/h4&gt;

&lt;p&gt;Resposta: Sim, você pode utilizar sem problema nenhum!&lt;/p&gt;

&lt;h4&gt;
  
  
  Posso usar no React Native?
&lt;/h4&gt;

&lt;p&gt;Resposta: Não, a configuração no React Native é diferente, mostro como fazer neste artigo:&lt;br&gt;
&lt;a href="https://dev.to/heybrunoandrade/configurando-caminhos-absolutos-no-react-native-pt-br-471o"&gt;Configurando Caminhos absolutos no React Native&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Meus arquivos de testes podem dar erro?
&lt;/h4&gt;

&lt;p&gt;Resposta: Se você tiver seguido corretamente o passo a passo, provavelmente não. Se você mudou o símbolo que vai utilizar como &lt;em&gt;alias&lt;/em&gt;, certifique-se de que tenha colocado isso também na configuração do jest lá no arquivo craco.config.js na propriedade &lt;em&gt;moduleNameMapper&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Por que não está utilizando o Babel plugin root import?
&lt;/h4&gt;

&lt;p&gt;Resposta: Diferentemente do Babel plugin root import, importamos somente uma biblioteca que resolve o problema, além de ser simples de utilizar. Outra coisa que andou me incomodando é que não está dando suporte ao CRA 3.0, por isso a utilização do Craco.&lt;/p&gt;

&lt;h2&gt;
  
  
  Imagine se tudo na vida funcionasse perfeitamente 🦄
&lt;/h2&gt;

&lt;p&gt;Assim como qualquer lib, é possível que se encontre bugs no @craco, caso encontre por favor abra uma &lt;a href="https://github.com/sharegate/craco/issues" rel="noopener noreferrer"&gt;issue no projeto oficial&lt;/a&gt; para que a comunidade melhore a biblioteca e torne-a funcional para todos.&lt;/p&gt;

&lt;p&gt;Mas calma, use-a sem medo para realização desse tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  É hora de dar tchau 😩
&lt;/h2&gt;

&lt;p&gt;Estava gostando tanto de passar esse tempo com você 😢. Caso queira saber o que ando aprontando por ai, me siga no Github &lt;a href="https://github.com/bybruno" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ajude sua rede de amigos desenvolvedores a pararem de sofrer com importações relativas compartilhando este artigo!&lt;/p&gt;

&lt;p&gt;Um grande abraço e até a próxima!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>webpack</category>
    </item>
    <item>
      <title>Configuring absolute paths in React for Web without ejecting [en-US]</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Sun, 21 Jul 2019 06:29:06 +0000</pubDate>
      <link>https://dev.to/bybruno/configuring-absolute-paths-in-react-for-web-without-ejecting-en-us-52h6</link>
      <guid>https://dev.to/bybruno/configuring-absolute-paths-in-react-for-web-without-ejecting-en-us-52h6</guid>
      <description>&lt;p&gt;After you've done an article showing how to set up &lt;a href="https://dev.to/bybruno/configuring-absolute-paths-in-react-native-en-us-2m5k"&gt;absolute paths in React Native&lt;/a&gt;, now I've been showing you how to do this in React for Web.&lt;/p&gt;

&lt;p&gt;While the React team does not implement this in the CRA, we'll set up with our own hands and without ejecting. Keep reading and you will see the magic happening.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small introduction ☕
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why not eject the project?
&lt;/h3&gt;

&lt;p&gt;Well, the reason for that is you're breaking CRA's “guarantees”. But calm, I've seen several projects that have been ejected and they are still working perfectly in production, the only problem is to eject, the settings will be mine and I have to support them.&lt;/p&gt;

&lt;p&gt;"Stuff can break" - &lt;a href="https://twitter.com/dan_abramov/status/1045809734069170176" rel="noopener noreferrer"&gt;Dan Abramov&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But fortunately, using tools like &lt;a href="https://github.com/sharegate/craco" rel="noopener noreferrer"&gt;craco&lt;/a&gt;, we can easily go back to the CRA default settings if things go wrong. And this is incredible!&lt;/p&gt;

&lt;p&gt;Since we will only touch &lt;em&gt;alias&lt;/em&gt;, you do not have much to worry about, the craco will inject the new settings we make in the &lt;em&gt;craco.config.js&lt;/em&gt; file within the CRA default settings.&lt;/p&gt;

&lt;p&gt;In case you do not know, the intention to configure absolute paths in a project made with Reactjs, is to facilitate the import of files. For this we can use a symbol to represent a root directory of our codes. See an example below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;


Use this 😍
import Form from &lt;span class="s1"&gt;'@/components/Form'&lt;/span&gt;

E Avoid this 😤
import Form from &lt;span class="s1"&gt;'../../../../../components/Form'&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  They say that it is practicing that you learne 🏊
&lt;/h2&gt;

&lt;p&gt;☝ So come on, open your terminal and install the necessary dependencies:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="c"&gt;# yarn&lt;/span&gt;
yarn add @craco/craco

&lt;span class="c"&gt;# npm&lt;/span&gt;
npm i @craco/craco


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;✌ After performing the &lt;em&gt;craco&lt;/em&gt; installation, we will need to rename some &lt;em&gt;package.json&lt;/em&gt; command lines.&lt;/p&gt;

&lt;p&gt;Replace the "react-scripts" with &lt;em&gt;"craco"&lt;/em&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&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;"scripts"&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;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"craco start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"craco build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"craco test"&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;This will cause the CRA scripts to be executed by &lt;em&gt;craco&lt;/em&gt; which will make injections of the settings that will be in the &lt;em&gt;craco.config.js&lt;/em&gt; file.&lt;/p&gt;

&lt;p&gt;🛠 Create the file in the project root directory called: &lt;em&gt;craco.config.js&lt;/em&gt; and add the following settings:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;webpack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;jest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;moduleNameMapper&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;^@(.*)$&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;rootDir&amp;gt;/src$1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  A pinch of VueJS, please! 🍲
&lt;/h2&gt;

&lt;p&gt;I'm using &lt;em&gt;alias&lt;/em&gt; "@" copying as Vuejs uses. You can use &lt;em&gt;alias&lt;/em&gt; that you find interesting, such as "~" or "#", for example.&lt;/p&gt;
&lt;h2&gt;
  
  
  My VSCode is not understanding anything 😢
&lt;/h2&gt;

&lt;p&gt;When doing this we will come across the first problem, the autocomplete. We are already accustomed to having autocomplete when we are going to import the files using relative paths.&lt;/p&gt;

&lt;p&gt;This error happens because VSCode does not understand that the "@" is the "src" folder of our project. To enable autocomplete we will need to configure the VSCode so that it understands. And for this we need to create a file called &lt;em&gt;jsconfig.json&lt;/em&gt; in the project root directory.&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://code.visualstudio.com/docs/languages/jsconfig" rel="noopener noreferrer"&gt;jsconfig.json&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Include the following properties within the file:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&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;"compilerOptions"&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;"baseUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"paths"&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;"@/*"&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="s2"&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;"exclude"&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="s2"&gt;"node_modules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"**/node_modules/*"&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;Amazing!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferd77ak66u8ky3oybsid.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferd77ak66u8ky3oybsid.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it works perfectly, use the command: npm start to run your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  A tool that likes to complain all the time! 😡
&lt;/h2&gt;

&lt;p&gt;If you are using &lt;em&gt;eslint&lt;/em&gt;, you will notice that it will complain on all imports that you perform using "@".&lt;/p&gt;

&lt;p&gt;Thank God, there is a way to calm &lt;em&gt;eslint&lt;/em&gt; using &lt;a href="https://www.npmjs.com/package/eslint-import-resolver-alias" rel="noopener noreferrer"&gt;eslint-import-alias&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;☝ First add the libraries below as development dependencies, for God's sake! 😰&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="c"&gt;# yarn&lt;/span&gt;
yarn add eslint-plugin-import eslint-import-resolver-alias &lt;span class="nt"&gt;-D&lt;/span&gt;

&lt;span class="c"&gt;# npm&lt;/span&gt;
npm i eslint-plugin-import eslint-import-resolver-alias &lt;span class="nt"&gt;-D&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;✌ In your .eslintrc.json file include the following properties:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="s2"&gt;"settings"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;&lt;br&gt;
    &lt;span class="s2"&gt;"import/resolver"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;&lt;br&gt;
      &lt;span class="s2"&gt;"alias"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;&lt;br&gt;
        &lt;span class="s2"&gt;"map"&lt;/span&gt;: &lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="s2"&gt;"@"&lt;/span&gt;, &lt;span class="s2"&gt;"./src"&lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;br&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;&lt;br&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;&lt;br&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Questions that look stupid but are not 😳💬&lt;br&gt;
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Can I use this technique in projects that go to production?
&lt;/h4&gt;

&lt;p&gt;Answer: Yes, you can use it without any problem!&lt;/p&gt;

&lt;h4&gt;
  
  
  Can I use it in React Native?
&lt;/h4&gt;

&lt;p&gt;Answer: No, the setting in React Native is different, I show you how to do this article:&lt;br&gt;
&lt;a href="https://dev.to/bybruno/configuring-absolute-paths-in-react-native-en-us-2m5k"&gt;Configuring Absolute Paths in React Native&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Can my test files fail?
&lt;/h4&gt;

&lt;p&gt;Answer: If you have followed step by step correctly, it probably will not give you an error. If you have changed the symbol that you are going to use as &lt;em&gt;alias&lt;/em&gt;, make sure you have also placed this in the jest configuration there in the craco.config.js file in the &lt;em&gt;moduleNameMapper&lt;/em&gt; property.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why are not you using the Babel plugin root import?
&lt;/h4&gt;

&lt;p&gt;Answer: Unlike the Babel plugin root import, we only import a library that solves the problem, as well as being simple to use. Another thing that has been bothering me is that it is not supporting CRA 3.0, so the use of Craco.&lt;/p&gt;

&lt;h2&gt;
  
  
  Imagine if everything in life worked perfectly 🦄
&lt;/h2&gt;

&lt;p&gt;Like any lib, you may find bugs in @craco, if found please open a &lt;a href="https://github.com/sharegate/craco/issues" rel="noopener noreferrer"&gt;issue in the official project&lt;/a&gt; for the community to improve the library and make it functional for everyone.&lt;/p&gt;

&lt;p&gt;But cool, use it fearlessly for this tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  It's time to say goodbye 😩
&lt;/h2&gt;

&lt;p&gt;I'm really enjoying spending this time with you. If you want to know what I'm up to, follow me on Github &lt;a href="https://github.com/bybruno" rel="noopener noreferrer"&gt;bybruno&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Help your developer friends to stop suffering with relative imports by sharing this article!&lt;/p&gt;

&lt;p&gt;A big hug and until next time!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>webpack</category>
    </item>
    <item>
      <title>Configuring Absolute Paths in React Native [en-US]</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Fri, 19 Jul 2019 10:26:39 +0000</pubDate>
      <link>https://dev.to/bybruno/configuring-absolute-paths-in-react-native-en-us-2m5k</link>
      <guid>https://dev.to/bybruno/configuring-absolute-paths-in-react-native-en-us-2m5k</guid>
      <description>&lt;p&gt;One of the things I miss about React / React Native is the absolute path. It is very common to use relative paths to import files.&lt;/p&gt;

&lt;p&gt;The problem is when the project grows and the folders are deeply nested, I believe you may have already seen or already done so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;../../../.../../../../Utils/Breadcrumbs.js

../../../../../Components/Form/TextField.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now imagine that the Utils folder has changed directory. 😢&lt;/p&gt;

&lt;p&gt;To resolve this issue, use a library called &lt;em&gt;Babel Plugin Root Import&lt;/em&gt;. With a list that can be used to encode the root of our application, which is a "src" folder. 😍&lt;/p&gt;

&lt;h2&gt;
  
  
  It is practicing that you learn
&lt;/h2&gt;

&lt;p&gt;☝ Add the library to your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;yarn add babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;span class="go"&gt;
    ou

&lt;/span&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✌ After installation, set up the &lt;em&gt;&lt;em&gt;babel.config.js&lt;/em&gt;&lt;/em&gt; file that is located in the root directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;presets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;module:metro-react-native-babel-preset&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;babel-plugin-root-import&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;rootPathPrefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;rootPathSuffix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;production&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;babel-plugin-root-import&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;rootPathPrefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;rootPathSuffix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With everything set up, it is now possible to import your files using "@" as a prefix. Here's an example below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@/Components/Form&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@/Pages/Auth/SignIn&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A pinch of &lt;em&gt;VueJS&lt;/em&gt; please 🍲
&lt;/h2&gt;

&lt;p&gt;I am using the "@" copying the &lt;em&gt;Vuejs&lt;/em&gt;. Use the prefix that you find interesting. It can be the '~' or '#' for example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Excuse me, could you show me the Way? 🚶
&lt;/h2&gt;

&lt;p&gt;Using this technique we will have our first problem, the absence of autocomplete. This is because VSCode still does not understand that the "@" refers to the "src" folder of our project. To solve this we will create in the root directory a configuration file that &lt;strong&gt;&lt;em&gt;VSCode&lt;/em&gt;&lt;/strong&gt; understands, called &lt;em&gt;jsconfig.json&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Inside it include the settings 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;"compilerOptions"&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;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"baseUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&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;"paths"&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;"@/*"&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="s2"&gt;"src/*"&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;"exclude"&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="s2"&gt;"node_modules"&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;Learn more about the &lt;em&gt;jsconfig.json&lt;/em&gt; file:&lt;br&gt;
&lt;a href="https://code.visualstudio.com/docs/languages/jsconfig" rel="noopener noreferrer"&gt;https://code.visualstudio.com/docs/languages/jsconfig&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agora sim! 😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmgd6krlfmtenc68mk47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmgd6krlfmtenc68mk47.png" width="698" height="192"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  A tool that likes to complain! 😡
&lt;/h2&gt;

&lt;p&gt;If you are using &lt;em&gt;eslint&lt;/em&gt; in your project, you will receive many complaints about the imports you make using the prefix '@'.&lt;/p&gt;

&lt;p&gt;Luckily, there is a library that lets you tell &lt;em&gt;eslint&lt;/em&gt; that everything is okay.&lt;/p&gt;

&lt;p&gt;Add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;yarn add eslint-import-resolver-babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;span class="go"&gt;
    ou

&lt;/span&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;eslint-import-resolver-babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;em&gt;eslint&lt;/em&gt; configuration file include the following properties.&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="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;"babel-plugin-root-import"&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;
  
  
  Questions that look stupid but are not 🤔
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Can I use this for applications going to production?
&lt;/h4&gt;

&lt;p&gt;Answer: Yes, if you have followed the steps correctly you will see that we configured for production in babel.config.js&lt;/p&gt;

&lt;h4&gt;
  
  
  Can I use React for web?
&lt;/h4&gt;

&lt;p&gt;Answer: To use the babel plugin root import for Web, you need to perform some other settings&lt;/p&gt;

&lt;h2&gt;
  
  
  But not everything in life is flowers 🔴
&lt;/h2&gt;

&lt;p&gt;You may encounter bugs in the library. If you find it please report it in the official babel plugin root import repository and help the community create a better library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/entwicklerstube/babel-plugin-root-import/issues" rel="noopener noreferrer"&gt;https://github.com/entwicklerstube/babel-plugin-root-import/issues&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow me on twitter &lt;a href="https://twitter.com/heybrunoandrade" rel="noopener noreferrer"&gt;@heybrunoandrade&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Help me translate this article into other languages.&lt;br&gt;
If you have received an error in the translation please make the repository to make a correction. I'll be very grateful.&lt;br&gt;
&lt;a href="https://github.com/heybrunoandrade/my-articles/tree/master/Front-end/React%20Native/Absolute%20Imports" rel="noopener noreferrer"&gt;Access Repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Configurando caminhos absolutos no React Native [pt-BR]</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Fri, 19 Jul 2019 09:54:28 +0000</pubDate>
      <link>https://dev.to/bybruno/configurando-caminhos-absolutos-no-react-native-pt-br-471o</link>
      <guid>https://dev.to/bybruno/configurando-caminhos-absolutos-no-react-native-pt-br-471o</guid>
      <description>&lt;p&gt;📢 English Version:&lt;br&gt;
&lt;a href="https://dev.to/heybrunoandrade/configuring-absolute-paths-in-react-native-en-us-2m5k"&gt;https://dev.to/heybrunoandrade/configuring-absolute-paths-in-react-native-en-us-2m5k&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Uma das coisas que sinto falta no React/React Native são os caminhos absolutos. É muito comum usarmos caminhos relativos para realizar importações de arquivos.&lt;/p&gt;

&lt;p&gt;O problema é quando o projeto cresce e as pastas ficam profundamente aninhadas, acredito que você já possa ter visto ou já fez isso:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;../../../.../../../../Utils/Breadcrumbs.js

../../../../../Components/Form/TextField.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Agora imagine que a pasta Utils mudou de diretório. 😢&lt;/p&gt;

&lt;p&gt;Para resolvermos esse problema, utilize uma biblioteca chamada &lt;em&gt;Babel Plugin Root Import&lt;/em&gt;. Com essa biblioteca podemos utilizar caracteres coringas para apontar o diretório root de nossa aplicação, que geralmente é a pasta “src”. 😍&lt;/p&gt;
&lt;h2&gt;
  
  
  É praticando que se aprende
&lt;/h2&gt;

&lt;p&gt;☝ Adicione a biblioteca em seu projeto.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;yarn add babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;span class="go"&gt;
    ou

&lt;/span&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✌ Após a instalação, configure o arquivo &lt;em&gt;&lt;em&gt;babel.config.js&lt;/em&gt;&lt;/em&gt; que está localizado no diretório raiz.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;presets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;module:metro-react-native-babel-preset&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;babel-plugin-root-import&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;rootPathPrefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;rootPathSuffix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;production&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;babel-plugin-root-import&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;rootPathPrefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;rootPathSuffix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Com tudo configurado, já é possível realizar as importações dos seus arquivos utilizando “@” como prefixo. Segue um exemplo abaixo:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@/Components/Form&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@/Pages/Auth/SignIn&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Uma pitada de &lt;em&gt;VueJS&lt;/em&gt; por favor 🍲
&lt;/h2&gt;

&lt;p&gt;Estou utilizando o “@” para imitar o &lt;em&gt;Vuejs&lt;/em&gt;. Utilize o prefixo que você achar interessante. Pode ser o ‘~’ ou ‘#’ por exemplo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Com licença, você poderia me mostrar o Caminho? 🚶
&lt;/h2&gt;

&lt;p&gt;Utilizando esta técnica teremos o nosso primeiro problema, a ausência do autocomplete. Isso acontece porque o VSCode ainda não entende que o “@” faz referência a pasta “src” do nosso projeto. Para resolver isso vamos criar no diretório raiz um arquivo de configuração que o &lt;strong&gt;&lt;em&gt;VSCode&lt;/em&gt;&lt;/strong&gt; entende, chamado de &lt;em&gt;jsconfig.json&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Dentro dele inclua as configurações abaixo:&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;"compilerOptions"&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;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"baseUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&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;"paths"&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;"@/*"&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="s2"&gt;"src/*"&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;"exclude"&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="s2"&gt;"node_modules"&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;Saiba mais sobre o arquivo &lt;em&gt;jsconfig.json&lt;/em&gt;:&lt;br&gt;&lt;br&gt;
&lt;a href="https://code.visualstudio.com/docs/languages/jsconfig" rel="noopener noreferrer"&gt;https://code.visualstudio.com/docs/languages/jsconfig&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agora sim! 😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmgd6krlfmtenc68mk47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmgd6krlfmtenc68mk47.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Uma ferramenta que gosta de reclamar! 😡
&lt;/h2&gt;

&lt;p&gt;Caso esteja utilizando o &lt;em&gt;eslint&lt;/em&gt; em seu projeto, irá receber muitas reclamações das importações que você faz utilizando o prefixo ‘@’.&lt;/p&gt;

&lt;p&gt;Felizmente, existe uma biblioteca que serve para avisarmos ao &lt;em&gt;eslint&lt;/em&gt; que está tudo certo.&lt;/p&gt;

&lt;p&gt;Adicione:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;yarn add eslint-import-resolver-babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;span class="go"&gt;
    ou

&lt;/span&gt;&lt;span class="gp"&gt;    babylu@Project: ~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;eslint-import-resolver-babel-plugin-root-import &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No arquivo de configuração do &lt;em&gt;eslint&lt;/em&gt; inclua as seguintes propriedades.&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="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;"babel-plugin-root-import"&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;
  
  
  Perguntas que parecem idiotas mas não são 🤔
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Posso usar isso para aplicativos que vão para produção?
&lt;/h4&gt;

&lt;p&gt;R: Sim, se você tiver seguido corretamente os passos verá que configuramos para produção no babel.config.js&lt;/p&gt;

&lt;h4&gt;
  
  
  Posso usar no React para web?
&lt;/h4&gt;

&lt;p&gt;R: Para utilizar o babel plugin root import para Web é necessário realizar algumas outras configurações.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mas nem tudo na vida são flores 🔴
&lt;/h2&gt;

&lt;p&gt;É possível que se encontre bugs na biblioteca. Caso você encontre por favor relate no repositório oficial do babel plugin root import e ajude a comunidade a criar uma biblioteca melhor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/entwicklerstube/babel-plugin-root-import/issues" rel="noopener noreferrer"&gt;https://github.com/entwicklerstube/babel-plugin-root-import/issues&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Me siga no Twitter &lt;a href="https://twitter.com/heybrunoandrade" rel="noopener noreferrer"&gt;@heybrunoandrade&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Me ajude a traduzir esse artigo para outros idiomas.&lt;br&gt;
&lt;a href="https://github.com/heybrunoandrade/my-articles/tree/master/Front-end/React%20Native/Absolute%20Imports" rel="noopener noreferrer"&gt;Acessar Repositório&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
      <category>ptbr</category>
    </item>
    <item>
      <title>Manual on how to become the worst programmer in the world</title>
      <dc:creator>Bruno A.</dc:creator>
      <pubDate>Tue, 16 Jul 2019 23:20:17 +0000</pubDate>
      <link>https://dev.to/bybruno/manual-on-how-to-become-the-worst-programmer-in-the-world-18km</link>
      <guid>https://dev.to/bybruno/manual-on-how-to-become-the-worst-programmer-in-the-world-18km</guid>
      <description>&lt;p&gt;If you want to become the worst programmer in the world I strongly recommend reading those steps that have proven effective in the lives of some programmers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Learn multiple languages ​​/ frameworks at once
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2ALXkSRnqxsh4pBmmD9ZeHFw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2ALXkSRnqxsh4pBmmD9ZeHFw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to become the programming guy learn 8 languages ​​and 5 frameworks at the same time.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create complex jobs for crumbs
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AvqTPNJGxh5kBDoNQ5TmVbA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AvqTPNJGxh5kBDoNQ5TmVbA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The best part of being the worst programmer in the world is to make a complex system and sell it for $25.&lt;/p&gt;

&lt;h4&gt;
  
  
  Discuss the best language/framework
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2Ah72bSS8UZ4ona8scW6Cxgw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2Ah72bSS8UZ4ona8scW6Cxgw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Discussing with the classmates stating that React is better than angular is something that will bring you a great feeling, even because React solves all problems.&lt;/p&gt;

&lt;h4&gt;
  
  
  Do not use version control
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AzWhHZUDWuxJwfEoumC1-OQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AzWhHZUDWuxJwfEoumC1-OQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use Google Drive to version your code. The best practice!&lt;/p&gt;

&lt;h4&gt;
  
  
  Are you in a team? Work alone!
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AL30BHpyUmdluxpzanwujiw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AL30BHpyUmdluxpzanwujiw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Work alone, you do not have to depend on another person. Know that, "Want to make things happen, do it yourself".&lt;/p&gt;

&lt;h4&gt;
  
  
  Do not be proactive
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AoPqw8eUjVCdKFw7HhlprHg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AoPqw8eUjVCdKFw7HhlprHg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Be proactive for what? Nothing will happen, everything will happen well!&lt;/p&gt;

&lt;h4&gt;
  
  
  Do not respect the Senior Developer
&lt;/h4&gt;

&lt;p&gt;The Senior Developers do not know what you're talking about, that post you read on facebook made by a 17 year old who knows how to create a component in the react knows what he's talking about.&lt;/p&gt;

&lt;h4&gt;
  
  
  Don't have discipline
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2Ajs4IF-Nq6rA66wnMFKLELg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2Ajs4IF-Nq6rA66wnMFKLELg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We become programmers to do whatever you want whenever you want and this is our world, get used to it!&lt;/p&gt;

&lt;h4&gt;
  
  
  Forget your mental and physical health
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2API0jVieukS6KIuN4m8xqWA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2API0jVieukS6KIuN4m8xqWA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to stay only on the computer and not worry about your health. Getting out of the computer for a few hours to exercise may cost you money. Time is money, write it down!&lt;/p&gt;

&lt;h4&gt;
  
  
  Get away from the people you love
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AxvMGwXmXiGTbNrPexBzJJg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F700%2F1%2AxvMGwXmXiGTbNrPexBzJJg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Study, work on the personal project, work on delivery of the project that is already for tomorrow. There is no time for people, but no problem because they will always be around.&lt;/p&gt;

&lt;p&gt;And finally ... Write in Dev.to a little manual of how&lt;br&gt;
become the worst programmer in the world.&lt;/p&gt;

&lt;p&gt;Original Post [PT/BR]: &lt;br&gt;
&lt;a href="https://medium.com/@brunoandrade.me/manual-de-como-se-tornar-o-pior-programador-do-mundo-3ac70b4fa1e2" rel="noopener noreferrer"&gt;https://medium.com/@brunoandrade.me/manual-de-como-se-tornar-o-pior-programador-do-mundo-3ac70b4fa1e2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have found some error in the translation, please inform me.&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
