Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: added async in allow method in no-empty-function (fixes #12768) #13036

Merged
merged 8 commits into from Mar 20, 2020
4 changes: 3 additions & 1 deletion lib/rules/no-empty-function.js
Expand Up @@ -23,7 +23,9 @@ const ALLOW_OPTIONS = Object.freeze([
"generatorMethods",
"getters",
"setters",
"constructors"
"constructors",
"asyncFunctions",
"asyncMethods"
]);

/**
Expand Down
14 changes: 13 additions & 1 deletion tests/lib/rules/no-empty-function.js
Expand Up @@ -24,7 +24,9 @@ const ALLOW_OPTIONS = Object.freeze([
"generatorMethods",
"getters",
"setters",
"constructors"
"constructors",
"asyncFunctions",
"asyncMethods"
]);

/**
Expand Down Expand Up @@ -267,6 +269,16 @@ ruleTester.run("no-empty-function", rule, [
{
code: "var foo = () => 0;",
parserOptions: { ecmaVersion: 6 }
},
{
code: "const foo = { async method() {} }",
anikethsaha marked this conversation as resolved.
Show resolved Hide resolved
options: [{ allow: ["asyncMethods"] }],
parserOptions: { ecmaVersion: 8 }
},
{
code: "async function a(){}",
options: [{ allow: ["asyncFunctions"] }],
parserOptions: { ecmaVersion: 8 }
anikethsaha marked this conversation as resolved.
Show resolved Hide resolved
}
],
invalid: []
Expand Down