Import blacklist is not working on named imports.
import { action } from "mobx";
with tslint.json configuration:
"import-blacklist": [
true,
{
"mobx": [
"action"
]
}
]
Ts lint passes with no issues.
It should fail since using action from mobx is blacklisted.
@Stupar92 I get the error locally. What command are you using to run the CLI?
Closing for inactivity. @Stupar92 please do comment again if you're seeing the bad behavior!
@JoshuaKGoldberg I was able to reproduce the issue above. I am using a base Angular CLI project, which uses typescript ~3.2.2 and tslint ~5.11.0. I attempted it with installing lodash and blacklisting isFunction like this:
"import-blacklist": [
true,
"rxjs/Rx",
{
"lodash": [
"isFunction"
]
}
],
I will try and see if I can reproduce the issue in a different context, however a fresh Angular CLI application should work.
@JoshuaKGoldberg same issue over here. Rule was added but tslint is not marking any issue.
Could you re-open this issue?
@Mr1upMachine did you find a solution to fix?
Current configuration:
@angular/core: 5.2.7
@angular/cli: 1.7.4
@angular/compiler-cli: 5.2.7
Typescript 3.2.2
Tslint 5.9.1
@christopheberth I have not yet no.
Same issue here my React/Typescript app. This is not working:
"import-blacklist": [
true,
{
"styled-components": [
{
"name": "styled",
"message": "import from styled-components/macro instead"
}
]
}
]
typescript: 3.3.3333
tslint: 5.13.0
I just tried the OP's sample code with mobx and action using TSLint 5.13.0 and correctly got a TSLint complaint.
{
"rules": {
"import-blacklist": [
true,
{
"mobx": [
"action"
]
}
]
}
}
// index.ts
import { action } from "mobx";
@bopfer @Mr1upMachine @christopheberth please share:
tslint.jsonWithout all those, it's rather difficult to repro what's going wrong.
@JoshuaKGoldberg, I have create a bare minimum repo to show the issue I am having. This repo is using the exact tslint.json file that I am using in my real app:
https://github.com/bopfer/import-blacklist-testing
I would like this to be blacklisted:
import styled from 'styled-components';
In favor of this:
import styled from 'styled-components/macro';
But, in src/index.tsx, VSCode and yarn lint will not report it.
It's very possible I am just plain doing something wrong, but I am not sure what that would be.
Super, thanks @bopfer! I'll take a look.
Also hitting this issue. I tried to upgrade dependencies, but it didn't help.
tslint: 5.15.0
typescript: 3.3.3333
typescript-tslint-plugin: 0.3.1
Edit: It actually started working after playing around a bit. I saw somewhere that you could pass an object to provide a message about an import, but looking at the config schema that is not actually supported. Here's the config I got working:
{
"import-blacklist": [true, { "lodash": ["isFinite"] }]
}
I never did take a look 馃槥... but thanks @villelahdenvuo! It sounds like the issue is with the rule's documentation and/or config parsing then?
I think the documentation is correct, I just saw the wrong example in some stackoverflow post. And my initial issue is with the VS Code/typescript plug-in because it's not showing lint errors for js files even though it is configured to do so. When I run it via the cli it works fine.
So is there any way to get this working with the VS Code/typescript plug-in. No one in my company actually uses ng lint (just linting on save) so it would be nice to have a fix for this. I've tried both of these rules
"import-blacklist": [
true,
[
"^primeng.primeng$",
"^rxjs.Rx$"
]
],
"import-blacklist": [
true,
"rxjs/Rx",
"primeng/primeng"
],
and neither throws an error when writing import { MessageModule } from 'primeng/primeng';
Blacklisting named imports have been added in v5.12
馃 Beep boop! 馃憠 TSLint is deprecated 馃憟 and you should switch to typescript-eslint! 馃
馃敀 This issue is being locked to prevent further unnecessary discussions. Thank you! 馃憢
Most helpful comment
@JoshuaKGoldberg same issue over here. Rule was added but tslint is not marking any issue.
Could you re-open this issue?
@Mr1upMachine did you find a solution to fix?
Current configuration:
@angular/core: 5.2.7@angular/cli: 1.7.4@angular/compiler-cli: 5.2.7Typescript 3.2.2Tslint 5.9.1