-
Notifications
You must be signed in to change notification settings - Fork 889
ordered-imports does not support path aliases defined in tsconfig #3654
Comments
Isn't that pretty confusing though? There are many libraries that do use NPM scopes and therefore start with |
It is a usage that is somehow popular in the Angular World, one can even find people promoting it (https://medium.com/@tomastrajan/6-best-practices-pro-tips-for-angular-cli-better-developer-experience-7b328bc9db81). But I do agree it may be confusing since NPM scopes start with As a result I renamed my aliases as I agree not all developers are going to uses tsconfig aliases, but at least many Angular CLI developers are going to set |
I agree this is a huge use case. I do this for React as well to avoid long paths with many parent dir references ( |
Facing same issue here. Would really love to use |
I would agree with this. Aliases are becoming more popular and this would be super useful. |
I had the same issue and managed to fix it. In tsconfig.json I have then in tslint.conf (still we check dependencies except optional): then finally in package.json (we have to have it in optional dependencies): With such configuration I can use imports like below without any exception from TSLint: Hopefully that'll work for you :-) |
What if we could tell TSLint which paths are in fact relative, even though they can look as absolute ones. {
"ordered-imports": [
true,
{
"grouped-imports": true,
...
"path-alias-roots": ["$@src/", "$@typings/"]
}
]
} |
I use the same trick (add alias to tsconfig.json) but on karma test I get
Did I miss something ? |
Typed rules are able to access Since the requested behavior is apparently popular in the Angular community, it seems reasonable that this could be made into an |
@ppowstanski Late on the conversation, but we can simply define it like this:
And avoid having to add fake optional dependencies in the package.json. |
I'd prefer looking at |
Using #4134, you could do something like:
Or whatever other way you may want to group the imports. We use something like this for our project with quite a few aliases for internal libraries and modules. |
Thanks @abierbaum !! Great job on that PR! |
☠️ TSLint's time has come! ☠️ TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. ✨ It was a pleasure open sourcing with you all! |
🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖 🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋 |
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
imports starting with @app are considered as imports from libraries.
Expected behavior
However, tsconfig file specifies
@app
as:So those import shall be considered as parent imports.
The text was updated successfully, but these errors were encountered: