From 73eb1e6f3d71b4bbf11f862583f490a19f38b30e Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 31 Jan 2022 22:30:01 +0100 Subject: [PATCH] Add tests for ensuring top level awaits Fixes https://github.com/standard/standard/issues/1548 --- .eslintrc.json | 2 +- test/validate-config.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9d14f1d7..f92423cb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,6 @@ { "parserOptions": { - "ecmaVersion": 2021, + "ecmaVersion": 2022, "ecmaFeatures": { "jsx": true }, diff --git a/test/validate-config.js b/test/validate-config.js index 090d1a5b..34b6a431 100644 --- a/test/validate-config.js +++ b/test/validate-config.js @@ -8,3 +8,11 @@ test('load config in eslint to validate all rule syntax is correct', async funct t.equal(lintResult.errorCount, 0) t.end() }) + +test('ensure we allow top level await', async function (t) { + const eslint = new ESLint() + const code = 'const foo = await 1\nconst bar = function () {}\nawait bar(foo)\n' + const [lintResult] = await eslint.lintText(code) + t.equal(lintResult.errorCount, 0) + t.end() +})