-
Notifications
You must be signed in to change notification settings - Fork 885
Deprecate no-unused-variable rule for typescript@next; also fix runtime error #3919
Conversation
it looks like @next is still broken :( |
src/rules/noUnusedVariableRule.ts
Outdated
@@ -72,6 +72,9 @@ export class Rule extends Lint.Rules.TypedRule { | |||
type: "functionality", | |||
typescriptOnly: true, | |||
requiresTypeInfo: true, | |||
deprecationMessage: !/^2\.[0-8]\./.test(ts.version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also use semver
to test versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes prefer using semver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, udpated
It is unfortunate that this option has been deprecated again. Here is at least one scenario when defining Could this option be undeprecated again like in #2256? |
Yeah, why was this re-deprecated? The issues with the built-in typescript flags haven't changed (afaik) -- they are still compile errors, where as |
Please see the discussion in #3918 (it's linked right at the top of the PR). |
Unfortunately this leaves things in a poor state (and I very much get that the rule was/is causing to much complexity/issues), because typescript isn't going to make those compiler options warnings, and from there issues about it have recommended using TSLint for that instead. 😢 |
@kachkaev wrote:
Another use-case where i really need it, is generated code. I want my manually written code to follow this rule, but to avoid making code-generator enormously complex, i'd like to disable this rule in generated code (or at least in some sections of generated code) - that is smth that can't be done with TypeScript compiler option. Please undeprecate this rule again! 😢 |
Another reason why I need it In Angular, sometimes you need to have to use
|
IMO Inputs, Outputs, HostBindings etc. shouldn't be private, because angular uses them outside of class |
Because sometimes I do not see why you should break encapsulation for the sake of it
<app-my-component [hello]="foo" (myOutput)="bar"></app-my-component> |
But it's the same way you are using your How do you think Angular would use your I think it's something like that -> Your variable is never read privately in class, so it has to be read outside of your component. |
Really disappointed to see this deprecation. Having a compilation failure is very annoying during active development. Linting is specifically where I want to catch this issue. |
So say you have an e.g. @Component({
selector: 'app-my-component',
templateUrl: './my.component.html',
styleUrls: ['./my.component.scss']
})
export class MyComponent {
@Input() private readonly label: string; // not used in template
...
} |
Totally agree with #3919 (comment) and #3919 (comment) and vote for undeprecate this rule back. See my explanation in buzinas/tslint-eslint-rules#171 (comment) |
See palantir/tslint#3919 and https://github.com/palantir/tslint/blob/master/CHANGELOG.md#warning-deprecations. Signed-off-by: Volker Theile <vtheile@suse.com>
Yeah, would you please bring this back - treating unused variables as build errors during active development is extremely annoying when commenting out code just to test something. |
I think discussion was moved to this issue #4100 |
@dolanmiu |
to silence warning like no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead. see palantir/tslint#3919 Signed-off-by: Kefu Chai <kchai@redhat.com>
to silence warning like no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead. we are using TypeScript 3.1.3 at the time of writing. see palantir/tslint#3919 Signed-off-by: Kefu Chai <kchai@redhat.com>
PR checklist
Overview of change:
The latest versions of TS 2.9-nightly change how they report some diagnostics, this PR makes sure the rule doesn't throw given those changes.
However, the changes in 2.9 make it much more complex for this rule to work as intended, especially with respect to the
ignorePattern
option. As per the discussion in #3918, we henceforth deprecate the rule for TS 2.9 and later, since the compiler handles most of what this rules does adequately.CHANGELOG.md entry:
[deprecation] no-unused-variable is deprecated because typescript now covers most of its functionality