DEV Community

Vinícius Bispo
Vinícius Bispo

Posted on

7 1

Como sobrescrever uma regra do eslint para uma pasta específica

Hoje passei por uma coisa no projeto onde eu trabalho, no qual minha tarefa foi adicionar o ESLint, porém não deveria deixar a regra do no-unused-vars nas migrations.
Essa era basicamente a minha config:

{
  "rules": {
    "no-unused-vars": [
      "error",
      {
        "argsIgnorePattern": "^_",
        "varsIgnorePattern": "^_"
      }
    ],
  }
}
Enter fullscreen mode Exit fullscreen mode

Aí eu pesquisei como eu faria isso no meu bom amigo DuckDuckGo(DDG), encontrei várias respostas, mas as principais foram:

  • Criar um .eslintrc.json dentro da pasta de migration e sobrescrever as regras lá (não gostei muito)
  • Usar a opção overrides do ESLint (gostei muito).

Vamos ver como fica com a opção de overrides:

{
  "rules": {
    "no-unused-vars": [
      "error",
      {
        "argsIgnorePattern": "^_",
        "varsIgnorePattern": "^_"
      }
    ],
  },
  "overrides": [
    {
      "files": [
        "migrations/*.js"
      ],
      "rules": {
        "no-unused-vars": "off"
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

E foi assim que aprendi a sobrescrever uma regra do eslint para uma pasta específica.
Espero que tenham gostado deste artigo curto. Fiquem bem e até a próxima!

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay