Search code examples
neovim

How in neovim to use auto-imports in TS files with default absolute paths, not relative ones?


WebStorm has a setting to make auto-imports absolute.

enter image description here

How to do the same in Neovim? By default, auto-imports in Neovim are relative:

import { Component } from '../Component'

And I need to use the paths from tsconfig.json. I use Astrovim


Solution

  • I added a plugin for eslint https://www.npmjs.com/package/eslint-plugin-no-relative-import-paths

    {
      "plugins": ["no-relative-import-paths"],
      "rules": {
        "no-relative-import-paths/no-relative-import-paths": [
          "error",
          { "allowSameFolder": true, "rootDir": "src", "prefix": "" }
        ]
      }
    }