From 6015308c939fb6c79ce62cdbe51c3df1b00faad5 Mon Sep 17 00:00:00 2001 From: Gajus Kuizinas Date: Tue, 26 May 2020 12:06:17 -0700 Subject: [PATCH] fix: check for class properties (fixes #210) --- src/rules/semi.js | 3 +++ tests/rules/assertions/semi.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/rules/semi.js b/src/rules/semi.js index 0f4b031c..5c6f94a7 100644 --- a/src/rules/semi.js +++ b/src/rules/semi.js @@ -57,6 +57,9 @@ const create = (context) => { return { OpaqueType: checkForSemicolon, TypeAlias: checkForSemicolon, + TypeAnnotation: (node) => { + checkForSemicolon(node.parent); + }, }; }; diff --git a/tests/rules/assertions/semi.js b/tests/rules/assertions/semi.js index 7dd267f0..81c43be5 100644 --- a/tests/rules/assertions/semi.js +++ b/tests/rules/assertions/semi.js @@ -1,5 +1,25 @@ export default { invalid: [ + { + code: 'class Foo { foo: string }', + errors: [ + { + message: 'Missing semicolon.', + }, + ], + options: ['always'], + output: 'class Foo { foo: string; }', + }, + { + code: 'class Foo { foo: string; }', + errors: [ + { + message: 'Extra semicolon.', + }, + ], + options: ['never'], + output: 'class Foo { foo: string }', + }, { code: 'type FooType = {}', errors: [ @@ -80,6 +100,14 @@ export default { code: 'type FooType = {};', options: ['always'], }, + { + code: 'class Foo { foo: string; }', + options: ['always'], + }, + { + code: 'class Foo { foo: string }', + options: ['never'], + }, { code: 'type FooType = { a: number;\n b: string;\n };', options: ['always'],