-
Notifications
You must be signed in to change notification settings - Fork 887
Conversation
e88a205
to
e17ef03
Compare
Just a suggestion: class Foo {
bar() { this.bar(); }
~~~ [lorem ipsum]
} If you want to go the easy way, you could "borrow" my implementation for this rule: https://github.com/ajafff/tslint-consistent-codestyle/blob/master/rules/preferStaticMethodRule.ts |
@ajafff Thanks! Have you considered turning some of your rules into pull requests here? |
On second thought the name of this rule is a bit misleading. // function is not using this, but declares it in parameter list
function doStuff(this: Foo, bar: Bar) {
~~~~~~~~~ [unused this]
return bar;
} |
export class Rule extends Lint.Rules.AbstractRule { | ||
/* tslint:disable:object-literal-sort-keys */ | ||
public static metadata: Lint.IRuleMetadata = { | ||
ruleName: "no-unused-this", |
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.
name is misleading since it does allow this
. I don't have a good name, but what about something like prefer-functions-over-methods
How about |
That sort of makes it sound like the rule is suggesting that |
no-unused-this
ruleprefer-function-over-method
rule
@andy-hanson thanks! |
PR checklist
What changes did you make?
Added the
no-unused-this
rule, which warns for methods that don't usethis
(they could be functions).Also, once microsoft/TypeScript#13217 is in, I'll add an exception for
override
, since that's a legitimate case where you would need to write a method that might not usethis
.