# no-referrer-policy

Rule `sonarjs/no-referrer-policy`. HTTP Referrer-Policy should not be set to an unsafe value

- 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: #1310 by reach, #611 by growth

## Linters

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

## Code examples

### Correct: the rule accepts this

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

let app = express();

app.use(
  helmet.referrerPolicy({
    policy: 'no-referrer' // Compliant
  })
);
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-referrer-policy": "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/no-redundant-optional](https://lintradar.dev/rules/sonarjs/no-redundant-optional.md): Optional properties should not redundantly include 'undefined'
- [sonarjs/no-regex-spaces](https://lintradar.dev/rules/sonarjs/no-regex-spaces.md): Regular expressions should not contain multiple spaces
- [sonarjs/no-redundant-jump](https://lintradar.dev/rules/sonarjs/no-redundant-jump.md): Jump statements should not be redundant
- [sonarjs/no-same-argument-assert](https://lintradar.dev/rules/sonarjs/no-same-argument-assert.md): Assertions should not be given twice the same argument
- [sonarjs/no-redundant-boolean](https://lintradar.dev/rules/sonarjs/no-redundant-boolean.md): Boolean literals should not be used in comparisons
- [sonarjs/no-same-line-conditional](https://lintradar.dev/rules/sonarjs/no-same-line-conditional.md): Conditionals should start on new lines

---

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