# aws-s3-bucket-versioning

Rule `sonarjs/aws-s3-bucket-versioning`. Amazon S3 buckets should have versioning enabled

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1183 by reach, #484 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/aws-s3-bucket-versioning` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-6252/) |

## Code examples

### Correct: the rule accepts this

```js
const s3 = require('aws-cdk-lib/aws-s3');

new s3.Bucket(this, 'id', {
    bucketName: 'bucket',
    versioned: true
});
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/aws-s3-bucket-versioning": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/aws-s3-bucket-public-access](https://lintradar.dev/rules/sonarjs/aws-s3-bucket-public-access.md): Amazon S3 bucket public access should be fully blocked
- [sonarjs/aws-sagemaker-unencrypted-notebook](https://lintradar.dev/rules/sonarjs/aws-sagemaker-unencrypted-notebook.md): SageMaker notebook instances should be encrypted at rest
- [sonarjs/aws-s3-bucket-insecure-http](https://lintradar.dev/rules/sonarjs/aws-s3-bucket-insecure-http.md): S3 buckets should enforce HTTPS-only access
- [sonarjs/aws-sns-unencrypted-topics](https://lintradar.dev/rules/sonarjs/aws-sns-unencrypted-topics.md): Amazon SNS topics should be encrypted at rest
- [sonarjs/aws-s3-bucket-granted-access](https://lintradar.dev/rules/sonarjs/aws-s3-bucket-granted-access.md): S3 buckets should not grant access to all users or authenticated users
- [sonarjs/aws-sqs-unencrypted-queue](https://lintradar.dev/rules/sonarjs/aws-sqs-unencrypted-queue.md): SQS queues should be encrypted

---

Web page: https://lintradar.dev/rules/sonarjs/aws-s3-bucket-versioning. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
