Webstorm how to choose shortest import

I have a question about is there a way WebStorm to choose the shortest import ?
So what I mean, for example if we have such file structure.

Now the root components folder under the src is with alias '@components'.

When I want to import the DefaultArticleHeader in the DefaultArticleHeader.test.tsx file
the auto import with alias will look like that.

import DefaultArticleHeader from "@components/CMS/components/DefaultArticleHeader"

while it can just be

import DefaultArticleHeader from "./DefaultArticleHeader"

The problem is non of the members from my team use WebStorm, and some of them are writing the imports by hand, and they find the long import harder to read, and they use the aliases only when they need to avoid imports like import Something from "../../../../components/....."

Comment actions Permalink

Please try setting Use path mappings from tsconfig.json to Only in files outside specified paths in Settings | Editor | Code Style | TypeScript - does it make things any better?

Comment actions Permalink

Yes, that is working great.


Please sign in to leave a comment.