# no-unsafe-property-key

Rule `unicorn/no-unsafe-property-key`. Disallow unsafe values as property keys.

- Source: unicorn
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1055 by reach, #1310 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-unsafe-property-key` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-unsafe-property-key.md) |

## Code examples

### Incorrect: the rule reports this

```js
object[key] = value;
```

```js
const object = {
  [key]: value,
};
```

```js
array[4n] = value;
```

### Correct: the rule accepts this

```js
object[String(key)] = value;
```

```js
const object = {
  [key.join('')]: value,
};
```

```js
array[Number(4n)] = value;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-unsafe-property-key": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-unsafe-json-serialization](https://lintradar.dev/rules/unicorn/no-unsafe-json-serialization.md): Disallow known values that JSON serialization cannot represent faithfully.
- [unicorn/no-useless-else](https://lintradar.dev/rules/unicorn/no-useless-else.md): Disallow `else` after a statement that exits.
- [unicorn/no-unnecessary-parameters](https://lintradar.dev/rules/unicorn/no-unnecessary-parameters.md): Disallow parameters that receive the same value at every call.
- [unicorn/operator-assignment](https://lintradar.dev/rules/unicorn/operator-assignment.md): Require assignment operator shorthand where possible.
- [unicorn/no-unnecessary-boolean-comparison](https://lintradar.dev/rules/unicorn/no-unnecessary-boolean-comparison.md): Disallow unnecessary comparisons against boolean literals.
- [unicorn/prefer-abort-signal-any](https://lintradar.dev/rules/unicorn/prefer-abort-signal-any.md): Prefer `AbortSignal.any()` over manually forwarding abort events between signals.

---

Web page: https://lintradar.dev/rules/unicorn/no-unsafe-property-key. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
