8

I'm getting errors on local modules.

Using the following to start my application:

"start": "NODE_PATH=\"$(pwd)\" node -r babel-register -r babel-polyfill src/index.js",

By setting NODE_PATH to the root directory where package.json lies enables me to write imports from the root:

import config from 'src/utils/config';

This is annoying the import/no-extraneous-dependencies rule. If I write the relative path it doesn't complain. Is there a way for eslint to recognize the root directory as the starting path for module import paths?

basickarl
  • 37,187
  • 64
  • 214
  • 335

1 Answers1

-2

Doing things differently probably rightfully makes some linting rules break. Or else let's bug-report the lint rule.

You avoid the initial ./ in every import but is there some other reasons for doing things this way?

There might be other ways to achieve your goal(s). Npm aliases or subpath imports perhaps? https://stackoverflow.com/a/67825148/296639

Simon B.
  • 2,530
  • 24
  • 30