0

i am trying to import modules inside nodejs routes file using the "node-module-alias".

My code structure is as follows,

.
├── src
    ├──utils
       ├── logger

when i try to commit the code, eslint fails with below error message.

2:30 error "src" is extraneous node/no-extraneous-import

my import code in the file is as follows,

```import Logger from 'src/utils/logger';````

I was able to fix the issue by adding a line in .eslintrc file

'node/no-extraneous-import': 'off',

But I dont want to modify the eslintrc file, and fix the issue. Any help would be appreciated. Thanks.

Shivathanu GC
  • 43
  • 1
  • 6

1 Answers1

0

You don't need to switch off the rule from rc file. You could simply disable it for that file by

/* eslint-disable node/no-extraneous-import */

import Logger from 'src/utils/logger

or by that line using

 // eslint-disable-next-line node/no-extraneous-import
 import Logger from 'src/utils/logger

And if you want to fix the root cause, If the place from where you are importing the file is at the same level as of logger, you don't need to give full path.

import Logger from './loggger';
Ashish Modi
  • 7,529
  • 2
  • 20
  • 35