This post is taken from my blog so be sure to check it out for more up-to-date content π
As a programmer, I think you have high expectation for th...
For further actions, you may consider blocking this person and/or reporting abuse
I've used ESLint for years; I keep telling myself I'll switch to prettier the next time I find myself writing an
// eslint-disable-line
or// eslint-disable-next-line
but it never seems to take....One thing to note, naming your magic numbers is all well and good but
numOfIterations
doesn't tell you anything that10
didn't. If you're going to go to the effort, it should explain why, not just what (like comments!).I said about it in the article.
But it's good advice in general. Variables should be taken care more than they actually are.
I must say, I wholly support the import/export rules, they make automatic imports, renames, and other tooling work so much better, as well as generally causing less diffs and consistent naming throughout a project.
I also begrudgingly agree with the sorting rules.
I am not convinced about
"return-undefined"
or even"noImplicitReturns"
though.Implicit returns in a void-returning function are a no-brainer, the body just ends and you're done. And having
undefined
written is just noise, that is whatreturn
means.Personally I'd forbid
return undefined
in all positions, andreturn
at the end of a function. Is there a way to do that?It's a good idea. Sadly, such a simple rule isn't present in TSLint and even ESLint. The closest thing I found is consistent-return from ESLint, but still, it's not exactly the right thing.
But my increment :v
Actually, I feel like a lot of people would applaud the
typedef
rule in this situation (yes, I deleted the types from the implementation):This way all the type information comes first, and the implementation comes after.
Very haskelly.
Well, there's the
"interface-name": [true, "never-prefix"]
option.Which is what the style I've seen TSc team recommend.
I love this article because I can relate to it on so many levels. Don't worry, bro. I know the struggles, too. You aren't the only perfectionist here. π
Well... I definitely feel better now. π As a side-note, I found this. It seems like a nice option if somebody wants to follow strictly defined guidelines with NPM, Express and alike using it. But still, it's not so strict and not so ideal either. That's why for now I disabled my linter (I'll turn it on when I finish writing the basic codebase) as it seemed a bit counter-productive with all this configuration stuff π
Nice article! Will try out tslint:all tomorrow!
I also standard add this rule from tslint-microsoft-contrib to check my code on any forgotten TODO/FIXME/HACK comments:
βno-suspicious-commentβ π
Thanks! I think you might be interested in a config of mine that I've recently released. github.com/areknawo/eslint-config-... It aims to solve most of the issues that I've described in this post. Hope you enjoy it! π