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

Commit

Permalink
requireSemicolons: check for ClassProperty
Browse files Browse the repository at this point in the history
Closes gh-2057
  • Loading branch information
hzoo committed Jan 8, 2016
1 parent 11ba6fb commit afacf5c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/require-semicolons.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ module.exports.prototype = {
'ThrowStatement',
'BreakStatement',
'ContinueStatement',
'DebuggerStatement'
'DebuggerStatement',
'ClassProperty'
], function(node) {
// ignore variable declaration inside for and for-in
if (node.type === 'VariableDeclaration') {
Expand Down
32 changes: 32 additions & 0 deletions test/specs/rules/require-semicolons.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,38 @@ describe('rules/require-semicolons', function() {
});
});

describe('class property', function() {
valid([
'class A { asdf; }',
'export class A { asdf; }',
'export default class A { asdf; }',
'export default class A { asdf = 1; }'
]);

invalid([
'class A { asdf }',
'export class A { asdf }',
'export default class A { asdf }',
'export default class A { asdf = 1 }'
]);

reportAndFix({
name: 'class A { asdf }',
rules: config,
errors: 1,
input: 'class A { asdf }',
output: 'class A { asdf; }'
});

reportAndFix({
name: 'class A { asdf = 1 }',
rules: config,
errors: 1,
input: 'class A { asdf = 1 }',
output: 'class A { asdf = 1; }'
});
});

reportAndFix({
name: 'expression call with comments',
rules: config,
Expand Down

0 comments on commit afacf5c

Please sign in to comment.