---
url: /docs/guide/usage/linter/rules/eslint/no-restricted-properties.md
---

### What it does

This rule allows you to disallow access to certain properties on certain objects.

### Why is this bad?

Certain properties on objects may be disallowed in a codebase. This is useful for
deprecating an API or restricting usage of a module’s methods. For example, you may want
to disallow using describe.only when using Mocha or telling people to use Object.assign
instead of \_.extend.

If you want to disallow APIs marked with `@deprecated`, consider using the type-aware
`typescript/no-deprecated` rule instead.

### Examples

**With options:**

```json
"no-restricted-properties": ["error", {
  "object": "JSON",
  "property": "parse"
}]
```

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

```js
/* no-restricted-properties: ["error", { "object": "JSON", "property": "parse" }] */

JSON.parse('{ "json": "here" }'); // 'JSON.parse' is restricted from being used.
```

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

```js
/* no-restricted-properties: ["error", { "object": "JSON", "property": "parse" }] */

JSON.stringify({ json: "here" });
```

**With options:**

```json
"no-restricted-properties": ["error", {
  "property": "extend",
  "allowObjects": ["safeUtils"]
}]
```

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

```js
/* no-restricted-properties: ["error", { "property": "extend", "allowObjects": ["safeUtils"] }] */

unsafeUtils.extend(value); // 'extend' is restricted from being used. Property 'extend' is only allowed on these objects: safeUtils.
```

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

```js
/* no-restricted-properties: ["error", { "property": "extend", "allowObjects": ["safeUtils"] }] */

safeUtils.extend(value);
```

**With options:**

```json
"no-restricted-properties": ["error", {
  "object": "legacyApi",
  "allowProperties": ["stableMethod"]
}]
```

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

```js
/* no-restricted-properties: ["error", { "object": "legacyApi", "allowProperties": ["stableMethod"] }] */

legacyApi.unstableMethod(); // 'legacyApi' is restricted from being used. Only these properties are allowed: stableMethod.
```

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

```js
/* no-restricted-properties: ["error", { "object": "legacyApi", "allowProperties": ["stableMethod"] }] */

legacyApi.stableMethod();
```

## How to use

## Version

This rule was added in v1.63.0.

## References
