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

106
Views
How to avoid relative imports with no-restricted-imports

What I want

I want to avoid the deep relative imports like ../../../, and I want to allow only the relative import of package.json file, so I set up the eslint no-restricted-imports rule like so:

.eslintrc.js

module.exports = {
  rules: {
    'no-restricted-imports': [
      'error',
      {
        patterns: [
          {
            group: ['**/../../*', '!**/../../package.json'],
            message: 'Please use alias instead of deep relative imports.',
          },
        ],
      },
    ],
  },
};

The problem

The problem with this configuration is that it is taking the imports from package.json as well, so this is throwing error: import * as PackageJSON from '../../../package.json';

how can I avoid all relative imports except the package.json one?

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!