---
url: /ja/rules/no-mutable-property-of-props-interface.md
---

# no-mutable-property-of-props-interface

このルールは、CDK Construct または Stack の `Props` (interface) のプロパティに、`readonly` 修飾子を指定することを強制します

意図しない副作用を防ぐため、Props のプロパティには `readonly` 修飾子を指定することが推奨されます。

***

#### 🔧 使用方法

::: code-group

```ts [Oxlint]
// oxlint.config.ts
export default defineConfig({
  // ... some configs
  rules: {
    "awscdk/no-mutable-property-of-props-interface": "error",
  },
});
```

```js [ESLint]
// eslint.config.mjs
export default defineConfig({
  // ... some configs
  rules: {
    "awscdk/no-mutable-property-of-props-interface": "error",
  },
});
```

:::

#### ✅ 適切な例

```ts
import { IBucket } from "aws-cdk-lib/aws-s3";

interface MyConstructProps {
  // ✅ Props のプロパティに readonly 修飾子が指定されている
  readonly bucket: IBucket;
}
```

```ts
import { IBucket } from "aws-cdk-lib/aws-s3";

// ✅ Props ではない interface に対しては、このルールは適用されない
interface MyInterface {
  bucket: IBucket;
}
```

#### ❌ 不適切な例

```ts
import { IBucket } from "aws-cdk-lib/aws-s3";

interface MyConstructProps {
  // ❌ Props のプロパティに readonly 修飾子が指定されていない
  bucket: IBucket;
}
```
