From 3b4d3b66682134da2700c30de07d57d91168e459 Mon Sep 17 00:00:00 2001 From: azihsoyn Date: Tue, 19 Nov 2024 02:11:09 +0900 Subject: [PATCH 1/7] implement eslint/no-object-constructor --- crates/oxc_linter/src/rules.rs | 2 + .../src/rules/eslint/no_object_constructor.rs | 111 ++++++++++++++++++ .../snapshots/no_object_constructor.snap.new | 46 ++++++++ 3 files changed, 159 insertions(+) create mode 100644 crates/oxc_linter/src/rules/eslint/no_object_constructor.rs create mode 100644 crates/oxc_linter/src/snapshots/no_object_constructor.snap.new diff --git a/crates/oxc_linter/src/rules.rs b/crates/oxc_linter/src/rules.rs index 381bce640d212..e2cddafc36c91 100644 --- a/crates/oxc_linter/src/rules.rs +++ b/crates/oxc_linter/src/rules.rs @@ -96,6 +96,7 @@ mod eslint { pub mod no_new_wrappers; pub mod no_nonoctal_decimal_escape; pub mod no_obj_calls; + pub mod no_object_constructor; pub mod no_plusplus; pub mod no_proto; pub mod no_prototype_builtins; @@ -525,6 +526,7 @@ oxc_macros::declare_all_lint_rules! { eslint::max_classes_per_file, eslint::max_lines, eslint::max_params, + eslint::no_object_constructor, eslint::no_alert, eslint::no_array_constructor, eslint::no_async_promise_executor, diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs new file mode 100644 index 0000000000000..49482c633b6a5 --- /dev/null +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -0,0 +1,111 @@ +use oxc_ast::ast::Expression; +use oxc_ast::AstKind; +use oxc_diagnostics::OxcDiagnostic; +use oxc_macros::declare_oxc_lint; +use oxc_semantic::IsGlobalReference; +use oxc_span::Span; + +use crate::{ + context::LintContext, + rule::Rule, + AstNode, +}; + +fn no_object_constructor_diagnostic(span: Span) -> OxcDiagnostic { + // See for details + OxcDiagnostic::warn("Disallow calls to the `Object` constructor without an argument") + .with_help("Use object literal notation {} instead") + .with_label(span) +} + +#[derive(Debug, Default, Clone)] +pub struct NoObjectConstructor; + +declare_oxc_lint!( + /// ### What it does + /// + /// Disallow calls to the Object constructor without an argument + /// + /// ### Why is this bad? + /// + /// Use of the Object constructor to construct a new empty object is generally discouraged in favor of object literal notation because of conciseness and because the Object global may be redefined. The exception is when the Object constructor is used to intentionally wrap a specified value which is passed as an argument. + /// + /// ### Examples + /// + /// Examples of **incorrect** code for this rule: + /// ```js + /// Object(); + /// new Object(); + /// ``` + /// + /// Examples of **correct** code for this rule: + /// ```js + /// Object("foo"); + /// const obj = { a: 1, b: 2 }; + /// const isObject = value => value === Object(value); + /// const createObject = Object => new Object(); + /// ``` + NoObjectConstructor, + pedantic, + pending +); + +impl Rule for NoObjectConstructor { + + fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) { + let (span, callee, arguments, type_parameters) = match node.kind() { + AstKind::CallExpression(call_expr) => ( + call_expr.span, + &call_expr.callee, + &call_expr.arguments, + &call_expr.type_parameters, + ), + AstKind::NewExpression(new_expr) => ( + new_expr.span, + &new_expr.callee, + &new_expr.arguments, + &new_expr.type_parameters, + ), + _ => { + return; + } + }; + + let Expression::Identifier(ident) = &callee else { + return; + }; + + if ident.is_global_reference_name("Object", ctx.symbols()) + && arguments.len() == 0 + && type_parameters.is_none() + { + ctx.diagnostic(crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span)); + } + } +} + +#[test] +fn test() { + use crate::tester::Tester; + + let pass = vec![ + "new Object(x)", + "Object(x)", + "new globalThis.Object", + "const createObject = Object => new Object()", + "var Object; new Object;", + // Disabled because the eslint-test uses languageOptions: { globals: { Object: "off" } } + /* "new Object()", */ + ]; + + let fail = vec![ + "new Object", + "Object()", + "const fn = () => Object();", + "Object() instanceof Object;", + "const obj = Object?.();", + "(new Object() instanceof Object);", + ]; + + Tester::new(NoObjectConstructor::NAME, pass, fail).test_and_snapshot(); +} diff --git a/crates/oxc_linter/src/snapshots/no_object_constructor.snap.new b/crates/oxc_linter/src/snapshots/no_object_constructor.snap.new new file mode 100644 index 0000000000000..32d4e638cb9db --- /dev/null +++ b/crates/oxc_linter/src/snapshots/no_object_constructor.snap.new @@ -0,0 +1,46 @@ +--- +source: crates/oxc_linter/src/tester.rs +assertion_line: 353 +snapshot_kind: text +--- + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:1] + 1 │ new Object + · ────────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:1] + 1 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:18] + 1 │ const fn = () => Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:1] + 1 │ Object() instanceof Object; + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:13] + 1 │ const obj = Object?.(); + · ────────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:2] + 1 │ (new Object() instanceof Object); + · ──────────── + ╰──── + help: Use object literal notation {} instead From 6e2f937a9696e1c6123c0c1e7236173954cc999d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:22:11 +0000 Subject: [PATCH 2/7] [autofix.ci] apply automated fixes --- .../src/rules/eslint/no_object_constructor.rs | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs index 49482c633b6a5..9c93fce2afcb4 100644 --- a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -5,11 +5,7 @@ use oxc_macros::declare_oxc_lint; use oxc_semantic::IsGlobalReference; use oxc_span::Span; -use crate::{ - context::LintContext, - rule::Rule, - AstNode, -}; +use crate::{context::LintContext, rule::Rule, AstNode}; fn no_object_constructor_diagnostic(span: Span) -> OxcDiagnostic { // See for details @@ -51,7 +47,6 @@ declare_oxc_lint!( ); impl Rule for NoObjectConstructor { - fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) { let (span, callee, arguments, type_parameters) = match node.kind() { AstKind::CallExpression(call_expr) => ( @@ -60,12 +55,9 @@ impl Rule for NoObjectConstructor { &call_expr.arguments, &call_expr.type_parameters, ), - AstKind::NewExpression(new_expr) => ( - new_expr.span, - &new_expr.callee, - &new_expr.arguments, - &new_expr.type_parameters, - ), + AstKind::NewExpression(new_expr) => { + (new_expr.span, &new_expr.callee, &new_expr.arguments, &new_expr.type_parameters) + } _ => { return; } @@ -79,7 +71,9 @@ impl Rule for NoObjectConstructor { && arguments.len() == 0 && type_parameters.is_none() { - ctx.diagnostic(crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span)); + ctx.diagnostic( + crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span), + ); } } } From 69ba5d46d1781f05541fe2da42495d497640c99b Mon Sep 17 00:00:00 2001 From: azihsoyn Date: Tue, 19 Nov 2024 02:28:31 +0900 Subject: [PATCH 3/7] update snapshot --- ...no_object_constructor.snap.new => no_object_constructor.snap} | 1 - 1 file changed, 1 deletion(-) rename crates/oxc_linter/src/snapshots/{no_object_constructor.snap.new => no_object_constructor.snap} (98%) diff --git a/crates/oxc_linter/src/snapshots/no_object_constructor.snap.new b/crates/oxc_linter/src/snapshots/no_object_constructor.snap similarity index 98% rename from crates/oxc_linter/src/snapshots/no_object_constructor.snap.new rename to crates/oxc_linter/src/snapshots/no_object_constructor.snap index 32d4e638cb9db..22cea336e252d 100644 --- a/crates/oxc_linter/src/snapshots/no_object_constructor.snap.new +++ b/crates/oxc_linter/src/snapshots/no_object_constructor.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -assertion_line: 353 snapshot_kind: text --- ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument From 41e04c3b5f801c56e047adc81fa092ce5bc06f29 Mon Sep 17 00:00:00 2001 From: Naoya Yoshizawa Date: Sat, 23 Nov 2024 23:25:52 +0900 Subject: [PATCH 4/7] Update crates/oxc_linter/src/rules/eslint/no_object_constructor.rs Co-authored-by: no-yan <63000297+no-yan@users.noreply.github.com> --- crates/oxc_linter/src/rules/eslint/no_object_constructor.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs index 9c93fce2afcb4..b528e94687247 100644 --- a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -71,9 +71,8 @@ impl Rule for NoObjectConstructor { && arguments.len() == 0 && type_parameters.is_none() { - ctx.diagnostic( - crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span), - ); + ctx.diagnostic(no_object_constructor_diagnostic(span)); + } } } From 871d8a2064a589a87f625b58a5cff4618b4cdce7 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 23 Nov 2024 14:26:35 +0000 Subject: [PATCH 5/7] [autofix.ci] apply automated fixes --- crates/oxc_linter/src/rules/eslint/no_object_constructor.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs index b528e94687247..362b5d80a7061 100644 --- a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -72,7 +72,6 @@ impl Rule for NoObjectConstructor { && type_parameters.is_none() { ctx.diagnostic(no_object_constructor_diagnostic(span)); - } } } From c4f229177e8550c74a4feab0f0d30c402ef1f553 Mon Sep 17 00:00:00 2001 From: azihsoyn Date: Sat, 23 Nov 2024 23:51:44 +0900 Subject: [PATCH 6/7] add missing test case with commented-out --- .../src/rules/eslint/no_object_constructor.rs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs index 362b5d80a7061..3027a9b5df657 100644 --- a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -97,6 +97,97 @@ fn test() { "Object() instanceof Object;", "const obj = Object?.();", "(new Object() instanceof Object);", + // Semicolon required before `({})` to compensate for ASI + /* + "foo + Object()", + "foo() + Object()", + "new foo + Object()", + "(a++) + Object()", + "++a + Object()", + "const foo = function() {} + Object()", + "const foo = class {} + Object()", + "foo = this.return + Object()", + "var yield = bar.yield + Object()", + "var foo = { bar: baz } + Object()", + (" + Object()", languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }) + (" + Object()", languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } })*/ + + // No semicolon required before `({})` because ASI does not occur + /* + "{} + Object()", + "function foo() {} + Object()", + "class Foo {} + Object()", + "foo: Object();", + "foo();Object();", + "{ Object(); }", + "if (a) Object();", + "if (a); else Object();", + "while (a) Object();", + "do Object(); + while (a);", + "for (let i = 0; i < 10; i++) Object();", + "for (const prop in obj) Object();", + "for (const element of iterable) Object();", + "with (obj) Object();",*/ + + // No semicolon required before `({})` because ASI still occurs + /* + "const foo = () => {} + Object()", + "a++ + Object()", + "a-- + Object()", + "function foo() { + return + Object(); + }", + "function * foo() { + yield + Object(); + }", + "do {} + while (a) + Object()", + "debugger + Object()", + "for (;;) { + break + Object() + }", + "for (;;) { + continue + Object() + }", + "foo: break foo + Object()", + "foo: while (true) continue foo + Object()", + ("const foo = bar + export { foo } + Object()", languageOptions: { sourceType: "module" }), + ("export { foo } from 'bar' + Object()", languageOptions: { sourceType: "module" }), + ("export * as foo from 'bar' + Object()", languageOptions: { sourceType: "module" }), + ("import foo from 'bar' + Object()", languageOptions: { sourceType: "module" }) + */ ]; Tester::new(NoObjectConstructor::NAME, pass, fail).test_and_snapshot(); From f69bc3bf7e0e3eb5e559b483eb8ca23b26c66630 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Sat, 23 Nov 2024 19:09:36 +0000 Subject: [PATCH 7/7] enable invalid cases --- .../src/rules/eslint/no_object_constructor.rs | 116 +++---- .../src/snapshots/no_object_constructor.snap | 287 +++++++++++++++++- 2 files changed, 336 insertions(+), 67 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs index 3027a9b5df657..2592b9fddc5e7 100644 --- a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -8,7 +8,6 @@ use oxc_span::Span; use crate::{context::LintContext, rule::Rule, AstNode}; fn no_object_constructor_diagnostic(span: Span) -> OxcDiagnostic { - // See for details OxcDiagnostic::warn("Disallow calls to the `Object` constructor without an argument") .with_help("Use object literal notation {} instead") .with_label(span) @@ -87,7 +86,7 @@ fn test() { "const createObject = Object => new Object()", "var Object; new Object;", // Disabled because the eslint-test uses languageOptions: { globals: { Object: "off" } } - /* "new Object()", */ + // "new Object()", ]; let fail = vec![ @@ -98,96 +97,81 @@ fn test() { "const obj = Object?.();", "(new Object() instanceof Object);", // Semicolon required before `({})` to compensate for ASI - /* - "foo - Object()", + "Object()", "foo() - Object()", - "new foo - Object()", - "(a++) - Object()", - "++a - Object()", - "const foo = function() {} - Object()", - "const foo = class {} - Object()", - "foo = this.return - Object()", + Object()", "var yield = bar.yield - Object()", + Object()", "var foo = { bar: baz } - Object()", - (" - Object()", languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }) - (" - Object()", languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } })*/ - + Object()", + " + Object()", + " + Object()", // No semicolon required before `({})` because ASI does not occur - /* + "Object()", "{} - Object()", + Object()", "function foo() {} - Object()", + Object()", "class Foo {} - Object()", + Object()", "foo: Object();", "foo();Object();", "{ Object(); }", "if (a) Object();", "if (a); else Object();", "while (a) Object();", - "do Object(); - while (a);", + "do Object(); while (a);", "for (let i = 0; i < 10; i++) Object();", "for (const prop in obj) Object();", "for (const element of iterable) Object();", - "with (obj) Object();",*/ - + "with (obj) Object();", // No semicolon required before `({})` because ASI still occurs - /* "const foo = () => {} - Object()", + Object()", "a++ - Object()", + Object()", "a-- - Object()", + Object()", "function foo() { - return - Object(); - }", + return + Object(); + }", "function * foo() { - yield - Object(); - }", - "do {} - while (a) - Object()", + yield + Object(); + }", + "do {} while (a) Object()", "debugger - Object()", + Object()", "for (;;) { - break - Object() - }", - "for (;;) { - continue - Object() - }", + break + Object() + }", + r"for (;;) { + continue + Object() + }", "foo: break foo - Object()", + Object()", "foo: while (true) continue foo - Object()", - ("const foo = bar - export { foo } - Object()", languageOptions: { sourceType: "module" }), - ("export { foo } from 'bar' - Object()", languageOptions: { sourceType: "module" }), - ("export * as foo from 'bar' - Object()", languageOptions: { sourceType: "module" }), - ("import foo from 'bar' - Object()", languageOptions: { sourceType: "module" }) - */ + Object()", + "const foo = bar + export { foo } + Object()", + "export { foo } from 'bar' + Object()", + r"export * as foo from 'bar' + Object()", + "import foo from 'bar + Object()", + "var yield = 5; + yield: while (foo) { + if (bar) + break yield + new Object(); + }", ]; Tester::new(NoObjectConstructor::NAME, pass, fail).test_and_snapshot(); diff --git a/crates/oxc_linter/src/snapshots/no_object_constructor.snap b/crates/oxc_linter/src/snapshots/no_object_constructor.snap index 22cea336e252d..f6d313176e5ca 100644 --- a/crates/oxc_linter/src/snapshots/no_object_constructor.snap +++ b/crates/oxc_linter/src/snapshots/no_object_constructor.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -snapshot_kind: text --- ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument ╭─[no_object_constructor.tsx:1:1] @@ -43,3 +42,289 @@ snapshot_kind: text · ──────────── ╰──── help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:1] + 1 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ foo() + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ var yield = bar.yield + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ var foo = { bar: baz } + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:1] + 1 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ {} + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ function foo() {} + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ class Foo {} + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:6] + 1 │ foo: Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:7] + 1 │ foo();Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:3] + 1 │ { Object(); } + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:8] + 1 │ if (a) Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:14] + 1 │ if (a); else Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:11] + 1 │ while (a) Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:4] + 1 │ do Object(); while (a); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:30] + 1 │ for (let i = 0; i < 10; i++) Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:25] + 1 │ for (const prop in obj) Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:33] + 1 │ for (const element of iterable) Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:12] + 1 │ with (obj) Object(); + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ const foo = () => {} + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ a++ + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ a-- + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:3:13] + 2 │ return + 3 │ Object(); + · ──────── + 4 │ } + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:3:13] + 2 │ yield + 3 │ Object(); + · ──────── + 4 │ } + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:1:17] + 1 │ do {} while (a) Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ debugger + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:3:13] + 2 │ break + 3 │ Object() + · ──────── + 4 │ } + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:3:13] + 2 │ continue + 3 │ Object() + · ──────── + 4 │ } + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ foo: break foo + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ foo: while (true) continue foo + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:3:9] + 2 │ export { foo } + 3 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ export { foo } from 'bar' + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:2:9] + 1 │ export * as foo from 'bar' + 2 │ Object() + · ──────── + ╰──── + help: Use object literal notation {} instead + + × Unterminated string + ╭─[no_object_constructor.tsx:1:17] + 1 │ import foo from 'bar + · ───── + 2 │ Object() + ╰──── + + ⚠ eslint(no-object-constructor): Disallow calls to the `Object` constructor without an argument + ╭─[no_object_constructor.tsx:5:13] + 4 │ break yield + 5 │ new Object(); + · ──────────── + 6 │ } + ╰──── + help: Use object literal notation {} instead