This product is not supported for your selected Datadog site. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Metadata

ID: javascript-best-practices/require-yield

Language: JavaScript

Severity: Error

Category: Best Practices

Description

Generator functions must yield at some point. Otherwise, use a normal function.

Non-Compliant Code Examples

function* foo() { return 0; }
(function* foo() { return 0; })();
var obj = { *foo() { return 0; } }
class A { *foo() { return 0; } }
function* foo() { function* bar() { yield 0; } }
function* foo() { function* bar() { return 0; } yield 0; }

Compliant Code Examples

function foo() { return 0; }
function* foo() { yield 0; }
function* foo() { }
(function* foo() { yield 0; })();
(function* foo() { })();
var obj = { *foo() { yield 0; } };
var obj = { *foo() { } };
class A { *foo() { yield 0; } };
class A { *foo() { } }
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security

PREVIEWING: ida.adjivon/rtrieu/DOCS-10715-ET-standalone