Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
How to disable eslint 'no-undef' for a specific package import?

I'm working with a framework ('hardhat') that automatically requires a package ('ethers') but eslint keeps calling it out as undefined. Requiring 'ethers' is not a solution because it just breaks everything; but from what I understand, a way to add exceptions to the entire document is to place overrides in a comment block above the entire thing.

 /*
    eslint-disable jest/valid-expect
 */ 
const { expect } = require("chai");
const { txHist } = require("../scripts/utils.js");

describe("DStor", () => {
    let DStor;
    let deployer, user1, user2, user3, users; // eslint-disable-line no-unused-vars

    beforeEach(async () => {
        // Get ContractFactory and Signers
        const DStorFactory = await ethers.getContractFactory("DStor"); // 'ethers' is highlighted with no-undef
...

I suspect the solution is to add another eslint-disable rule, but I don't know how to target the 'ethers' package with it. Anyone have any solutions?

Update: fixed by adding const { ethers } = require("hardhat");

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Have a look at ESLint globals. Basically, you can declare a global value ethers in your ESLint configuration, and that will be treated as defined in all linted files.

For ESLint >= 7, if your configuration file is .eslintrc, add an entry like:

{
    "globals": {
        "ethers": "readonly"
    }
}

For ESLint < 7, use "ethers": false instead.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda