# no-mime-sniff

Rule `sonarjs/no-mime-sniff`. Browsers should not be allowed to perform MIME type sniffing

- 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: #1296 by reach, #597 by growth

## Linters

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

## Code examples

### Correct: the rule accepts this

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

let app = express();

app.use(helmet.noSniff());
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-mime-sniff": "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-literal-call](https://lintradar.dev/rules/sonarjs/no-literal-call.md): Literals should not be used as functions
- [sonarjs/no-misleading-array-reverse](https://lintradar.dev/rules/sonarjs/no-misleading-array-reverse.md): Array-mutating methods should not be used misleadingly
- [sonarjs/no-labels](https://lintradar.dev/rules/sonarjs/no-labels.md): Labels should not be used
- [sonarjs/no-misleading-character-class](https://lintradar.dev/rules/sonarjs/no-misleading-character-class.md): Unicode Grapheme Clusters should be avoided inside regex character classes
- [sonarjs/no-inverted-boolean-check](https://lintradar.dev/rules/sonarjs/no-inverted-boolean-check.md): Boolean checks should not be inverted
- [sonarjs/no-mutate-reactive-state-in-updated-hook](https://lintradar.dev/rules/sonarjs/no-mutate-reactive-state-in-updated-hook.md): Reactive state should not be unconditionally mutated inside Vue's "updated" lifecycle hook

---

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