Skip to content

objectKeyDuplicates

Reports unnecessary duplicate keys that override previous values.

✅ This rule is included in the ts untyped preset.

Duplicate object keys are legal in JavaScript, but they can lead to unexpected behavior. When duplicate keys exist, only the last value for a given key is used. This can cause confusion and bugs, especially when maintaining the code.

const object = { a: 1, a: 2 };
const config = {
port: 3000,
host: "localhost",
port: 8080,
};

This rule is not configurable.

If your project intentionally creates duplicate keys as an unusual style choice, this rule may not be for you. If you have a rare case where duplicate keys are intentional, you can use Flint disable comments for those specific situations instead of completely disabling this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.