Configurable no-implicit-dependencies Ignore to Support Absolute Path Imports #3483
Comments
There's just one question: how to add the whitelisted modules to the existing config? Currently this rule has two config options, so you can write I think the best approach would be a config object: "whitespace": [
true,
{
"dev": true,
"optional": true,
"whitelist": ["#", "~"] // property could be named "ignore" as well
] |
An aside: My question/suggestion: "no-implicit-dependencies": [
true,
{
"dev": true,
"optional": true,
"allow": ["#", "~", "/app"] // I like "allow" as the exception name, but ditch it if it conflicts with established conventions
}
]
"no-implicit-dependencies": [ true, "dev", "optional" ] |
Yeah sorry my example above uses another tslint rule to show an example of what I would want not that I want to change
edit: I started working on this but then I realized that I broke the API. So unfortunately no real progress to show. Ill take a look at this again when i have time over the holidays. |
I just ran into this as well - I have no choice but to disable these rules in my tslint.json. |
@viridia: You might consider doing some inline tslint disabling. That way, you'd still get feedback if you accidentally import something that is not in your package file. That's what I settled on in the meantime. Of course, for my project, I didn't have very many places where I was importing in a way that caused an issue. If you do, it might be a bigger headache. |
@happycollision I used absolute imports pervasively throughout the code - based on advice from this medium post: https://spin.atomicobject.com/2017/10/07/absolute-paths-javascript/ |
I'm also having an issue. This would be so great if we had a fix for this. I ended up disabling the rule in my tslint.json |
For those interested have I figured out a very hacky workaround, while we are waiting for a real fix. |
Any forecast if that will be implemented? |
Need this enhancement too, please consider implement it. 🌹 |
I would also benefit from this. |
I had to disable the no-implicit-dependencies rule because I use absolute imports in my projects. This feature could be very useful. |
Need this feature here, too. |
this feature would be very much appreciated |
https://github.com/palantir/tslint/releases/tag/5.11.0
|
Can documentation be added for this? I don't understand how to use it. If I have
How would I use this? I tried:
But I get this error:
|
Got it working. Here is what I did:
"paths": {
"~/*": ["./*"]
}, |
What about dev dependencies @ilearnio ? |
@jeznag Hm, not sure if I'll ever need them in my app's code. So far all works good |
@jeznag FYI if your paths start with @ then you need to specify the whole name (not just the package name) due to the way the package name is calculated (it seems to not split the name of if it’s starts with an @ symbol): see
|
Damn! That's a good catch @chris5287 ! I was using the My
My
So I can now import local modules without tslint nor ts error. Eg:
|
Don't forget the wildcard ( Incorrect: "paths": {
"path1/": ["dir/"]
} Correct: "paths": {
"path1/*": ["dir/*"]
} |
🤖 Beep boop! 👉 TSLint is deprecated 👈 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
Expected behavior
I use webpack resolve to support absolute path imports and tslint, on two different linters (no-submodule-imports and no-implicit-dependencies), picks this up as a package import and throws an error. My ask is the ability to configure an ignore for certain import prefixes (or packages in this scenario). Similar to:
I would like to keep the rule enabled as it did help me catch an implicit import but it breaks the above workflow.
The text was updated successfully, but these errors were encountered: