-
Notifications
You must be signed in to change notification settings - Fork 887
no-unused-variable TypeError: Cannot read property '1' of null #3918
Comments
Good find @hotforfeature. I started addressing this over in #3919 because it related to some changes coming up in TS 2.9 which will only exacerbate this issue. My PR prevent an exception from being thrown, however, it simply ignores |
I'm wondering if we should thing about deprecating this rule. tsc now provides a way to ignore its warnings, and it provides support for automatic fixes for its warnings through an IDE. As far as I can see, the main benefit to this rule is |
My primary use case for this rule is to autofix problems on commit in a git hook when linting. So I still think there's great value here even if tsc offers something via IDE integrations. |
@jkillian i think that the rule is starting to become increasingly expensive to support with TSLint's support for multiple versions of Typescript and continued changes in Typescript behavior. And since Typescript supports the feature, we should lean towards using that. But since earlier versions of TS doesn't support it, I dont think that we should delete it. However i think we should start to think about deprecating the rule and work with the TS folks to better support the current TSLint workflows with TS. |
I would second @suchanlee 's proposal. This rule comes up in issues a lot, it seems. Too many considering that recent TS versions warn about the problem adequately. Let's phase it out! |
@hotforfeature - acknowledge your usecase and find it reasonable. However, due to the complexity of the rule, I think we're going to deprecate it (see #3919). As always though, anyone is welcome to copy the source code of the rule and move it to an external package and keep using/improving it that way! |
For what it's worth: {
"compilerOptions": {
"noUnusedLocals": true,
"noUnusedParameters": true,
}
} Using the above in |
|
Defining |
@giladgray, @killtheliterate wrote:
I don't want to disable this rule, because as @kachkaev wrote
My use-case 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 options 😞 |
At the very least, this deprecation should be documented on the TSLint website, but I strongly agree that this deprecation was premature. Any plans to re-consider? Would a community contribution be accepted? |
This deprecation is ridiculous. The compiler flags are a TERRIBLE replacement. They break the build and don't fix themselves. How is that a reasonable solution to point people to? If the |
👋 folks - just linking this to #4232. It's well understood & agreed that the built-in compiler options are not a sufficient replacement for In the meantime, you could use something like |
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
Expected behavior
Rule should warn
All imports in import declaration are unused.
for line 1.This is caused by noUnusedVariableRule.ts#L123 because the
failure
message isAll imports in import declaration are unused.
, which does not have a variable name in it for the regex to find.This rule works correctly if the
ignore-pattern
option is not specified since it won't try to check the variable name.The text was updated successfully, but these errors were encountered: