# strict-transport-security

Rule `sonarjs/strict-transport-security`. HTTP Strict-Transport-Security policy should not be disabled

- 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: #1367 by reach, #668 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/strict-transport-security` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-5739/) |

## Code examples

### Correct: the rule accepts this

```js
const express = require('express');
const helmet = require('helmet');

let app = express();

app.use(helmet.hsts({
  maxAge: 31536000,
  includeSubDomains: true
})); // Compliant
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/strict-transport-security": "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/stateful-regex](https://lintradar.dev/rules/sonarjs/stateful-regex.md): Regular expressions with the global flag should be used with caution
- [sonarjs/super-linear-regex](https://lintradar.dev/rules/sonarjs/super-linear-regex.md): Regular expressions should not cause non-linear backtracking
- [sonarjs/stable-tests](https://lintradar.dev/rules/sonarjs/stable-tests.md): Tests should be stable
- [sonarjs/synchronous-exception-assertions](https://lintradar.dev/rules/sonarjs/synchronous-exception-assertions.md): Synchronous exception assertions should receive synchronous callbacks
- [sonarjs/sql-queries](https://lintradar.dev/rules/sonarjs/sql-queries.md): SQL queries should not be dynamically formatted
- [sonarjs/synchronous-suite-callback](https://lintradar.dev/rules/sonarjs/synchronous-suite-callback.md): Tests should not be registered asynchronously in suite callbacks

---

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