How to manually add a path to be resolved in eslintrc

I think the link below helps you. You can add resolving directories by using config.

https://github.com/benmosher/eslint-plugin-import#resolvers

For example, if you want to resolve src/, you can write like below on .eslintrc.

{
  "settings": {
    "import/resolver": {
      "node": {
        "paths": ["src"]
      }
    }
  }
}

Then ESLint resolve from src directory. You can require src/hoge/moge.js by writing const moge = require('hoge/moge'); and ESLint knows it.


Too late to see this question. Actually, there is already a resolver named eslint-import-resolver-alias that implements this functionality with the below setting.

{
  settings: {
    'import/resolver': {
      'alias': [
        ['main/src', './main/src']
       ]
     }
  }
}

I was facing similar problem: ESLint was not able to resolve the modules imported relative to instruction "baseUrl": "src" in my tsconfig.json.

Managed to solve the problem in a similar to the marked as a solution answer, except I had to add the extensions array. So I added the following to my .eslintrc.js:

  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
        paths: ['./src']
      }
    }
  },

Hope this helps someone. The source of my solution is actually the package's npm page.