Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class-methods-use-this rule #47

Merged
merged 2 commits into from Apr 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/bad/es6.js
Expand Up @@ -37,3 +37,14 @@ var foo = new Symbol('foo'); // The Symbol constructor is not intended to be use
function* foo() {
return 10; // This generator functions that do not have the `yield` keyword.
}

/*eslint class-methods-use-this: "error"*/
class A {
constructor() {
this.a = "hi";
}

sayHi() {
console.log("hi"); // The sayHi method doesn’t use this, so we can make it a static method.
}
}
3 changes: 2 additions & 1 deletion lib/es6-rules.js
Expand Up @@ -10,5 +10,6 @@ module.exports = {
'no-class-assign': 'error',
'no-const-assign': 'error',
'no-new-symbol': 'error',
'require-yield': 'error'
'require-yield': 'error',
'class-methods-use-this': 'error'
};