Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_dupe_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use oxc_ast::{
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use rustc_hash::FxHashMap;
use rustc_hash::{FxBuildHasher, FxHashMap};

use crate::{context::LintContext, rule::Rule, AstNode};

Expand Down Expand Up @@ -43,7 +43,11 @@ impl Rule for NoDupeKeys {
let AstKind::ObjectExpression(obj_expr) = node.kind() else {
return;
};
let mut map = FxHashMap::default();
let len = obj_expr.properties.len();
if len <= 1 {
return;
}
let mut map = FxHashMap::with_capacity_and_hasher(len, FxBuildHasher);
for prop in &obj_expr.properties {
let ObjectPropertyKind::ObjectProperty(prop) = prop else {
continue;
Expand Down