# os-command

Rule `sonarjs/os-command`. OS commands should not be executed using a shell interpreter

- 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: #2172 by reach

## Linters

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

## Code examples

### Correct: the rule accepts this

```js
const cp = require('child_process');

cp.spawnSync("/usr/bin/file.exe", { shell: false }); // Compliant
```

Examples from the ESLint documentation.

## Enable it

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

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

## Related rules

- [sonarjs/operation-returning-nan](https://lintradar.dev/rules/sonarjs/operation-returning-nan.md): Arithmetic operations should not result in "NaN"
- [sonarjs/prefer-immediate-return](https://lintradar.dev/rules/sonarjs/prefer-immediate-return.md): Local variables should not be declared and then immediately returned or thrown
- [sonarjs/non-number-in-arithmetic-expression](https://lintradar.dev/rules/sonarjs/non-number-in-arithmetic-expression.md): Arithmetic operators should only have numbers as operands
- [sonarjs/prefer-object-literal](https://lintradar.dev/rules/sonarjs/prefer-object-literal.md): Object literal syntax should be used
- [sonarjs/no-wildcard-import](https://lintradar.dev/rules/sonarjs/no-wildcard-import.md): Wildcard imports should not be used
- [sonarjs/shorthand-property-grouping](https://lintradar.dev/rules/sonarjs/shorthand-property-grouping.md): Shorthand object properties should be grouped at the beginning or end of an object declaration

---

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