Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint - alias setup

So I am using aliases in my webpack configuration and I have those eslint warnings about no-extraneous-dependencies etc.

So I installed eslint-plugin-import along with eslint-import-resolver-alias and configured my .eslintrc files like this:

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "env": {
    "browser": true,
    "es6": true,
    "node": true,
    "jest": true
  },
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "defaultParams": true
    }
  },
  "rules": {
    "react/jsx-filename-extension": 0,
    "react/sort-comp": 0,
    "linebreak-style": 0,
    "prefer-arrow-callback": 0,
    "consistent-return": 0,
    "func-names": 0,
  },
  "settings": {
    "import/resolver": {
      "alias": [
        // I have my actions folder in ./shared/actions
        ["Actions", "./shared/actions"]
      ]
    }
  }
}

My linter is not working with this settings options. What am I missing?

like image 663
mdmb Avatar asked Aug 24 '17 09:08

mdmb


1 Answers

The problem has to be with your relative path

"./shared/actions"

Try changing it to

"../shared/actions"

If that does not work, try an absolute path and take it from there.

Basically, the root directory / current working directory, is not the one you think it is...

like image 174
Antonios Avatar answered Nov 08 '22 00:11

Antonios