tleunen / eslint-import-resolver-babel-module

Custom eslint resolve for babel-plugin-module-resolver
https://github.com/tleunen/babel-plugin-module-resolver
MIT License
248 stars 31 forks source link

Aliases that begin with an exclamation mark cause errors #91

Closed AlephFive closed 6 years ago

AlephFive commented 6 years ago

Currently we are using an alias that begins with an exclamation mark in the babel plugin module resolver without any problems. However, despite this eslint will get missing file extension and unable to resolve path errors: 1:28 error Unable to resolve path to module '!src/routes/routes' import/no-unresolved 1:28 error Missing file extension for "!src/routes/routes" import/extensions Changing the alias to something without the exclamation mark works just fine though.

Here are some relevant info:

in .babelrc

{
  "plugins": [
    [
      "babel-plugin-module-resolver",
      {
        "alias": {
          "!src": "./src"
        }
      }
    ]
  ],
  "env": {
    "development": {
      "presets": [
        "@babel/preset-env",
        "next/babel",
        [
          "@babel/preset-stage-0",
          {
            "decoratorsLegacy": true
          }
        ],
      ]
    },
    "production": {
      "presets": [
        "@babel/preset-env",
        "next/babel",
        [
          "@babel/preset-stage-0",
          {
            "decoratorsLegacy": true
          }
        ]
      ]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
    }
  }
}

in .eslintrc

{
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "node": true
  },
  "settings": {
    "ecmascript": 6,
    "jsx": true,
    "import/resolver": {
      "babel-module": {}
    }
  },
  "plugins": [
    "react",
    "jsx"
  ],
  "extends": [
    "airbnb",
    "eslint:recommended",
    "plugin:react/recommended"
  ],
}