ABuffSeagull / eslint-import-resolver-parcel

Parcel import resolution plugin for eslint-plugin-import
MIT License
12 stars 2 forks source link

My ~ paths aren't resolving #26

Closed jgoux closed 4 years ago

jgoux commented 5 years ago

Hello, sorry for the support related issue. 😅

I'm trying to use eslint-plugin-import but I'm failing at setting it up with parcel.

I added eslint-import-resolver-parcel as the resolver :

{
"eslintConfig": {
    "extends": [
      "plugin:react-app/recommended",
      "plugin:import/errors",
      "plugin:import/warnings"
    ],
    "plugins": [
      "react-hooks"
    ],
    "rules": {
      "react-app/react/react-in-jsx-scope": "off",
      "react-hooks/rules-of-hooks": "error",
      "react-hooks/exhaustive-deps": "warn"
    },
    "settings": {
      "import/resolver": {
        "parcel": {
          "rootDir": "src"
        }
      }
    }
  }
}

but when I do : eslint src/ all my ~ paths are in error : 7:30 error Unable to resolve path to module '~/components' import/no-unresolved

Did I miss something ? The project is building fine with parcel.

For the record I tried using eslint-import-resolver-alias which works fine :

"settings": {
      "import/resolver": {
        "alias": [
          [
            "~",
            "./src"
          ]
        ]
      }
    }
ABuffSeagull commented 5 years ago

I think I might've changed the logic awhile ago and never got around to pushing it. :man_shrugging: Update and try again, and if that doesn't work, do let me know

coder2000 commented 4 years ago

I am using 1.10.1 and having the same issue.

ABuffSeagull commented 4 years ago

Hmm, now that I'm looking over it, I don't think I completely understood the docs when it described the package root. I'll dive around in the parcel source code and see what it's actually referring to.

ABuffSeagull commented 4 years ago

Aha!

// Tilde path. Resolve relative to nearest node_modules directory,
// or the project root - whichever comes first.

https://github.com/parcel-bundler/parcel/blob/v1.10.3/src/Resolver.js#L129

I was always going to the nearest node_modules directory.

ABuffSeagull commented 4 years ago

Let me know if you still have issues