# frame-ancestors

Rule `sonarjs/frame-ancestors`. Content Security Policy frame-ancestors directive should not be disabled

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Deprecated: yes
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2136 by reach

## Linters

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

## Code examples

### Correct: the rule accepts this

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

let app = express();

app.use(
  helmet.contentSecurityPolicy({
    directives: {
      // other directives
      frameAncestors: ["'example.com'"] // Compliant
    }
  })
);
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/frame-ancestors": "error",
    },
  },
];
```

## Related rules

- [sonarjs/for-in](https://lintradar.dev/rules/sonarjs/for-in.md): "for...in" loops should filter properties before acting on them
- [sonarjs/function-name](https://lintradar.dev/rules/sonarjs/function-name.md): Function and method names should comply with a naming convention
- [sonarjs/file-name-differ-from-class](https://lintradar.dev/rules/sonarjs/file-name-differ-from-class.md): Default export names and file names should match
- [sonarjs/file-header](https://lintradar.dev/rules/sonarjs/file-header.md): Track lack of copyright and license headers
- [sonarjs/max-lines](https://lintradar.dev/rules/sonarjs/max-lines.md): Files should not have too many lines of code
- [sonarjs/expression-complexity](https://lintradar.dev/rules/sonarjs/expression-complexity.md): Expressions should not be too complex

---

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