From 3c086f1678d1df854599d6b33bbfb541b705789b Mon Sep 17 00:00:00 2001 From: kobelb Date: Wed, 10 May 2017 09:18:24 -0400 Subject: [PATCH] Modifying semi rule to support for await --- README.md | 2 +- rules/semi.js | 2 +- tests/rules/semi.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82a80d5..a9da548 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Each rule corresponds to a core `eslint` rule, and has the same options. - `babel/new-cap`: Ignores capitalized decorators (`@Decorator`) - `babel/object-curly-spacing`: doesn't complain about `export x from "mod";` or `export * as x from "mod";` (🛠) - `babel/no-invalid-this`: doesn't fail when inside class properties (`class A { a = this.b; }`) -- `babel/semi`: Includes class properties (🛠) +- `babel/semi`: doesn't fail when using `for await (let something of {})`. Includes class properties (🛠) #### Deprecated diff --git a/rules/semi.js b/rules/semi.js index 48bbb7e..0f9ef74 100644 --- a/rules/semi.js +++ b/rules/semi.js @@ -187,7 +187,7 @@ module.exports = { parent = ancestors[parentIndex]; if ((parent.type !== "ForStatement" || parent.init !== node) && - (!/^For(?:In|Of)Statement/.test(parent.type) || parent.left !== node) + (!/^For(?:In|Of|Await)Statement/.test(parent.type) || parent.left !== node) ) { checkForSemicolon(node); } diff --git a/tests/rules/semi.js b/tests/rules/semi.js index 3d146a1..b3f4620 100644 --- a/tests/rules/semi.js +++ b/tests/rules/semi.js @@ -102,6 +102,7 @@ ruleTester.run("semi", rule, { // babel "class Foo { bar = 'example'; }", "class Foo { static bar = 'example'; }", + { code: "async function foo() { for await (let thing of {}) { console.log(thing); } }", parserOptions: { ecmaVersion: 6 } }, // babel, "never" { code: "class Foo { bar = 'example' }", options: ["never"] },