> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-unsafe-unary-minus

[Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/no-unsafe-unary-minus': 'error',
    },
  },
]);
```

## Rule Details

Disallow unary negation of a value that is not a `number` or `bigint`.

Applying the unary minus operator (`-`) to a value that is not a number or bigint type is a likely mistake. JavaScript will coerce the value to a number, often resulting in `NaN`. This rule ensures the operand of unary negation is always `number` or `bigint`.

Examples of **incorrect** code for this rule:

```typescript
declare const str: string;
-str;

declare const bool: boolean;
-bool;

declare const obj: object;
-obj;
```

Examples of **correct** code for this rule:

```typescript
-42;
-someNumber;

declare const big: bigint;
-big;

declare const val: number | bigint;
-val;
```

## Original Documentation

- [typescript-eslint: no-unsafe-unary-minus](https://typescript-eslint.io/rules/no-unsafe-unary-minus)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unsafe-unary-minus.ts)
