Skip to content

Is this necessary for import/no-cycle? #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CMCDragonkai opened this issue May 26, 2022 · 1 comment
Closed

Is this necessary for import/no-cycle? #106

CMCDragonkai opened this issue May 26, 2022 · 1 comment

Comments

@CMCDragonkai
Copy link

I came to this repo after this https://github.com/import-js/eslint-plugin-import#typescript says to also install this.

However I tried the rule import/no-cycle, and it worked as long as I added plugin:import/typescript:

  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended",
    "plugin:import/typescript", // <--- ADDED THIS ONE
    "prettier"
  ],
  "plugins": [
    "import"
  ],

If I didn't have that plugin, it wouldn't work.

Now I checked my package-lock.json to see if something was bringing in this package eslint-import-resolver-typescript. But there was nothing.

[nix-shell:~/Projects/TypeScript-Demo-Lib-Native]$ ag 'eslint-import-resolver'
package-lock.json
2943:    "node_modules/eslint-import-resolver-node": {
2945:      "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
2953:    "node_modules/eslint-import-resolver-node/node_modules/debug": {
2994:        "eslint-import-resolver-node": "^0.3.6",
10529:    "eslint-import-resolver-node": {
10531:      "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
10581:        "eslint-import-resolver-node": "^0.3.6",

Does this mean this package isn't required for some of the rules in the eslint-import-plugin? Or should I still have this package for other reasons?

@JounQin
Copy link
Collaborator

JounQin commented May 26, 2022

You need enable this resovler manually, it helps to resolve @types/* automatically:

{
  "import/resolver": {
    "typescript": {}
  }
}

This means you can:

  • import/require files with extension .ts/.tsx!
  • Use paths defined in tsconfig.json.
  • Prefer resolve @types/* definitions over plain .js.
  • Multiple tsconfigs support just like normal.

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants