Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!