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

174
Views
Have ESLint or Prettier detect undefined / unimported code

I set up a JavaScript project with ESLint and Prettier.

Here is my .eslintrc.json:

{
  "extends": [
    "next/core-web-vitals",
    "plugin:unicorn/recommended",
    "plugin:prettier/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": 2022
  },
  "plugins": ["simple-import-sort"],
  "rules": {
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error",
    "unicorn/no-null": "off",
    "unicorn/prevent-abbreviations": [
      "error",
      {
        "allowList": {
          "getServerSideProps": true,
          "getStaticProps": true
        }
      }
    ]
  },
  "overrides": [
    {
      "files": ["*.spec.ts"],
      "extends": ["plugin:cypress/recommended"]
    }
  ]
}

and here is my .prettierrc.json:

{
  "arrowParens": "avoid",
  "bracketSameLine": false,
  "bracketSpacing": true,
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "always",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "all",
  "useTabs": false
}

Now I wrote this test:

import { describe } from 'riteway';

describe('mapUserSessionToUserProfile()', async assert => {
  const email = 'foo@bar.com';
  const session = {
    email,
    issuer: 'did:example:123456789abcdefghi',
    publicAddress: '0xDC25EF3F5B8A186998338A2ADA83795FBA2D695E',
  };

  const userProfile = { email, id: session.issuer };

  assert({
    given: 'a user session',
    should: 'return a user profile',
    actual: mapUserSessionToUserProfile(session),
    expected: userProfile,
  });
});

but as you can see, I forgot to:

import { mapUserSessionToUserProfile } from './user-profile-helpers';

ESLint didn't complain. I was wondering, is there a way for ESLint to recognize these errors?

about 4 years ago · Juan Pablo Isaza
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!