sonarjs/generator-without-yield
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/generator-without-yield": "error",
},
},
];function* myGen(a, b) { // Noncompliant
let answer = 0;
answer += a * b;
}function* myGen(a, b) {
let answer = 0;
while (answer < 42) {
answer += a * b;
yield answer;
}
}Examples from the ESLint documentation.
sonarjs/generator-without-yield
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/generator-without-yield": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Future reserved words should not be used as identifiers
Functions should always return the same type
Functions should not be defined inside loops
Lifecycle hooks should not be interleaved with test cases or nested suites