ronantakizawa/codereview-bench huggingface dataset:
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
		{
			code: "global.execScript(function() { x = 1; }, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "global.setTimeout(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "global.setInterval(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "global.execScript(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "globalThis.setTimeout(foo, 100);",
			languageOptions: { ecmaVersion: 2020, globals: globals.browser },
		},

		// only checks on top-level statements or window.*
		{
			code: "foo.setTimeout('hi')",
			languageOptions: { globals: globals.browser },
		},

		// identifiers are fine
		{
			code: "setTimeout(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(1, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(2)",
			languageOptions: { globals: globals.browser },

Review comment (suggestion):
```suggestion
```

Same as the previous comment.

Code after:
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "global.setInterval(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "global.execScript(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "globalThis.setTimeout(foo, 100);",
			languageOptions: { ecmaVersion: 2020 },
		},

		// only checks on top-level statements or window.*
		{
			code: "foo.setTimeout('hi')",
			languageOptions: { globals: globals.browser },
		},

		// identifiers are fine
		{
			code: "setTimeout(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(1, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(2)",
			languageOptions: { globals: { execScript: false } },
		},

		// as are function expressions
		{
			code: "setTimeout(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// setInterval
		{
			code: "foo.setInterval('hi')",
			languageOptions: { globals: globals.browser },
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
			},
		},
		{
			code: "global.setTimeout(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "global.setInterval(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "global.execScript(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "globalThis.setTimeout(foo, 100);",
			languageOptions: { ecmaVersion: 2020, globals: globals.browser },
		},

		// only checks on top-level statements or window.*
		{
			code: "foo.setTimeout('hi')",
			languageOptions: { globals: globals.browser },
		},

		// identifiers are fine
		{
			code: "setTimeout(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(1, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(2)",
			languageOptions: { globals: globals.browser },
		},

		// as are function expressions
		{
			code: "setTimeout(function() {}, 10)",

Review comment (suggestion):
```suggestion
			languageOptions: { ecmaVersion: 2020 },
```

`globalThis` is enabled as a global by `ecmaVersion: 2020`.

Code after:
			code: "global.setInterval(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "global.execScript(foo, 100);",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "globalThis.setTimeout(foo, 100);",
			languageOptions: { ecmaVersion: 2020 },
		},

		// only checks on top-level statements or window.*
		{
			code: "foo.setTimeout('hi')",
			languageOptions: { globals: globals.browser },
		},

		// identifiers are fine
		{
			code: "setTimeout(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(1, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(2)",
			languageOptions: { globals: { execScript: false } },
		},

		// as are function expressions
		{
			code: "setTimeout(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// setInterval
		{
			code: "foo.setInterval('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
				globals: globals.browser,
			},
		},
		{
			code: "globalThis.setTimeout(foo, 100);",
			languageOptions: { ecmaVersion: 2020, globals: globals.browser },
		},

		// only checks on top-level statements or window.*
		{
			code: "foo.setTimeout('hi')",
			languageOptions: { globals: globals.browser },
		},

		// identifiers are fine
		{
			code: "setTimeout(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(1, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(2)",
			languageOptions: { globals: globals.browser },
		},

		// as are function expressions
		{
			code: "setTimeout(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// setInterval
		{
			code: "foo.setInterval('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// execScript
		{
			code: "foo.execScript('hi')",

Review comment (suggestion):
```suggestion
			languageOptions: { globals: { execScript: false } },
```

`execScript` is not in `globals.browser`.

Code after:
		},

		// identifiers are fine
		{
			code: "setTimeout(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(1, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(2)",
			languageOptions: { globals: { execScript: false } },
		},

		// as are function expressions
		{
			code: "setTimeout(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// setInterval
		{
			code: "foo.setInterval('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// execScript
		{
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: { execScript: false } },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: { execScript: false } },
		},

		// a binary plus on non-strings doesn't guarantee a string
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
			code: "setTimeout(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// setInterval
		{
			code: "foo.setInterval('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// execScript
		{
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: globals.browser },
		},

		// a binary plus on non-strings doesn't guarantee a string
		"setTimeout(foo + bar, 10)",

		// doesn't check anything but the first argument
		{
			code: "setTimeout(foobar, 'buzz')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setTimeout(foobar, foo + 'bar')",
			languageOptions: { globals: globals.browser },
		},

		// only checks immediate subtrees of the argument
		{
			code: "setTimeout(function() { return 'foobar'; }, 10)",
			languageOptions: { globals: globals.browser },
		},


Review comment (suggestion):
```suggestion
			languageOptions: { globals: { execScript: false } },
```

`execScript` is not in `globals.browser`.

Code after:
		},
		{
			code: "setInterval(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// execScript
		{
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: { execScript: false } },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: { execScript: false } },
		},

		// a binary plus on non-strings doesn't guarantee a string
		{
			code: "setTimeout(foo + bar, 10)",
			languageOptions: { globals: globals.browser },
		},

		// doesn't check anything but the first argument
		{
			code: "setTimeout(foobar, 'buzz')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setTimeout(foobar, foo + 'bar')",
			languageOptions: { globals: globals.browser },
		},

		// only checks immediate subtrees of the argument
		{
			code: "setTimeout(function() { return 'foobar'; }, 10)",
			languageOptions: { globals: globals.browser },
		},

		// https://github.com/eslint/eslint/issues/7821
		{
			code: "setTimeoutFooBar('Foo Bar')",
			languageOptions: { globals: globals.browser },
		},

		{
			code: "foo.window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
		// setInterval
		{
			code: "foo.setInterval('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// execScript
		{
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: globals.browser },
		},

		// a binary plus on non-strings doesn't guarantee a string
		"setTimeout(foo + bar, 10)",

		// doesn't check anything but the first argument
		{
			code: "setTimeout(foobar, 'buzz')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setTimeout(foobar, foo + 'bar')",
			languageOptions: { globals: globals.browser },
		},

		// only checks immediate subtrees of the argument
		{
			code: "setTimeout(function() { return 'foobar'; }, 10)",
			languageOptions: { globals: globals.browser },
		},

		// https://github.com/eslint/eslint/issues/7821
		{
			code: "setTimeoutFooBar('Foo Bar')",
			languageOptions: { globals: globals.browser },

Review comment (suggestion):
```suggestion
			languageOptions: { globals: { execScript: false } },
```

Same as the previous comment.

Code after:
		},

		// execScript
		{
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: { execScript: false } },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: { execScript: false } },
		},

		// a binary plus on non-strings doesn't guarantee a string
		{
			code: "setTimeout(foo + bar, 10)",
			languageOptions: { globals: globals.browser },
		},

		// doesn't check anything but the first argument
		{
			code: "setTimeout(foobar, 'buzz')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setTimeout(foobar, foo + 'bar')",
			languageOptions: { globals: globals.browser },
		},

		// only checks immediate subtrees of the argument
		{
			code: "setTimeout(function() { return 'foobar'; }, 10)",
			languageOptions: { globals: globals.browser },
		},

		// https://github.com/eslint/eslint/issues/7821
		{
			code: "setTimeoutFooBar('Foo Bar')",
			languageOptions: { globals: globals.browser },
		},

		{
			code: "foo.window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo.global.setTimeout('foo', 100);",
			languageOptions: {
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
		},
		{
			code: "setInterval(foo, 10)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setInterval(function() {}, 10)",
			languageOptions: { globals: globals.browser },
		},

		// execScript
		{
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: globals.browser },
		},

		// a binary plus on non-strings doesn't guarantee a string
		"setTimeout(foo + bar, 10)",

		// doesn't check anything but the first argument
		{
			code: "setTimeout(foobar, 'buzz')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setTimeout(foobar, foo + 'bar')",
			languageOptions: { globals: globals.browser },
		},

		// only checks immediate subtrees of the argument
		{
			code: "setTimeout(function() { return 'foobar'; }, 10)",
			languageOptions: { globals: globals.browser },
		},

		// https://github.com/eslint/eslint/issues/7821
		{
			code: "setTimeoutFooBar('Foo Bar')",
			languageOptions: { globals: globals.browser },
		},

		{
			code: "foo.window.setTimeout('foo', 100);",

Review comment (suggestion):
```suggestion
		{
			code: "setTimeout(foo + bar, 10)",
			languageOptions: { globals: globals.browser },
		},
```

To not pass just because `setTimeout` is not a global.

Code after:
			code: "foo.execScript('hi')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "execScript(foo)",
			languageOptions: { globals: { execScript: false } },
		},
		{
			code: "execScript(function() {})",
			languageOptions: { globals: { execScript: false } },
		},

		// a binary plus on non-strings doesn't guarantee a string
		{
			code: "setTimeout(foo + bar, 10)",
			languageOptions: { globals: globals.browser },
		},

		// doesn't check anything but the first argument
		{
			code: "setTimeout(foobar, 'buzz')",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "setTimeout(foobar, foo + 'bar')",
			languageOptions: { globals: globals.browser },
		},

		// only checks immediate subtrees of the argument
		{
			code: "setTimeout(function() { return 'foobar'; }, 10)",
			languageOptions: { globals: globals.browser },
		},

		// https://github.com/eslint/eslint/issues/7821
		{
			code: "setTimeoutFooBar('Foo Bar')",
			languageOptions: { globals: globals.browser },
		},

		{
			code: "foo.window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo.global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
		// https://github.com/eslint/eslint/issues/7821
		{
			code: "setTimeoutFooBar('Foo Bar')",
			languageOptions: { globals: globals.browser },
		},

		{
			code: "foo.window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo.global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "var window; window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "var global; global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "function foo(window) { window.setTimeout('foo', 100); }",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "function foo(global) { global.setTimeout('foo', 100); }",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "foo('', window.setTimeout);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo('', global.setTimeout);",
			languageOptions: { sourceType: "commonjs" },
		},

		// https://github.com/eslint/eslint/issues/19923
		{
			code: `

Review comment (suggestion):
```suggestion
```

`global` is enabled as a global by `sourceType: "commonjs"`.

Code after:
		},
		{
			code: "foo.global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "var window; window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "var global; global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "function foo(window) { window.setTimeout('foo', 100); }",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "function foo(global) { global.setTimeout('foo', 100); }",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "foo('', window.setTimeout);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo('', global.setTimeout);",
			languageOptions: { sourceType: "commonjs" },
		},

		// https://github.com/eslint/eslint/issues/19923
		{
			code: `
			function execScript(string) {
				console.log("This is not your grandparent's execScript().");
			}

			execScript('wibble');
			`,
			languageOptions: {
				globals: { execScript: false },
			},
		},
		{
Repository: eslint/eslint
File: tests/lib/rules/no-implied-eval.js (JavaScript)

Code before:
			code: "foo.global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "var window; window.setTimeout('foo', 100);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "var global; global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "function foo(window) { window.setTimeout('foo', 100); }",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "function foo(global) { global.setTimeout('foo', 100); }",
			languageOptions: {
				sourceType: "commonjs",
				globals: globals.browser,
			},
		},
		{
			code: "foo('', window.setTimeout);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo('', global.setTimeout);",
			languageOptions: { sourceType: "commonjs" },
		},

		// https://github.com/eslint/eslint/issues/19923
		{
			code: `
			function execScript(string) {
				console.log("This is not your grandparent's execScript().");
			}

			execScript('wibble');
			`,
			languageOptions: {
				globals: { execScript: false },
			},
		},
		{

Review comment (suggestion):
```suggestion
```

Same as the previous comment.

Code after:
		},
		{
			code: "var global; global.setTimeout('foo', 100);",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "function foo(window) { window.setTimeout('foo', 100); }",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "function foo(global) { global.setTimeout('foo', 100); }",
			languageOptions: {
				sourceType: "commonjs",
			},
		},
		{
			code: "foo('', window.setTimeout);",
			languageOptions: { globals: globals.browser },
		},
		{
			code: "foo('', global.setTimeout);",
			languageOptions: { sourceType: "commonjs" },
		},

		// https://github.com/eslint/eslint/issues/19923
		{
			code: `
			function execScript(string) {
				console.log("This is not your grandparent's execScript().");
			}

			execScript('wibble');
			`,
			languageOptions: {
				globals: { execScript: false },
			},
		},
		{
			code: `
			function setTimeout(string) {
				console.log("This is not your grandparent's setTimeout().");
			}

			setTimeout('wibble');
			`,
			languageOptions: {
				globals: globals.browser,
			},
		},
Repository: eslint/eslint
File: lib/rules/one-var.js (JavaScript)

Code before:
		 * Decrements the functionStack counter.
		 * @returns {void}
		 * @private
		 */
		function endFunction() {
			functionStack.pop();
			endBlock();
		}

		/**
		 * Check if a variable declaration is a require.
		 * @param {ASTNode} decl variable declaration Node
		 * @returns {bool} if decl is a require, return true; else return false.
		 * @private
		 */
		function isRequire(decl) {
			return (
				decl.init &&
				decl.init.type === "CallExpression" &&
				decl.init.callee.name === "require"
			);
		}

		/**
		 * Records whether initialized/uninitialized/required variables are defined in current scope.
		 * @param {string} statementType node.kind, one of: "var", "let", "const", "using", or "await using"
		 * @param {ASTNode[]} declarations List of declarations
		 * @param {Object} currentScope The scope being investigated
		 * @returns {void}
		 * @private
		 */
		function recordTypes(statementType, declarations, currentScope) {
			for (let i = 0; i < declarations.length; i++) {
				if (declarations[i].init === null) {
					if (
						options[statementType] &&
						options[statementType].uninitialized === MODE_ALWAYS
					) {
						currentScope.uninitialized = true;
					}
				} else {
					if (
						options[statementType] &&
						options[statementType].initialized === MODE_ALWAYS
					) {
						if (
							options.separateRequires &&
							isRequire(declarations[i])
						) {
							currentScope.required = true;
						} else {

Review comment (suggestion):
```suggestion
		 * @param {string} statementType one of: "var", "let", "const", "using", or "awaitUsing"
```

Code after:
		 * Decrements the functionStack counter.
		 * @returns {void}
		 * @private
		 */
		function endFunction() {
			functionStack.pop();
			endBlock();
		}

		/**
		 * Check if a variable declaration is a require.
		 * @param {ASTNode} decl variable declaration Node
		 * @returns {bool} if decl is a require, return true; else return false.
		 * @private
		 */
		function isRequire(decl) {
			return (
				decl.init &&
				decl.init.type === "CallExpression" &&
				decl.init.callee.name === "require"
			);
		}

		/**
		 * Records whether initialized/uninitialized/required variables are defined in current scope.
		 * @param {string} statementType one of: "var", "let", "const", "using", or "awaitUsing"
		 * @param {ASTNode[]} declarations List of declarations
		 * @param {Object} currentScope The scope being investigated
		 * @returns {void}
		 * @private
		 */
		function recordTypes(statementType, declarations, currentScope) {
			for (let i = 0; i < declarations.length; i++) {
				if (declarations[i].init === null) {
					if (
						options[statementType] &&
						options[statementType].uninitialized === MODE_ALWAYS
					) {
						currentScope.uninitialized = true;
					}
				} else {
					if (
						options[statementType] &&
						options[statementType].initialized === MODE_ALWAYS
					) {
						if (
							options.separateRequires &&
							isRequire(declarations[i])
						) {
							currentScope.required = true;
						} else {