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

Commit 47d19e1

Browse files
committed
validateParameterSeparator: notice class methods
Fixes #2289
1 parent 92fa964 commit 47d19e1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/rules/validate-parameter-separator.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ module.exports.prototype = {
5454
var whitespaceBeforeComma = Boolean(separators.shift());
5555
var whitespaceAfterComma = Boolean(separators.pop());
5656

57-
file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {
57+
file.iterateNodesByType([
58+
'FunctionDeclaration',
59+
'FunctionExpression',
60+
'ClassMethod'
61+
], function(node) {
5862

5963
node.params.forEach(function(paramNode) {
6064

test/specs/rules/validate-parameter-separator.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ describe('rules/validate-parameter-separator', function() {
5151
.to.have.one.validation.error.from('validateParameterSeparator');
5252
});
5353

54+
it('should validate class methods', function() {
55+
expect(checker.checkString('class a { constructor(a, b) {} }'))
56+
.to.have.one.validation.error.from('validateParameterSeparator');
57+
});
58+
5459
it('should report unexpected space for function a(b ,c) {}', function() {
5560
expect(checker.checkString('function a(b ,c) {}'))
5661
.to.have.one.validation.error.from('validateParameterSeparator');
@@ -102,6 +107,11 @@ describe('rules/validate-parameter-separator', function() {
102107
.to.have.one.validation.error.from('validateParameterSeparator');
103108
});
104109

110+
it('should validate class methods', function() {
111+
expect(checker.checkString('class a { constructor(a , b) {} }'))
112+
.to.have.one.validation.error.from('validateParameterSeparator');
113+
});
114+
105115
it('should report missing space for function a(b,c) {}', function() {
106116
expect(checker.checkString('function a(b,c) {}'))
107117
.to.have.one.validation.error.from('validateParameterSeparator');
@@ -149,6 +159,11 @@ describe('rules/validate-parameter-separator', function() {
149159
.to.have.one.validation.error.from('validateParameterSeparator');
150160
});
151161

162+
it('should validate class methods', function() {
163+
expect(checker.checkString('class a { constructor(a , b) {} }'))
164+
.to.have.one.validation.error.from('validateParameterSeparator');
165+
});
166+
152167
it('should report missing space for function a(b,c) {}', function() {
153168
expect(checker.checkString('function a(b,c) {}'))
154169
.to.have.one.validation.error.from('validateParameterSeparator');
@@ -192,6 +207,11 @@ describe('rules/validate-parameter-separator', function() {
192207
.to.have.one.validation.error.from('validateParameterSeparator');
193208
});
194209

210+
it('should validate class methods', function() {
211+
expect(checker.checkString('class a { constructor(a, b) {} }'))
212+
.to.have.one.validation.error.from('validateParameterSeparator');
213+
});
214+
195215
it('should report missing space for function a(b ,c) {}', function() {
196216
expect(checker.checkString('function a(b ,c) {}'))
197217
.to.have.one.validation.error.from('validateParameterSeparator');

0 commit comments

Comments
 (0)