Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
validateParameterSeparator: notice class methods
Browse files Browse the repository at this point in the history
Fixes #2289
  • Loading branch information
markelog committed Jul 14, 2016
1 parent 92fa964 commit 47d19e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rules/validate-parameter-separator.js
Expand Up @@ -54,7 +54,11 @@ module.exports.prototype = {
var whitespaceBeforeComma = Boolean(separators.shift());
var whitespaceAfterComma = Boolean(separators.pop());

file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {
file.iterateNodesByType([
'FunctionDeclaration',
'FunctionExpression',
'ClassMethod'
], function(node) {

node.params.forEach(function(paramNode) {

Expand Down
20 changes: 20 additions & 0 deletions test/specs/rules/validate-parameter-separator.js
Expand Up @@ -51,6 +51,11 @@ describe('rules/validate-parameter-separator', function() {
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should validate class methods', function() {
expect(checker.checkString('class a { constructor(a, b) {} }'))
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should report unexpected space for function a(b ,c) {}', function() {
expect(checker.checkString('function a(b ,c) {}'))
.to.have.one.validation.error.from('validateParameterSeparator');
Expand Down Expand Up @@ -102,6 +107,11 @@ describe('rules/validate-parameter-separator', function() {
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should validate class methods', function() {
expect(checker.checkString('class a { constructor(a , b) {} }'))
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should report missing space for function a(b,c) {}', function() {
expect(checker.checkString('function a(b,c) {}'))
.to.have.one.validation.error.from('validateParameterSeparator');
Expand Down Expand Up @@ -149,6 +159,11 @@ describe('rules/validate-parameter-separator', function() {
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should validate class methods', function() {
expect(checker.checkString('class a { constructor(a , b) {} }'))
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should report missing space for function a(b,c) {}', function() {
expect(checker.checkString('function a(b,c) {}'))
.to.have.one.validation.error.from('validateParameterSeparator');
Expand Down Expand Up @@ -192,6 +207,11 @@ describe('rules/validate-parameter-separator', function() {
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should validate class methods', function() {
expect(checker.checkString('class a { constructor(a, b) {} }'))
.to.have.one.validation.error.from('validateParameterSeparator');
});

it('should report missing space for function a(b ,c) {}', function() {
expect(checker.checkString('function a(b ,c) {}'))
.to.have.one.validation.error.from('validateParameterSeparator');
Expand Down

0 comments on commit 47d19e1

Please sign in to comment.