FluidFramework icon indicating copy to clipboard operation
FluidFramework copied to clipboard

Proposal: Disable noUnusedLocals in shared TSConfig

Open tylerbutler opened this issue 6 years ago • 5 comments

The noUnusedLocals TSConfig setting is problematic when prototyping or debugging because it prevents compilation. Unused locals should be a linting error, and I don't think linting errors should cause compilation failures.

Now that we are using ESLint everywhere, and it includes rules that check for unused locals, I think we should disable the TSConfig rule. ESLint will still ensure unused locals are cleaned up before merge, but it won't get in the way of compilation when you have a debug variable hanging around during active development.

tylerbutler avatar Feb 18 '20 16:02 tylerbutler

I’m not against this in theory, but linting isn’t 100% reliable in our code base as there are lots of files that disable it. I’m worried these could still sneak through right now.

anthony-murphy avatar Feb 18 '20 17:02 anthony-murphy

@anthony-murphy Would enabling noUnusedLocals in CI builds alleviate those concerns?

tylerbutler avatar Feb 18 '20 17:02 tylerbutler

I would love for us to push for parity between our CI and our local build. It's very time consuming when everything is building and passing locally but breaking in the CI.

skylerjokiel avatar Feb 18 '20 19:02 skylerjokiel

This is sort of debated in a GitHub issue. It sounds like ESLint may have weaker detection of these kinds of errors?

I’m not against this in theory, but linting isn’t 100% reliable in our code base as there are lots of files that disable it. I’m worried these could still sneak through right now.

Agree we should fix those to turn on linting, but accidentally letting unused locals slip in isn't the worst kind of error to let slip through. They should basically have no effect, and are trivial to fix once linting is enabled.

arinwt avatar Feb 18 '20 21:02 arinwt

Regardless of the choice I agree that we shouldn't have lint rules that are enabled on a CI job but not locally. The only drift I'd expect on the build server is running a long form test or performance pass.

Unused locals on their own likely aren't dangerous. But tend to be a canary for some other logic issue that led to them being unused. I'm not sure if the TypeScript team has weighed in on these issues for their preference but that might be insightful.

Although these checks can be annoying I find commenting out the code when prototyping can be helpful. Or if you want to keep a variable around to inspect it's usually simple to do something that makes the compiler happy - like console.log it, assert it, etc...

kurtb avatar Feb 18 '20 22:02 kurtb