diff --git a/README.md b/README.md index 157bd2d..4da03e0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ original ones as well!). "babel/object-curly-spacing": 1, "babel/no-await-in-loop": 1, "babel/flow-object-type": 1, - "babel/no-invalid-this": 1 + "babel/no-invalid-this": 1, + "babel/semi": 1 } } ``` @@ -50,6 +51,7 @@ The following rules are not in `eslint`, but are relevant only to syntax that is the current JavaScript standard or supported by `eslint`. - `babel/no-await-in-loop`: guard against awaiting async functions inside of a loop +- `babel/semi`: Includes class properties #### Deprecated diff --git a/rules/semi.js b/rules/semi.js index ee37ab0..48bbb7e 100644 --- a/rules/semi.js +++ b/rules/semi.js @@ -208,6 +208,7 @@ module.exports = { ContinueStatement: checkForSemicolon, ImportDeclaration: checkForSemicolon, ExportAllDeclaration: checkForSemicolon, + ClassProperty: checkForSemicolon, ExportNamedDeclaration(node) { if (!node.declaration) { checkForSemicolon(node); diff --git a/tests/rules/semi.js b/tests/rules/semi.js index a23a6e8..3d146a1 100644 --- a/tests/rules/semi.js +++ b/tests/rules/semi.js @@ -97,7 +97,15 @@ ruleTester.run("semi", rule, { // https://github.com/eslint/eslint/issues/7782 { code: "var a = b;\n/foo/.test(c)", options: ["never"] }, - { code: "var a = b;\n`foo`", options: ["never"], parserOptions: { ecmaVersion: 6 } } + { code: "var a = b;\n`foo`", options: ["never"], parserOptions: { ecmaVersion: 6 } }, + + // babel + "class Foo { bar = 'example'; }", + "class Foo { static bar = 'example'; }", + + // babel, "never" + { code: "class Foo { bar = 'example' }", options: ["never"] }, + { code: "class Foo { static bar = 'example' }", options: ["never"] } ], invalid: [ { code: "import * as utils from './utils'", output: "import * as utils from './utils';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ImportDeclaration", column: 33 }] }, @@ -170,6 +178,14 @@ ruleTester.run("semi", rule, { { code: "export default (foo) => foo.bar();", output: "export default (foo) => foo.bar()", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, { code: "export default foo = 42;", output: "export default foo = 42", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, { code: "export default foo += 42;", output: "export default foo += 42", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, - { code: "a;\n++b", output: "a\n++b", options: ["never"], errors: [{ message: "Extra semicolon." }] } + { code: "a;\n++b", output: "a\n++b", options: ["never"], errors: [{ message: "Extra semicolon." }] }, + + // babel + { code: "class Foo { bar = 'example' }", errors: [{ message: "Missing semicolon." }] }, + { code: "class Foo { static bar = 'example' }", errors: [{ message: "Missing semicolon." }] }, + + // babel, "never" + { code: "class Foo { bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] }, + { code: "class Foo { static bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] } ] });