How to change eslint settings to understand absolute import?

You need to use eslint-plugin-import: https://github.com/benmosher/eslint-plugin-import

And configure your eslint settings in .eslintrc

module.exports = {
  ...   
  "settings": {
    "import/resolver": {
      "node": {
        "paths": ["src"]
      }
    },
  },
}

Then, you can use import from src folder.

Example, if you have src/components/MyComponent.jsx, you will write this:

import MyComponent from 'components/MyComponent.jsx';

Leave a Comment